0

I'd like to ask for help with win32 native TextOutW function when it comes down to displaying characters with right-to-left text direction. Basically, I want TextOutW to display text with characters as is, without applying any transformations,shaping,etc to the text.

What I have, is basically a simple code [1] like this:

WCHAR text[2] = { 0x5D3, 0x5E9 };
TextOutW(hdc, 100, 100, ( LPCWSTR ) text, 2);

that I used because I want to draw two characters together, left to right, first 0x5D3 (ד) and then 0x5E9 (ש) . What I get is the opposite - first the 0x5E9 is drawn and then 0x5D3:

דש

Sure, I can think of many workarounds how to override this, the simplest being just adding 0x202D [2] character in front of the text. But that seems hacky and generally wrong, and also wouldn't help me with for example arabic text that will have letters joined automatically (and will require even uglier workarounds).

Is there any information about this Windows behavior? How could I turn that off inside a program? Is this something related to Uniscribe? (I never used it and don't intend to).

Thank you!

[1] ( The full code is here http://karasik.eu.org/misc/rtl.c ).

[2] U+202D (LRO) LEFT-TO-RIGHT OVERRIDE: Forces the following characters to be treated as strong left-to-right characters.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536

1 Answers1

0

Look at the ExtTextOut() function, especially the ETO_GLYPH_INDEX flag.

Note that this behavior is not specific to Windows (but Windows implementation of Unicode layout is slightly different from other platforms). You cannot magically "turn it off" for your program, e.g. by choosing some special Locale.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307