title: Word wrapping in pango with mixed scripts
body: <p>I have a text box implementation that uses pango.  If i put a string that starts with a word in right-to-left script, followed by a space, followed by word in left-to-right based script, the word wrapping that pango uses gets messed up (using <code>PANGO_WRAP_WORD_CHAR</code>).  For the string <em>العربية ENGLISH</em> I get the following:</p>
  
  <p><a href="https://i.stack.imgur.com/TOXkb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TOXkb.png" alt="Bad word wrapping"></a></p>
  
  <p>If I add the unicode character <code>U+200F</code> after the space, then I get the expected word wrapping:</p>
  
  <p><a href="https://i.stack.imgur.com/QkTtI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QkTtI.png" alt="Expected word wrapping"></a></p>
  
  <p>Also, if I replace the Arabic script above with Hindi (which is left-to-right like the English next to it) then I still get the problem, so it doesn't seem to be a strictly left-to-right, right-to-left thing.  In the Hindi case, I put in a hack that inserts a <code>0x200E</code> after the space it resolves the problem.</p>
  
  <p>Is this a bug in pango?  Are there work-arounds I can try that are generic enough to fix the problem but not break other cases?  The current work around I'm using inserts either a <code>0x200E</code> or <code>0x200F</code> after every space based on the direction of the previous strongly directed character in the string, but I'm not sure if there's certain strings that this will cause problems with.</p>
  
  <p>Update: I was able to reproduce this problem on Ubuntu 12.04 with gedit (with <em>Enable Text Wrapping</em> and <em>Do no split words over two lines</em> settings enabled).  I simply typed <code>Hello world</code> over and over until it wrapped several times, then replaced all instances of <code>world</code> with <code>पहुंचगया</code>, and everything collapsed to a single line.</p>