A BDF file holds one font: one typeface, at one size, in one orientation. It is plain text, so it has no offsets or binary fields; instead each line starts with an upper-case keyword followed by values separated by spaces. This page covers everything before the first glyph: the global keywords and the property block. The glyphs are on the Glyphs page.
Text rules
- Only printable ASCII (0x20 to 0x7E) is used, plus the line endings.
- A line ends with LF or with CR LF (the X Consortium’s 2.1 text allows either; Adobe’s documents describe CR LF).
- Keywords are upper case and come first on the line; values are separated by spaces. In 2.1 numbers are decimal integers, which may be negative; 2.2 (section 3) also allows real numbers where a value is of type number.
- Version 2.2 lifts the limit on line length: lines may be any length, and a string value may be up to 65,535 characters, the longest PostScript string (section 3 and the appendix).
COMMENTlines may appear anywhere betweenSTARTFONTandENDFONT, and are ignored.- Version 2.1 is the one adopted by the X Window System; version 2.2 (Adobe Technical
Note #5005, 22 March 1993) adds metrics for a second writing direction (vertical
text), font-wide metrics and the
CONTENTVERSIONkeyword. Its appendix warns that a 2.2 file may not be readable by a 2.1 parser.
Global keywords
In this order:
| Keyword | Values | Meaning |
|---|---|---|
STARTFONT | version | Required, the first line: 2.1 or 2.2. |
COMMENT | text | Optional, anywhere; ignored. |
CONTENTVERSION | integer | Version 2.2, optional. A number an installer can use to tell versions of the font data apart; it should change only when the bitmaps themselves are improved, not when the glyph set or encoding changes. |
FONT | name | Required. The font’s name: the rest of the line, which may contain spaces. In X fonts an XLFD name; Adobe’s 2.2 text says it should match the PostScript FontName of the matching outline font (section 3.1). |
SIZE | point size, x resolution, y resolution | Required. The size in points and the device resolution in dots per inch that the bitmaps were made for, e.g. SIZE 24 75 75. |
FONTBOUNDINGBOX | width, height, x offset, y offset | Required. In pixels: the smallest box that holds every glyph when drawn at the origin, given by its size and the offset of its lower-left corner from the origin. |
METRICSSET | 0, 1 or 2 | Version 2.2, optional. Which writing directions the glyphs have metrics for: 0 only direction 0 (horizontal, the default when absent), 1 only direction 1 (vertical), 2 both. |
STARTPROPERTIES | count | Optional. Starts the property block of count lines. |
ENDPROPERTIES | none | Ends the property block; required if it was started. |
CHARS | count | Required. The number of glyphs that follow, each from STARTCHAR to ENDCHAR. |
ENDFONT | none | Required, the last line. |
Version 2.2 (section 3.1) also allows the per-glyph metric keywords
SWIDTH, DWIDTH, SWIDTH1, DWIDTH1
and VVECTOR in this global section, before CHARS, to give one
value for the whole font; a glyph that gives the same keyword overrides it. This
saves space in ideographic fonts where most glyphs share metrics, but a file meant
for 2.1 readers should not use it. With METRICSSET 1,
SWIDTH and DWIDTH are optional. The keywords are described
on the Glyphs page.
The property block
Each line between STARTPROPERTIES and ENDPROPERTIES is a
property name and one value: an integer, or a string in double quotes, in which two
double quotes stand for one. BDF itself defines no property names except three that
every font should have:
| Property | Type | Meaning |
|---|---|---|
FONT_ASCENT | integer | Pixels above the baseline for spacing lines of text. |
FONT_DESCENT | integer | Pixels below the baseline for spacing lines. |
DEFAULT_CHAR | integer | The code of the glyph to show for a character the font lacks. |
A compiler may reject a font without them, or make up values. When the X server
compiled a BDF file these three became fields of the font rather than properties. All
other names come from the X Logical Font Description conventions (XLFD), below, or
are private names of the form _ORGANISATION_NAME.
The XLFD font name
An XLFD name is fourteen fields, each starting with a hyphen, for example
-Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-65-ISO8859-1. The same
fourteen values normally appear again as properties.
| # | Field | Meaning |
|---|---|---|
| 1 | FOUNDRY | Who digitised the font or last changed it, e.g. Adobe. |
| 2 | FAMILY_NAME | Family name, e.g. Helvetica. |
| 3 | WEIGHT_NAME | The foundry’s weight name, e.g. Medium, Bold. |
| 4 | SLANT | R roman (upright), I italic, O oblique, RI reverse italic, RO reverse oblique, OT other. Italic and oblique lean clockwise, the reverse forms anticlockwise. |
| 5 | SETWIDTH_NAME | The foundry’s width name, e.g. Normal, Condensed. |
| 6 | ADD_STYLE_NAME | Any extra style words needed to make the name unique, e.g. Sans; often empty. |
| 7 | PIXEL_SIZE | Body size in pixels. |
| 8 | POINT_SIZE | Body size in decipoints (tenths of a point, 72.27 points to the inch). |
| 9 | RESOLUTION_X | Horizontal resolution in dots per inch. |
| 10 | RESOLUTION_Y | Vertical resolution in dots per inch. |
| 11 | SPACING | P proportional, M monospaced, C character cell (monospaced with no ink outside each cell). |
| 12 | AVERAGE_WIDTH | Mean glyph width in tenths of a pixel; negative for right-to-left fonts. |
| 13 | CHARSET_REGISTRY | Who registered the character set, e.g. ISO8859, ISO10646. |
| 14 | CHARSET_ENCODING | Which set of that registry, e.g. 1; it says how ENCODING values map to characters. |
In scalable fonts the size fields are 0. A 0 weight, slant or width,
and bracketed matrices in the size fields, belong to scalable and polymorphic fonts
rather than to BDF bitmaps.
Standard properties
The XLFD defines these further properties. Sizes are in pixels unless stated, and the types are those of the X protocol: ATOM is a string (quoted in BDF), INT32 a signed and CARD32 an unsigned integer.
| Property | Type | Meaning |
|---|---|---|
MIN_SPACE | INT32 | Smallest word space to use (default ¾ of NORM_SPACE). |
NORM_SPACE | INT32 | Normal word space (default the width of the space glyph). |
MAX_SPACE | INT32 | Largest word space (default 1½ × NORM_SPACE). |
END_SPACE | INT32 | Space after a sentence (default NORM_SPACE). |
AVG_CAPITAL_WIDTH | INT32 | Mean width of capitals, tenths of a pixel. |
AVG_LOWERCASE_WIDTH | INT32 | Mean width of lower-case letters, tenths of a pixel. |
QUAD_WIDTH | INT32 | Width of an em space. Deprecated. |
FIGURE_WIDTH | INT32 | Width of the figures and dollar sign when they are all equal. |
SUPERSCRIPT_X, SUPERSCRIPT_Y | INT32 | Offset from the current point to a made-up superscript (y upwards). |
SUBSCRIPT_X, SUBSCRIPT_Y | INT32 | Offset to a made-up subscript (y downwards). |
SUPERSCRIPT_SIZE, SUBSCRIPT_SIZE | INT32 | Body size for those (default 0.6 × PIXEL_SIZE). |
SMALL_CAP_SIZE | INT32 | Body size for made-up small capitals. |
UNDERLINE_POSITION | INT32 | From the baseline to the top of the underline. |
UNDERLINE_THICKNESS | INT32 | Thickness of the underline. |
STRIKEOUT_ASCENT, STRIKEOUT_DESCENT | INT32 | Top and bottom of a box drawn over text, above and below the baseline. |
ITALIC_ANGLE | INT32 | Slant angle in 1/64 degree, anticlockwise from the 3 o’clock direction (upright is 90 × 64). |
CAP_HEIGHT | INT32 | Height of capitals. |
X_HEIGHT | INT32 | Height of lower-case letters such as x. |
RELATIVE_SETWIDTH | CARD32 | Width class: 0 undefined, 10 ultra-condensed to 90 ultra-expanded, 50 normal. |
RELATIVE_WEIGHT | CARD32 | Weight class: 0 undefined, 10 ultra-light to 90 ultra-bold, 50 medium. |
WEIGHT | CARD32 | Measured weight 0 to 1000: capital stem width × 1000 ÷ CAP_HEIGHT. |
RESOLUTION | CARD32 | Resolution in hundredths of a pixel per point. Deprecated. |
DESTINATION | CARD32 | 0 made to match printed output, 1 made for legibility on screen. |
FONT | ATOM | The full XLFD name. |
FACE_NAME | ATOM | Full typeface name without size, e.g. “Helvetica Bold”. |
FULL_NAME | ATOM | The same as FACE_NAME. Deprecated. |
COPYRIGHT | ATOM | Copyright of the font data. |
NOTICE | ATOM | Copyright of the design, or trademark notice for the name. |
FONT_TYPE | ATOM | Where the font came from: Bitmap, Prebuilt, Type 1, TrueType, Speedo, F3 or another registered name. |
FONT_VERSION | ATOM | The font’s version. |
RASTERIZER_NAME, RASTERIZER_VERSION | ATOM | The software that rendered a scaled font, and its version. |
RAW_ASCENT, RAW_DESCENT, other RAW_* | INT32 | For transformed fonts: the same metrics in units of 1/1000 of the pixel size. |
AXIS_NAMES, AXIS_LIMITS, AXIS_TYPES | ATOM, integers, ATOM | Axes of polymorphic (variable) fonts: names, minimum and maximum of each, registered types. |
Any of the fourteen name fields can also appear as a property of the same name:
FOUNDRY, FAMILY_NAME (the BDF 2.1 sample writes
FAMILY), WEIGHT_NAME, SLANT,
SETWIDTH_NAME, ADD_STYLE_NAME, PIXEL_SIZE,
POINT_SIZE, RESOLUTION_X, RESOLUTION_Y,
SPACING, AVERAGE_WIDTH, CHARSET_REGISTRY,
CHARSET_ENCODING.
Example
The start of the sample font in the BDF 2.1 specification, Adobe Helvetica Bold at 24 pixels:
STARTFONT 2.1
FONT -Adobe-Helvetica-Bold-R-Normal--24-240-75-75-P-65-ISO8859-1
SIZE 24 75 75
FONTBOUNDINGBOX 9 24 -2 -6
STARTPROPERTIES 19
FOUNDRY "Adobe"
FAMILY "Helvetica"
WEIGHT_NAME "Bold"
SLANT "R"
SETWIDTH_NAME "Normal"
ADD_STYLE_NAME ""
PIXEL_SIZE 24
POINT_SIZE 240
RESOLUTION_X 75
RESOLUTION_Y 75
SPACING "P"
AVERAGE_WIDTH 65
CHARSET_REGISTRY "ISO8859"
CHARSET_ENCODING "1"
MIN_SPACE 4
FONT_ASCENT 21
FONT_DESCENT 7
COPYRIGHT "Copyright (c) 1987 Adobe Systems, Inc."
NOTICE "Helvetica is a registered trademark of Linotype Inc."
ENDPROPERTIES
CHARS 2
Every glyph fits in a box 9 pixels wide and 24 high whose lower-left corner is 2 pixels left of and 6 pixels below the origin. Lines of text are spaced 21 + 7 = 28 pixels apart. The two glyphs that follow are decoded on the Glyphs page.