As mentioned in a previous post, there is a clear need for a bitmap font generator that provides proper Unicode support.
To address this need, I created BMFontGen.exe. This program can generate a bitmap font from any of the fonts currently installed on your system and it provides a variety of options for controlling which glyphs get placed in the font and how they appear. More details about the tool (including a download link) are given in this document, but for our purposes it suffices to know that BMFontGen takes a font name and a font size and produces an XML file (containing the font description) and a collection of PNG files (that contain the glyph bitmaps).
To use these fonts in an XNA game, you need some code that can load these files and let you draw a string of text on the screen. To fill this role, I created the BitmapFont class. This class handles the font loading and exposes a set of DrawString methods that do what you would expect them to do.
To demonstrate the class in action, I’ve created a simple demo app (attached to this post – see link at bottom) which I’ve cleverly named “BitmapFontDemo”. Here is a screenshot from the app that shows off some of the capabilities of the font renderer.
The BitmapFont class is intended to provide basic text rendering services only, so don’t expect it to handle linebreaks or format text in a rectangle or provide any other advanced text options. However, I’ll be adding functionality to it as time goes on, and I also intend to release other game support classes that build upon the base functionality provided by BitmapFont.
This is the first release for this tool, so let me know if you find this useful or if you think there’re features missing. I’m curious to see games that make use of these fonts (even if I can’t read them ^_^).