Introduction
BDF is a plain text format for bitmap fonts, defined by Adobe and adopted by the X Window System as its standard way to distribute fonts. Each glyph is stored as a grid of pixels at one fixed size, so BDF fonts are sharp at that size and nothing else. They are still used for terminal and programming fonts on Linux, and for the small screens of embedded devices and microcontroller projects.
The X font compiler bdftopcf converts BDF to the binary PCF format (its manual page:
“a font compiler for the X server and font server”, with fast reading on the matching architecture).
Structure
A BDF file is plain text made of keyword lines. It starts with
STARTFONT 2.1 (or 2.2), then the
global section: the font name (usually an
X Logical Font Description name), point size and resolution, the bounding box of all
glyphs, and a block of properties
between STARTPROPERTIES and ENDPROPERTIES.
CHARS gives the number of glyphs. Each
glyph runs from STARTCHAR to
ENDCHAR and gives its code (ENCODING), its advance width
(SWIDTH and DWIDTH), its bounding box (BBX) and,
after BITMAP, one line of hexadecimal per pixel row. The file ends with
ENDFONT. Version 2.2 adds metrics for vertical writing.
STARTCHAR A
ENCODING 65
SWIDTH 500 0
DWIDTH 8 0
BBX 8 8 0 0
BITMAP
18
24
42
42
7E
42
42
00
ENDCHAR
Tape and tar distribution
Section 2 of Adobe Technical Note #5005 (version 2.2) describes how Adobe distributed BDF fonts, which is history rather than part of the file syntax. The bitmaps were typically sent on magnetic tape: 1600 BPI, nine track, unlabelled, with two or more files, each followed by an end-of-file mark and the last by two. Physical records hold 512 bytes, except that the last record of a file may hold fewer. Each file is encoded in the printable characters (octal 40 through 176) of US-ASCII plus carriage return and line feed; each line ends with carriage return (octal 015) and line feed (octal 012). The first file on a tape is Adobe’s copyright notice and the files after it are font files. Tapes could also be had in UNIX tar format, and no other tape format was supported. The X Consortium’s 2.1 text instead allows a line to end in CR LF or just LF. The validity rules and number types are on the Glyphs page.
These are ways of carrying the files, not part of what a BDF file is: a font taken off a tape or out of a tar archive is the text described on these pages, with CR LF or LF line ends (the viewer reads both). A tar archive is opened by the explorer’s tar plugin, which lists its files and opens each by its own type, so a BDF inside one is read as any other. The 512-byte tape records and end-of-file marks exist only on the tape itself and in no file the site can be given.
In the explorer
The XLFD matrices PIXEL_SIZE_MATRIX and POINT_SIZE_MATRIX are named on the
Header page as parts of an XLFD font name, not BDF properties.
The viewer (the bdf plugin) reads every keyword of versions 2.1 and
2.2, lists every property with its XLFD meaning, draws every glyph (512 to a sheet, linked to the bytes), checks
the metrics (BBX against the font box, DWIDTH against SWIDTH, the METRICSSET rules) and draws a line of sample
text, also in the vertical direction when the font has those metrics. It reports problems and reads on. The X
server’s own reader is followed line by line as well, and what it refuses or changes is listed in the Font tab
as warnings labelled “X server behaviour”, never as problems, because those rules are one program’s and the
specifications allow more (the fixed header order, the required property block, the 2.1 version only, the
glyph line order, the 16-bit limits, the bitmap row rules) and, for a constant-width font, the padding of every
glyph to one terminal cell that libXfont applies last (the cell is drawn as a frame on the glyph sheets). The Text tab
shows the file as text, and a problem or table row that names a line opens it there. On the real X.Org fonts (6x13, 7x13, 9x15, 10x20, 6x10, 8x13B,
12x13ja, 18x18ko and courB24) it reports no problem: a glyph name over 14 characters in a 2.1 file and ink in the
padding bits are notes there, because those fonts break the text of the specification and every X server loads them.
The rows of a glyph are built from the file when its node is opened, so a 6 MB font keeps about 15 times its size in memory.
Links
Software
- FontForge – free font editor that opens and saves BDF (Windows, macOS, Linux)
- Text editors – any text editor opens BDF, since the format is plain text
Developers
- FreeType – library that renders BDF fonts (C)
Reference
- Glyph Bitmap Distribution Format (BDF) Specification – Adobe Technical Note #5005, version 2.2, 22 March 1993 (PDF)
- Bitmap Distribution Format 2.1 – the X Consortium’s version of the specification, with the sample font
- X Logical Font Description Conventions – the font names and properties BDF fonts use