Compile a BDF X Font into PCF with bdftopcf

An X server cannot read a BDF font directly, so bdftopcf compiles that source into a Portable Compiled Format file it can load. The examples use bdftopcf 1.1 from the Debian package xfonts-utils version 1:7.7+6build3. Allow about ten minutes if the BDF file is ready and you only need a standard conversion.

1. Check the installed compiler

$ command -v bdftopcf
/usr/bin/bdftopcf
$ bdftopcf -v
bdftopcf 1.1

The installed manual describes this as a font compiler for the X server and font server. PCF files are portable between architectures, although a file can be read more quickly when its layout suits the host. The version check matters when a build script or an old font archive has to be reproduced later.

Checkpoint: if the command is missing, stop here and install the distribution package that provides bdftopcf through your normal package-management process. Do not download a random executable into a font directory.

2. Convert one BDF file without changing the source

$ bdftopcf -o ./output-font.pcf ./fontfile.bdf
$ printf 'status=%s\n' "$?"
status=0
$ ls -l ./output-font.pcf

Checkpoint: use file ./output-font.pcf or the font inspection tool available on your system for a second check. A successful exit status means the compiler completed; it does not prove the glyph design is what you intended, so keep the BDF until the PCF has been tested by the consumer.

3. Avoid accidental truncation

$ bdftopcf -o ./output-font.pcf.new ./fontfile.bdf
$ test -s ./output-font.pcf.new
$ mv ./output-font.pcf.new ./output-font.pcf

-o names an output file, but it is still safer to use a fresh temporary name when replacing an existing PCF. This protects the old file if the conversion fails or you decide the result is wrong. Run the mv only after the conversion and the non-empty-file check succeed; if conversion fails, inspect the diagnostic and leave the old PCF alone. To recover an unwanted replacement before another process uses it, restore your own backup or regenerate the known-good PCF from the original BDF. The mv example changes state in the current directory, so review both names before running it.

If you deliberately want standard output instead, use an explicit new file:

$ bdftopcf ./fontfile.bdf > ./output-font.pcf
$ printf 'status=%s\n' "$?"
status=0

Warning: shell redirection opens the destination before the program runs. Never use this form with the only copy of a useful PCF unless you have a backup. The -o workflow with a .new name makes the replacement boundary easier to see.

4. Select glyph padding when a consumer needs it

$ bdftopcf -p 4 -o ./output-font-p4.pcf ./fontfile.bdf

Only add these options when the target X implementation or an existing reproducible build requires them. If the option value is outside the documented set, the installed compiler rejects it; correcting an invalid value is safer than trying several combinations against a production font directory.

5. Set bit and byte order only for a known target

The default conversion does not require you to choose an order manually. The explicit switches are:

These are different choices: bit order controls the position of bits within each unit, while byte order controls multi-byte values such as metrics and bitmap data. Do not add all four flags to make a conversion seem more portable. Select the documented combination for the X server or font tooling that will consume the PCF, and keep that choice in the build command so it can be reproduced.

6. Use terminal optimisation with a clear reason

$ bdftopcf -t -o ./terminal-font.pcf ./fontfile.bdf

These flags can change spacing or the way glyph extents are understood by software. Test the resulting font with the actual application. If you only need a normal PCF, omit both options.

7. Diagnose a failed conversion

$ ls -l ./fontfile.bdf
$ test -r ./fontfile.bdf && echo readable
$ test -w . && echo destination-writable

Check the input path and permissions first, without changing the font archive. If the compiler reports it cannot open the BDF source, correct the path or read permission. If it cannot create the PCF, choose a writable destination or fix the destination permission according to your system policy. Running the whole conversion as root can hide an ownership problem and can leave root-owned output behind, so it should not be the first remedy.

For an option error, compare the command with the local manual. The documented values are narrow: -p accepts 1, 2, 4 or 8, and -u accepts 1, 2 or 4. The compiler has no documented input-directory mode, font installation mode or automatic overwrite safeguard. Keep conversion and installation as separate, reviewable operations.

Done means