Archive for July, 2009

Font Generation Tool

Wednesday, July 29th, 2009

As I couldn’t find an existing tool which met my requirements, I’ve written by own utility to generate a bitmap font from a true-type font, which is quite useful for when you want to use a font in a game but don’t want to buy the full distribution rights to it…

It can be downloaded here (source code included):

And the syntax is:
PixieFGT fontname size [spacing] [-antialias] [-texture]

The optional parameter spacing gives you that many empty pixels around each character, so there’s room to add things like dropshadow or glow in your image editing software.

The optional flag -texture will give you the characters arranged on a bitmap of power-of-two size, and if the flag is not specified, they will be placed on one long horizontal strip instead (which is what I most often use for fonts in Pixie, as it makes it easier to apply gradients to the font in photoshop).

If you specify -antialias, the font will be generated at 16 times the requested size, and then downsampled, for high quality antialias.

Here’s an example of how a generated font bitmap might look:


And along with it you also get an XML file which specifies which character can be found in which area of the bitmap.

The XML file also contains kerning information, which you could make use of if you want. What it basically tells you is that if a character with the ascii value matching the "first"-value was rendered, followed immediately by one matching the "second"-value, the second character should be moved horizontally by the specified amount, so that, for example, "A" and "V" are placed closer together than "A" and "L"…

The source code is public domain as usual.