How to render nice-looking typefaces in games?

Started by
12 comments, last by SilentSalamander 20 years, 1 month ago
Hello We''re just about finished with our game, and we''re pretty happy with it so far (in fact, you can download a beta at http://www.gamesresearch.com/hikari), and we''ll be releasing it soon. However, the typefaces could use some improvement. The situation is, we''re plotting a textured quad onto the screen for each letter. We''re doing this so that we can have more dramatic-looking typeface letters (e.g. gradiated, embossed etc.). The problem is that non-fixed-width typefaces render on the screen really poorly. Take lowercase i, followed by a lowercase j, for example. For a non-fixed-width typeface, the "correct" rendering of ij is to have the bottom of the j underhang directly beneath the i. Instead, there is a big gap between the i and the j, because the font renderer naturally starts rendering the textured quad for j past the end of the i. I''ve thought about some solutions, but what I''m really looking for is a robust, time-proven way of handling this, without using, for example, built-in typeface classes. Can I hear what people have to say about this? Is there a good resource out there that treats this topic rigorously? Thanks, -ss-
John Allen Umbaughsilentsalamander@gamesresearch.comwww.gamesresearch.com
Advertisement
D3DXFont
Yes, I hear it''s much better in DirectX 9.0, but there are a couple of problems:

1) In the future, I want to target different platforms on which DirectX is not available.
2) More to the point, D3DXFont doesn''t support things like shading, animation, independent translation out of the box.

So you can see that, probably, D3DXFont is not the best tool for me to use. Nevertheless, thank you for your informative answer!
John Allen Umbaughsilentsalamander@gamesresearch.comwww.gamesresearch.com
is the problem with vertical or horizontal allignement?

if its horizontal, are you assuming that each character is the same width for rendering?

and if so, there must be some way to determine what the width of each individual character is, and then start drawing the next character offset by the width of the previous character.
Stupid thing erased my message, so for the second time.

If you are using a standard windows font, then windows has some API commands that get the dimensions of the characters, use this to set the offset from one char to the next.

Or if you make your own fonts create your font class to contain this information so you know where to offset the next char based on a char by char width

There are free programs that will create a bitmap from TrueType fonts and many of them will save extra information about each character, such as horizontal/vertical alignment, in a separate file that you can read in to your program. One program is located here and I think was written by a GDnet member (can''t remember who!). There are quite a few others out there as well.
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
Then subclass D3DXFont... you can use your own bitmap for the letters.

Platforms that don''t support DirectX are irrelevent.

quote:Original post by SilentSalamander
Yes, I hear it''s much better in DirectX 9.0, but there are a couple of problems:

1) In the future, I want to target different platforms on which DirectX is not available.
2) More to the point, D3DXFont doesn''t support things like shading, animation, independent translation out of the box.

So you can see that, probably, D3DXFont is not the best tool for me to use. Nevertheless, thank you for your informative answer!


SelethD solution is pretty much the best you can do right now. Or maybe somebody else have done it, so try google won''t hurt.
Wow, some good information out there. Thanks!

Platforms that don''t support DirectX are irrelevent.

Haha, I''ll keep that in mind!
John Allen Umbaughsilentsalamander@gamesresearch.comwww.gamesresearch.com
In the DX9 SDK there''s a text demo which dynamically loads a true type font and makes it''s corresponding quad set. It uses a list of positions for each letter so non-squared type faces are rendered properly, you can use that code as a base and use negative start offsets for letters that should "overlap" with the previous one.

The code is not DirectX specific, I easily ported it to an OpenGL based renderer.

This topic is closed to new replies.

Advertisement