Using bitmap fonts

Bitmap fonts work better when we need to render very small text between 7 and 9 pixels height. Is there any way to create a bitmap font and have it loading as if it was a normal panda font?

You can use any bitmap font you like; Panda uses FreeType as its font-rendering library, and FreeType supports bitmap fonts as well as TrueType fonts.

See this thread for a discussion on rendering your fonts pixel-accurately.


Yes i made that thread. :smiley: But i didn’t ask the question properly. I wanted to ask about creating a bitmap image and drawing letters by hand with a paint program. Then build a panda font from it. The font i want is a tweaked bitmap image from an old game i want to use for nostalgy reasons.

Oh, sorry.

Yes, there are lots of ways to use a plain bitmap as a font. Basically, you want to create an egg file, with a polygon for each letter. Each polygon should be in a group named for the ASCII (or Unicode) numeric value for the letter. You should also place a in the same group to represent the width of the letter: the X coordinate of this point represents the space between this letter and the next when it is laid out on a line; note that the width of the polygon itself means nothing (since sometimes letters should overlap a bit).

See the font egg files in the models directory–cmr12.egg, cmtt12.egg, cmss12.egg–for examples.

If you already have a bitmap image that contains the letters of your font laid out in a grid, it should be fairly easy to write a simple Python program that will generate an egg file to reference this font.


Thanks for the hint.