Jump to content
  • Advertisement
Sign in to follow this  

Fast Bitmap fonts...

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

Do you want to use a font which is stored in a bitmap or do you want to use the windows bitmap fonts (the .fon) files ?

Sicne the later is odd, I will assume that you want to use a font which is stored in a bitmap. You'll have to

1) create the bitmap - this will be your font texture (you may create an alpha map too)
2) create all the texture coords which are associated with a letter or sign

The bitmap creation is simple. The letters should be on the same line but they must be at the center of each box. The algorithm is :

for each letter
letter_rect is associated to this letter
fixed_y is the y position of the letter line
GetTextExtentPoint32(letter, size);
end for

Of course, there may be more than one letter line (and therefore more than one fixed_y). But fixed_y should allways be letter_rect.top + fixed_offset.

The texture coords are computed from the different letter_rect.

To use the bitmap font, simply

bind font texture
populate the vertex stream and the index buffer
send them to the GPU

Hope I answer your question :) If not, please feel free to explain what you'd like to know.

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.

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!