Jump to content
  • Advertisement
Sign in to follow this  
msamurai

How to render unicode text with ID3DXFont ?

This topic is 3691 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

Hello all I need to render unicode strings in my application, so I tried using ID3DXFont interface. In the reference: http://msdn.microsoft.com/en-us/library/bb173962(VS.85).aspx it says that it supports ANSI and unicode strings, but it doesn't say how to render unicode strings. So I guessed it meant that the second parameter of 'DrawText' (LPCTSTR pString) can be interpreted as either ANSI or UTF-8 (which is compatible with ANSI), and I call this function like this: // str is my text in UTF-8 (exactly as I loaded it from a UTF-8 text file font->DrawText(NULL, str, -1, &rect, DT_CENTER | DT_WORDBREAK , color); Which results in rendering the ANSI characters correctly, but the unicode ones as rubbish. screenshot: http://samurai.hobby-site.com/tmp/UTF8Screenshot.png Does anyone know how to do this correctly? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
To use Unicode strings with ID3DXFont you need two things: a Unicode font and the string encoded in wide character format, 16 bits per chararacter. UTF-8 doesn't work. Once you have those two, you can use the wide character version of the font rendering functions. If you don't define UNICODE for the project then you'll need to call the W versions of function calls directly.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!