<div dir="ltr">Thank you for your fast response,<div><br></div><div>The LRI/PDI seems like the best solution, I've already tried <span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">it without success. </span><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px">I will try again with the patch applied (on the unicode63 branch).</span></div><div><span style="font-family:arial,helvetica,sans-serif;font-size:12.8px"><br></span></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">Regards,</span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">Romain Ouabdelkader.</span></font></div><div class="gmail_extra"><br><div class="gmail_quote">2015-09-17 15:08 GMT+02:00 Dov Grobgeld <span dir="ltr"><<a href="mailto:dov.grobgeld@gmail.com" target="_blank">dov.grobgeld@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:arial,helvetica,sans-serif">It is correct according to the Bidi Algorithm as both the emoji and its modifiers are neutral characters, and thus they inherit their direction from the context, and in this case become RTL. I can think off of my head think about a couple of options of how to resolve this:<br><br></div><div style="font-family:arial,helvetica,sans-serif">1. Before doing directional rearrange, surround all runs of emoji like characters with LRI/PDI (requires non-released fribidi). <br></div><div style="font-family:arial,helvetica,sans-serif">2. Check the run level of the emoji after the bidi algo and increase the run level to the nearest higher even run-level before calling fribidi reorder lines.<br><br></div><div style="font-family:arial,helvetica,sans-serif">I'm sure there are other options as well. Probably Behdad will come up with a simple solution that I hadn't thought of. :-)<br><br></div><div style="font-family:arial,helvetica,sans-serif">Regards,<br></div><div style="font-family:arial,helvetica,sans-serif">Dov<br><br></div><div style="font-family:arial,helvetica,sans-serif"><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Thu, Sep 17, 2015 at 3:54 PM, Romain Ouabdelkader <span dir="ltr"><<a href="mailto:romain.ouabdelkader@gmail.com" target="_blank">romain.ouabdelkader@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div style="font-size:12.8px">Hi,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I'm having some trouble to get emojis to work with FriBidi.</div><div style="font-size:12.8px">Basic emoji works fine, but when using emoji modifiers in a RTL language, the modifiers end up before the emoji.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Here I have a string with an arabic text, the emoji U+1f476 (a baby) and a tone modifier U+1f3fb:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">const char utf8_input[] = u8"اختبار \U0001f476\U0001f3fb";</div><div style="font-size:12.8px">int utf8_len = sizeof(utf8_input) - 1;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">std::unique_ptr<FriBidiChar[]> unicode_str(new FriBidiChar[utf8_len]);</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">FriBidiCharSet utf8_charset = fribidi_parse_charset("UTF-8");</div><div style="font-size:12.8px">int len_unicode = fribidi_charset_to_unicode(utf8_charset, utf8_input,</div><div style="font-size:12.8px"> utf8_len, unicode_str.get());</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">std::unique_ptr<FriBidiCharType[]> bidi_types(new FriBidiCharType[len_unicode]);</div><div style="font-size:12.8px">std::unique_ptr<FriBidiLevel[]> levels(new FriBidiLevel[len_unicode]);</div><div style="font-size:12.8px">FriBidiParType base = FRIBIDI_PAR_ON;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">fribidi_get_bidi_types(unicode_str.get(), len_unicode, bidi_types.get());</div><div style="font-size:12.8px">fribidi_get_par_embedding_levels(bidi_types.get(), len_unicode, &base, levels.get());</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">fribidi_reorder_line(0, bidi_types.get(), len_unicode, 0, base,</div><div style="font-size:12.8px"> levels.get(), unicode_str.get(), NULL);</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">std::cout << std::hex;</div><div style="font-size:12.8px">for (int i = 0; i < len_unicode; ++i)</div><div style="font-size:12.8px"> {</div><div style="font-size:12.8px"> std::cout << "\\u" << unicode_str[i];</div><div style="font-size:12.8px"> }</div><div style="font-size:12.8px">std::cout << std::endl;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Output:</div><div style="font-size:12.8px">\u1f3fb\u1f476\u20\u631\u627\u628\u62a\u62e\u627</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">As you can see the tone modifier U+1f3fb is first and then the emoji U+1f476 is next.</div><div style="font-size:12.8px">I've also tested this with log2vis().</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Is this a bug? If not, what is the correct way to handle emojis?</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Regards,</div><div style="font-size:12.8px">Romain Ouabdelkader.</div></div>
<br></div></div>_______________________________________________<br>
fribidi mailing list<br>
<a href="mailto:fribidi@lists.freedesktop.org" target="_blank">fribidi@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/fribidi" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/fribidi</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div>