Bitmap font creator
Tuesday , 17, February 2009
I came to serious troubles last autumn when I wanted to create some bitmap fonts for GameBlender. Application ftblender wasn’t able to build them correctly, fonts had overlapping characters and resolution wasn’t satisfying, too.
When I found out that Python Image Library (PIL) is able to render characters to images, I started to work on alternative way of bitmap font creation. Bitmap Font Creator is result of this work. It performs bitmap font generation from TrueType Font file and allows to configure Blender mesh object to use this created font automatically.
Installation and usage
Copy file blendFont.py to Blender scripts folder and script will appear in Image scripts menu. Tool requires PIL to be installed.
Description of fields:
- Font File – name of result bitmap font file (it requires to have file extension, I recommend to use .png)
- Font size – size of font characters
- Font Folder – folder, where bitmap font file will be saved
- TTF File – source True Type Font file
- Map File – defines characters for upper half of 8-bit ASCII code (codes 0×80 – 0xFF). Format of map file: first character on each line defines code in bitmap font, rest of line contains hex code of unicode character, that will be used. In tool package is included file cp1250.txt, that contains definitions for Central Europian characters used in Slovakia and Czech republic. If no map file is used, bitmap font will contain only basic ASCII characters (range 0×20 – 0x7F).
- Width – width of resulting bitmap font image. Height will be calculated automatically.
- Padding – add additional pixels on each side of every font character.
- Use basic characters – includes basic ASCII character set in font – can be switched off for languages that don’t use basic ASCII charactes (Japan, Chinese, Arabian…).
- Setup selected object – this toggle will check, if selected object is mesh and contains exactly one quad. If yes, then tool will set generated bitmap font as texture to selected object and will update object’s UV coordinates, texture mode and add Text property. After that is selected object prepared to be used in game.
- Base Char and Delimiter are “hardcore” parameters for bitmap font generation, there will be no need to change their default values for most fonts.
Bitmap font is generated after all fields are set up and button Create Bitmap Font is pressed. Then the font image is loaded to Blender and selected object is set up to use this font (if its toggle is enabled).