-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getReorderedString of mixed RTL, LTR and Emoji text sometimes differs from browser bidi behavior #9
Comments
I did some research (at least tried to) and got some interesting info: What I wanted to do was add some new tests to I thought it's going to be easy - just grab some short strings with Emojis, run a known-to-work bidi implementation on them (I used Fribidi CLI), get the embedding levels, the visual order, and extend the tests with 4-5 simple cases. But, as nothing is easy with bidi stuff, I stumbled:
Fribidi CLI output format:
Here are the fribidi results with the text "Cא👱🏽♂️" :
So, what should the visual order be? 2 3 4 5 6 0 1 ? for the LTR case bidi-js returns the same levels as Fribidi, but for the RTL case it returns 2 1 2 2 2 2 1 1 1 That's my 2 cents research anyway |
Thanks Tom for the helpful analysis! I believe there are two issues at play:
While this refers specifically to combining marks (e.g. zero width joiner This un-flipping would be done as a special case in |
When passing a mixed RTL, LTR and Emoji string to
getReorderedString
, if the sentence is processed asrtl
, and the emoji is right after an LTR block it seems like it will be considered as a part of the LTR block, while the browser seems to considers it as a new RTL block (I'm not sure I'm 100% familiar with the implementation to use the right terms here):if the original string is
RRR LLL N
(where N is the Emoji)The browser will Render it (in a
"direction: rtl"
block) asN LLL RRR
but bidi.js will return
LLL N RRR
if the original string is
RRR LLL R N
both the browser and bidi.js will render it as
N R LLL RRR
a codepen demo:
https://codepen.io/tombigel/pen/gOJYQom
Is it expected?
The text was updated successfully, but these errors were encountered: