Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SilentSalamander

How to render nice-looking typefaces in games?

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

Share this post


Link to post
Share on other sites
Advertisement
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • 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!