bdf2fnt X11/BDF Font Converter

download bdf2fnt
v2013.07.26

sample fonts
v2013.07.26
[CLICK HERE] for screenshot



Introduction
The Maximite is a small PIC32 single board computer (SBC) that usually runs a BASIC interpreter called mmbasic. The SBC plugs directly into a VGA monitor and has the ability to display alphanumeric characters in various sizes using the builit-in fonts.

mmbasic allows the use of user-defined loadable fonts

What are Fonts?
For the purpose of discussion, we will define a Font as a file containing a description of how to display glyphs on your device. The glyphs could be letters, numbers, or other symbols depending on the purpose of the font.

There is a HUGE selection of fonts available on the Internet covering all sorts of styles and sizes. A problem with fonts is no single standard exists on how a font file should define the glyphs.

mmbasic has it's own font definition layout unlike any of the common Internet standards.

Using Fonts in mmbasic
Although we can download a font from the Internet, the file must be in a format that is usable by mmbasic. That is where bdf2fnt becomes useful.

BDF fonts are a common file format used by X11. We can use the bdf font if we first download & convert it into a format usable by mmbasic. bdf2fnt is a php script that will read a bdf font file and create 4 new files.

Why 4 files?

Many fonts have 256 (0-255) symbols defined. Due to design decisions of mmbasic, we can only load symbols with characters codes 32-127. This does not represent a problem though because we can break up the font into 3 smaller groups of characters and load each file at runtime. Note that in many cases, only the 1st file is actually needed for normal text.

Wait! You had said 4 files and now are saying 3 files; which is it 3 or 4??

To convert a bdf font, type the following Linux command: ./bdf2fnt fontname.bdf

4 files will be created

  1. fontname-symbols.txt -- Not usable by mmbasic. It is for humans to see ALL available symbols in a font
  2. fontname.fnt -- mmbasic loadable font containing symbols 32-126
  3. fontname-p2.fnt -- mmbasic loadable font containing symbols 160-254
  4. fontname-p3.fnt -- mmbasic loadable font containing symbols 1-32 & 128-159

What about other non-BDF fonts?
BDF fonts are not the only fonts out there. I use Ubuntu Linux and was able to convert TrueType and PCF fonts to BDF. Once converted, I used bdf2fnt to convert the newly created .bdf file to mmbasic compatible .fnt format.

In Ubuntu, I installed the pcf2bdf BDF converter: apt-get install pcf2bdf

In Ubuntu, I installed the otf2bdf TrueType converter: apt-get install otf2bdf




Copyright © 2013 by Mark Bramwell, London, Canada. All rights reserved.