Some of the best programming fonts out there are monospaced, bitmap fonts. Because every character has the same width, they can become very small in size and still be legible, thus allowing the programmer to view a significant amount of code at once. Bitmap fonts in Windows are compiled in the binary FON format. In the *nix world, these fonts are usually in the PCF(Portable Compiled Format) format. So here is what i did to convert a FON to PCF and generate a cross-platform format in-between.
The first step involves converting the *.FON file to a Bitmap Display Format (BDF). BDF files are distributed in an ASCII encoded, human-readable form. This data represents the font for a single size and orientation. Thus if the *.FON file contains multiple fonts, multiple BDF files will be generated. The tool to perform this conversion comes as part of the Wine Windows Emulator for X. The program is called fnt2bdf, and while it's no longer built into the default install, it still can be found and compiled from the sources. Later on, we'll also rely on another tool from the folks at Wine called bdftopcf. So if you have the know-how, you can compile these programs separately, or build Wine as a complete package.
What's nice about BDF files is that they are relatively easy to edit since they are human-readable and cross-compatible. You can use a BDF editor such as the GNU Font Editor to tweak the font before you perform the final PCF conversion. Below is an image of the GNU Font Editor in action.
The *.FON file i wanted to convert is from Tristan's excellent set of programming fonts. In particular i love Proggy Clean and have been using it for quite some time. Note: You don't have to convert this file if you want to use it. It's already been done. I'm just using it as an example.
Basic usage for fnt2bdf is as follows:
Usage: fnt2bdf [-c charset] [-o basename] [input file]
where the -c option id the charset you wish to use. In order to convert ProggyClean.fon to BDF, i ran
fnt2bdf -c iso8859-1 ProggyClean.fon
You may find that a different charset works for your needs.
Now that the BDF file is created we can edit it or move right into the PCF conversion using bdftopcf. PCF files are binary files, but the format is portable across architectures.
usage: bdftopcf [-o pcf file] [bdf file]
where 'pcf file' is the name of the output file to write to. So i ran
bdftopcf ProggyClean.bdf -o ProggyClean.pcf
Now that i have the PCF file, the last thing i need to do is compress it
gzip ProggyClean.pcf
Installing The New Font
Copy your new compressed PCF font files to a directory that is visible to the x-server's Font Path. You may check the font path of the running server by typing the command
xset q
On my FreeBSD machine I chose /usr/X11R6/lib/X11/fonts/misc/ to hold these new fonts. If your on a linux box, your path will probably be /usr/lib/X11/fonts/misc/. Next, you need to update the font index file 'fonts.dir' by running mkfontdir. Here's the command I used inside my misc font directory
mkfontdir /usr/X11R6/lib/X11/fonts/misc/
If you don't want to restart your X server, you can update your
current X session using
xset fp rehash
Otherwise restarting X will also load the new fonts.
Troubleshooting:
If you've followed the above steps and still having problems, make sure that you are loading the 'bitmap' module via the 'XF86Config' file
Section "Module"
Load "bitmap"
[..]
EndSection
Resources:
Bitmap Display Format (BDF) Specs
Portable Compiled Format (PCF) Specs
FONT Format (FON) Specs
Setting the server's font path
