In this post I will show how one can edit bitmap fonts in pcf or bdf
format under GNU/Linux. The reason for writing this article was a wish
on mine part to edit the X11 core fonts in order to add a dotted or
I use urxvt with stock settings (except color) as terminal emulator.
If not defined to otherwise in the configfile urxvt uses the default fonts of
the X windowing system. The X default fonts are in fact a complete
collection of fonts which are called misc-fixed. They are available
in different sizes whereas urxvt uses 6×13 as a default.
The misc-fixed fonts are bitmap fonts.
This means that every character is defined pixel for pixel.
This leads to a few advantages over truetype or freetype fonts which are
constructed out of splines:
- Faster to display: There is no need to convert the character to
actual pixels before displaying it.
- Pixel-perfect: As bitmap fonts are already stored in pixels they can
be displayed exactly as defined beforehand. There is no need of
anti-aliasing, the font is sharp as hell. This is the main reason why I
use bitmap fonts.
The pixel perfection is the biggest downside of bitmap fonts at the same
time. As soon as a bitmap font should be scaled in any way, they start to
Dotted / slashed zero
A dotted or slashed zero is a typographic term and means, that the
number zero is crossed or has a small dot inside. This makes the zero
far more distinguishable from the capital letter O. There’s a nice
article on Wikipedia on that topic.
Unfortunately the misc-fixed fonts don’t have a dotted zero.
But this is going to change…
Three tools are needed. It’s very likely that you must install the
- pcf2bdf: This tool is used to convert the bitmap font from the
binary pcf format into the ASCII-based bdf format (bitmap distribution
format). On a modern Linux the bitmap fonts are stored in pcf
format and additionally compressed with gzip. On archlinux this is only
available in AUR: pcf2bdf.
- gbdfed: The graphical bdf editor is used to edit bitmap fonts. On
archlinux gbdfed is available only an AUR as well: gbdfed.
The official site: gbdfed official site.
- bdftopcf: This tool is used to convert the edited bdf file back
into pcf format. It’s shipped with X, so theres a high possibility
that you don’t have to install it.
Editing the pcf font files
On most systems the font files will lay under
You can list all installed fonts with it corresponding name and path with the
The next step is to copy the font file you want to edit and unzip it:
$ cp /usr/share/fonts/misc/6x13-ISO8859-1.pcf.gz /tmp/
$ cd /tmp/
$ gunzip 6x13-ISO8859-1.pcf.gz
After that we can convert the pcf file into bdf format:
$ pcf2bdf -o 6x13-ISO8859-1.bdf 6x13-ISO8859-1.pcf
Now we can edit the font with gbdfed:
$ gbdfed 6x13-ISO8859-1.bdf
After that we convert the bdf file back into pcf format:
$ bdftopcf -o 6x13-ISO8859-1.pcf 6x13-ISO8859-1.bdf
Compress it and copy it back. Make sure to have a backup of your
$ gzip 6x13-ISO8859-1.pcf
# cp 6x13-ISO8859-1.pcf.gz /usr/share/fonts/misc/
Afterwards we force a rebuild of the fontcache:
$ fc-cache -f
You might have to restart the X server as well.
And we’re finished:
If you don’t want to overwrite your original font file you have to
rename the font inside of gbdfed, copy the modified font to
~/.fonts and run
fc-cache -f ~/.fonts. After that you have to
specify the font inside of urxvts configfile / .Xresources: