Font issues

Started by
3 comments, last by Rattenhirn 15 years, 1 month ago
Hi, I'm getting in a bit of a state working out how fonts work for games. Assume a game is cross-platform and multi-lingual, I clearly don't go creating my own font of thousands of characters, so how does this work? Do I specify what font to use on each OS for each language and hope it exists - if it doesn't what would be the next step? Also, it seems the best way is to use a truetype font and then create a bitmap of it, but how does that get around the problem of something like an m taking up as much room as a comma, it would look a little silly...
Advertisement
You generally license a truetype font and generate a bitmap font with the glyphs you need. If the game makes advanced use of fonts, then the ttf can also be rendered on the fly.

You can and should not rely that a font available on the users computer. It's not guaranteed that it will be there and be what you expect it to be and there are possible licensing issues to consider as well.

As for your problem with the m and the comma: it is not a problem, unless you want each of your glyphs to have the same width. For even prettier font rendering, look up the term "kerning".
So, I'm guessing that more often than not a game actually uses a number of fonts (or just one big one), one for each particular language - Latin, and perhaps another 3 for CJK? I'm also trying to work out exactly what something like the FreeType library actually does and what it's purpose is?

Thank you.
Freetype can read all sorts of font formats and render them.

I used Freetype previously to render glyphs from a truetype font to pixel buffers for dynamically building a bitmap at whatever resolution I needed.
What''s a cleaver?
Quote:Original post by NewBreed
So, I'm guessing that more often than not a game actually uses a number of fonts (or just one big one), one for each particular language - Latin, and perhaps another 3 for CJK?


That really depends on the situation. If you use prerendered glyphs ("bitmap fonts"), what you describe is a sensible approach. You can further optimise by preprocessing all your texts that end up on the screen to find out, which glyphs you actually need.

An alternative is to use libraries like freetype to render glyphs on the fly. This is more complicated and probably slower, but also a lot more flexible. Beware that many aspects of font rendering are covered by patents! The freetype docu has a lot of info on this.

This topic is closed to new replies.

Advertisement