Jump to content
  • Advertisement
Sign in to follow this  
InetRoadkill

rasterizer for TTF fonts?

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

What's the proper method for getting rasterized versions of a TTF so that I can load them as textures into the 3D engine (windows VC7 platform)?

Share this post


Link to post
Share on other sites
Advertisement
If you wanted an easier route, the windows GDI can render these kinds of fonts given they are installed on the system. You can bypass the need to install them on the system AddFontMemResourceEx() which will install a font temp. and only for your application process. Then you can use CreateFont() to create a font object, and GetCharABCWidthsFloat() to get the metrics you need, and final use the GDI to draw the font to a bitmap which you can use as a texture.

The advantage to this is that you end up with a smaller application, as the last time I checked freetype was pretty big. Using freetype is actually probably easier though if you are unfamiliar with windows GDI. So its a toss up.

Share this post


Link to post
Share on other sites
What I've been doing is something like the following:

1) Using Freetype create a small program that rasterizes the .ttf to a texture and exports the texture (To a .png for example).

2) Then my actual game or whatever I'm making can just load the texture. It doesn't have to be built with Freetype (larger size) or use the Windows GDI (non-portable).

As another plus, I believe this method results in a faster end-program (as the rasterization is done prior to execution). I like to have an entire font in one texture, and to do this you'll need to learn a little about Texture Atlases. Try searching about them and if you still need some help I can tell you more.

If you're developing on Windows, there's a free program you can download that will create these textures for you called BMFont. I preferred to create my own as I could set things up just as I wanted (and I develop on Linux).

The downside to this font method is that you must choose your rasterized font size beforehand. You can make multiple textures for multiple sizes of a font, but that will of course take up more space.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!