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 0x80 – 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 0x20 – 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).
7 thoughts on “Bitmap font creator”
I spend some time to make the script work with Blender 2.48a : It seems to work only with PNG files at saving time. You can find the patch here :
Well sorry cause you recommanded to use PNG in this blog post, so I’m a bit confused, anyway, I couldn’t make it work with standard ASCII franch chars because of a Blender Bug you were correcting by doing this :
#if code >= 0x80: code = code | 0xFF00
I commented it and it work at the end so I guess Blender’s bug was fixed in the recent versions…
See my previous comment for the patched script.
I also forgot to thank you ashsid, for your nice job.
This is a good tool, thanks.
I am working on a script that can read the txt file that I exported from a Google docs sheet. So I want to make a good tool to read multiple language sheets and use in Blender. This can be use in games to make language version of the text messages.
1] Loved it
2] Found it more useful as a standalone module (especially with blender 2.5x), so I took out everything after line 212
3] Large resolution chars are clipped, so I increased the image size on line 121 to 1024
4] Great Program!!!!!!
5] Wish I had more time to modify it 🙂
… make that 8192, not 1024 🙂
hmm.. any ideas why these changes would flip the periods (upside down in relation to other text)?
Hi, I’m very excited to use this for my font, but I get an error in blender 2.56.6 r36037.
File “/blendFont.py”, line 39
self.chars = [[”, u’@’]]
SyntaxError: invalid syntax