A while ago I wrote a MonoFont class for Woopsi that was more space-efficient than the usual Font class. Working on the assumption that most fonts would be monochrome, I decided it would be more efficient to store the font as bit-packed data, with a 0 indicating a transparent pixel and a 1 indicating a filled pixel. This way, 16 pixels could be packed into a single unsigned short. Comparing it with the usual method of using an entire unsigned short to store just one pixel, the space saving is obvious - 16 times more data can be squeezed into a bit-packed monochrome font file.
Great in theory, but I didn’t have a way of producing bit-packed fonts. Bah.
I’ve addressed this problem by quickly bodging together a C# program that will take the bitmap data in the .c file created by PAGfx and compress it into a bit-packed .c file compatible with the MonoFont class. All you need to do is take the output file, drop it into your sourcecode in place of the original file, make sure you update the .h file with the new array size, swap from Font to MonoFont, and you’re away.
I’ve used the app to replace the TinyFont file with a bit-packed version. It’s gone from being a 6K file down to less than half a kilobyte. Not a great saving overall, but relatively speaking it’s a huge decrease in size.
The new app’s source is in the SVN repository (Visual Studio 2005/C# project). A binary release and source archive are below:
Note that you’ll need the .NET2 runtime to make the app work. Also note that it’s a command line app. Use the “/?” switch to see the help text, or just read the readme file.
Other less interesting changes to Woopsi include miscellaneous minor bugfixes and a lot of new javadoc comments.