• 13
• 15
• 19
• 27
• 9

# Fast Bitmap fonts...

This topic is 4957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

any ideas on how to make fast bitmap fonts (gdi, preferably)?

##### Share on other sites
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);   TextOut(letter_rect.width-size.cx)/2,fixed_y,letter)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 texturepopulate the vertex stream and the index buffersend them to the GPUrender

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