Jump to content
  • Advertisement
Sign in to follow this  
blairhartley

Unable to display right-to-left reading text correctly

This topic is 3918 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Why just not reverse the string? Make function that will reverse chars in string and then just draw string normally without flag...

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
Thanks Jack - that's useful. I was considering re-writing my text handlers using GDI to a texture - your comments have encouraged me to get on with it!

Share this post


Link to post
Share on other sites
i've used ID3DXFont with right to left text and the only problem I had was on a UK XP machine when the regional optional in the control panel did not have the 'support for right to left langauges' option ticked!

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!