Wrong -> arrow direction in RTL text contexts

I have joined the Unicode mailing list to propose an addition to Unicode that would be a solution in cases like this. One of the responses I got was this:

(Me:) The problem is this replacement is done (as far as I know) outside of any rendering context, when the text is just a sequence of character codes. It’s not reasonable to know which direction the text goes. Sometimes it’s completely impossible, if the text direction depends on context that isn’t available at the time of replacement.

The above is strictly speaking inaccurate. Any serious text rendering
nowadays requires a shaping engine, such as HarfBuzz, and ligation of
“->” into “→” would be done by such a shaper in cooperation with a
font that supports ligatures. The shaping engine is aware of the
bidi context and the script of the text it shapes, so it could in
principle mirror the arrow.

They are talking about something like this: GitHub - tonsky/FiraCode: Free monospaced font with programming ligatures

Consider switching to the ligature approach instead of blind character replacement. Another arguable advantage would be that when copy-pasted, the text would still be “->” instead of an arrow.

I haven’t looked into the technical details of how to implement this, I’ll leave that to you if you choose to use this solution.

Edit: well, unsurprisingly, Fira Text in particular isn’t designed with RTL in mind, so the rendering is off - but at least it’s pointing the right way! https://fonts.google.com/specimen/Fira+Code?preview.text=A%20->%20B,%20א%20->%20ב
Firefox:

I’m not sure if there exists a font today that does this correctly and explicitly supports RTL/bidi.

1 Like