Projects

Bitmap font editor tool

Last updated: Aug. 31, 2010, 10:35 p.m.

In a project I am currently working on I needed a font to embed in the ROM of an ARM Cortex micro-controller that could be used on one of these ChLCD modules from SparkFun. The display in my application is currently mounted in a landscape orientation, but I didn't want to preclude using it the other way around, or changing the font. I've written a few bitmap font editors over the years for various graphical LCDs, VGA displays and LED matrix displays. They all have a common interface, a character being edited with oversized pixels and a preview of the entire font. I decided this time to do a "proper job" of the code and write a Python GUI app that should be cross-platform and allows saving and loading of fonts.

Screen shot of bitmap font editing software

The basic application lets you create a font with up to 32x32 pixel characters and up to 65536 characters. You can select the fore ground and background colours although this only affects the UI at the moment. All of this can then be saved and loaded from a *.fnt file. (Note these aren't Microsoft .fnt files they are unique to this program as they contain a python object.) The actual generation of a suitable file for inclusion in your micro-controller project is done as a separate stage using the "Export" dialogue. Currently there is only the exporter for generating the font file for my ARM project, although this is vanilla C code with one byte per character line. To make an exporter for your project you simply need to copy the arm_c.py file from the exporters directory, read the comments and edit the function and exporter name fields to generate the output format you need. I might get around to writing another couple of exporters for controllers/devices I own but it really is a pretty simple function call.

Also worth noting, there is only one keyboard shortcut in the application; pressing space while editing a character will update the main font display and move on to the next character this is handy if you're skipping through a new font drawing out characters in order.

Get the program here:

http://nathandumont.com/files/fontedit.tar.gz

Note that there has been minimal testing. It worked well enough to create the font I wanted, there were several bugs (now fixed) discovered in the process so the development testing wasn't as good as I'd hoped. I suggest you keep a backup of your work and save early and make sure the file opens okay.

As ever my code is released as GPL, you will need a recent release of Python and PyGTK 2.6 or better, the code should be platform independent but has only been tested on Ubuntu 32 and 64 bit. Comments/suggestions/bugs will get to me most rapidly by email: nathan@nathandumont.com, make sure to put a sensible subject etc. as there's a vicious spam filter on that account.

Section:
Projects
Tags:
LCD,
Bitmap font,
embeded,
c

Comments

Thanks for your work!

11 Sep 2012 - 20:36 Michael

... exactly what I needed.

Posting comments is not currently possible. If you want to discuss this article you can reach me on twitter or via email.


Contact

Email: nathan@nathandumont.com

Twitter: @hairymnstr

Links