Sign in to follow this  
Decept

Automatic font selection

Recommended Posts

I'm in the process of making my engine able to render text (with DX8) with any font found in Windows. If I for example want to render a Chinese character I can load "Microsoft YaHei" font which contains Chinese characters. While experimenting I hardcoded some strings in VC2005 for rendering with the engine. I noticed that I could also enter characters from any language into the source code. That is a little strange, because VC2005 uses "Courier New" font, which does not contain for example, Chinese characters. It must somehow find a different font to print out the text. Notepad does the same thing and I suspect most other applications do this aswell. How do they do that? Is this built into Windows and if so, can I access it?

Share this post


Link to post
Share on other sites
I imagine that the OS handles it by default. But at a programming level, you could set several fonts for different code ranges. E.g. Characters 0x0000-0x00BF (ASCII) = "Courier New", 0x0F00-0x0FFF = "Microsoft YaHei" What you want to use is Unicode, since it's capable of displaying more than one codepage at a time.

Here are some good Unicode resources:
Unicode FAQ
Quick Unicode question
Standard UTF-8 decoder

Share this post


Link to post
Share on other sites
That's exactly what I do now. I have a list of fonts and a list of unicode ranges for each one. I then search through the list when I need a character.
Later on I saw the behaviour I mentioned in other apps and I thought that maybe I could do that too somehow.

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