A command-line tool to end my bitmap font generation needs for-friggin-ever. I hope. :)
-h, --help | This help |
-dpi # | DPI for font rendering (72 is default) |
-bpp # | Bpp of bitmap files (8, 24, 32, default is 8) |
-bold [#] | Generate a bold font (# is factor, default 20) |
-italic [#] | Generate an italics font (# is factor, default 20) |
-chars "chars" | Add specified chars to charset |
-max # | Maximum texture size (power of 2, default is 1024) |
-noASCII | Do not include the 32-127 chars by default |
-cp "codepage" | Codepage for translating 8-bit characters |
FontCreator C:\Windows\Fonts\ARIALUNI.TTF 80 "My Fonts\ArialNumsIt" -max 512 -noASCII -chars "0123456789" -italic -bold 30That will generate files:
I use the Freetype library for font rendering, it might support formats other than TTF but I haven't tried them.
Use double quotes around parameters that contain spaces. Especially important for filenames.
For font sizes and DPI settings, I have followed Photoshop's conventions.
Bold and italics are "fake" deformations of the character bitmap; for the real effects you need separate source font files. The optional parameter supplied to -italic and -bold are a percentage of the total character width, and can be negative to invert the effect. A bold parameter of -100 can't be used.
Charset files are regular text files, either classic 8-bit characters or 16-bit Unicode (UCS-2 Big Endian or Little Endian). You can add as many text files as you want. Use -noASCII if you only want characters you supply directly (via -chars or via charset files). FontCreator will not duplicate characters in the resulting font regardless where they come from.
Codepages are... well, it's a long and confusing topic. Ignore it and it will use the system defaults. Use -cp "C" to avoid any translation. In Windows, you can use -cp ".1252" (notice the leading dot) for the Latin-1 codepage, -cp ".1255" for Hebrew, etc. You can find a list of Windows codepages at http://www.microsoft.com/typography/unicode/cscp.htm or http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_81rn.asp, and more info in general at http://en.wikipedia.org/wiki/Codepage. I have no idea how this works in other operating systems. Codepage settings are active at the point where they are specified, so if you have an 8-bit charset file called "file1.txt" and write:
FontCreator ... -cp ".437" file1.txt -cp ".850" file1.txt
then the charset file will be read twice, and interpreted differently each time. If you have any trouble, don't use -cp and supply Unicode charset files instead.
The TFN file is a plain text file where you can find the the list of texture files and the parameters for each character in the font.
Unicode advance offsetX offsetY TextureIndex TextureU TextureV Width Height
The Unicode is hexadecimal (for example, 0x0020 would be the space ' '). Everything else should be pretty much self-explanatory. To draw a character, draw the rectangle (TextureU, TextureV, Width, Height) from the TextureIndex texture, at the position (X + offsetX, Y + offsetY), then add "advance" to X, repeat this for each character in your string. When going to the next line, just add the font's "height" to Y.
The TFN file is deliberately minimalistic in structure. It is designed like that to minimize loading complexity. It contains the texture dimensions as a helper in case you later postprocess the TGAs and change their size - you need the original dimensions in order to interpret the TextureU and TextureV of the characters.
The TGA files are saved as follows: