Sign in to follow this  
blairhartley

Unable to display right-to-left reading text correctly

Recommended Posts

Anybody any experience using the DX utility text helper to display right-to-left reading text (in my case, Arabic)? I'm getting a wierd problem with the ordering of letters... For example... imagine the following is a string of two words of Arabic text, displayed as they should be... FED CBA They are actually stored in the string in the order... ABC DEF I'm using the CDXUTTextHelper with the DT_RTLREADING flag set, using an Arabic font. What I get displayed is the following... DEF ABC i.e. the words are displaying right to left (as they should) but the letters within the words are reversed. Many thanks in advance, Tim

Share this post


Link to post
Share on other sites
Quote:
Original post by streamer
Why just not reverse the string? Make function that will reverse chars in string and then just draw string normally without flag...


I did try that - but the Arabic characters are interpreted differently by the text drawing routine when they are in a different order. In other words, particular combinations of characters are replaced by other characters. MS Word does the same thing, so I assume it's normal.

Also, there must be something I'm doing wrong here - properly displaying text right to left doesn't seem like too much to ask :)

Share this post


Link to post
Share on other sites
I'm never developed for arabic market, so I don't know for sure, but if MS Word do something is probably due to program routine. I don't think that Windows is changing some character sequence by itself.
Probably you need to replace manually characters and then draw in right order.

Share this post


Link to post
Share on other sites
To be honest, I've always been a little suspicious of the D3DX text drawing routines. They've improved immensely over the years in both capabilities and performance, but the occasional odd thing like this combined with a relatively undocumented blackbox (I assume CDXUTTextHelper maps to ID3DXFont?) implementation isn't reassuring.

Have you dug into the IME control in the DXUT GUI? ISTR that's claimed as being a compliant international-capable input control. Should also have some code for handling output into the rendered textbox as well.

If you can't crack it you could always fall back to pure Win32/GDI text rendering to a texture. It's a bit of a bugger, but if you're doing much text rendering then it can actually be a lot more efficient than D3DX. The F1 Management game I worked on saw its biggest performance improvements by going to a bespoke text renderer.

hth
Jack

Share this post


Link to post
Share on other sites
The Directx text drawing routines actually can render arabic text correctly, however, the problem is with the edit control which seems to behave wrongly when entering arabic text. If you run the CustomUI sample, you will notice that the arabic text you enter in the IME edit control doesn't display correctly in the edit control itself, but is displayed just fine above in the static control (so rendering to a texture using GDI won't solve a thing).

However, the regular edit control (not the IME one) displays arabic characters correctly, except the text you enter will be left-justified. So, your best bet is to alter the code for the DX edit control to draw text starting at the right of its client area, but this won't be very simple... the edit control is a bit complex. Good luck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this