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. The 2.1 text calls its values integers (positive integers where they must be) and gives
no further syntax; its only remark on pixels is in the
DWIDTHentry (the actual device width must be an integral number of device pixels); 2.2 (section 3) gives the type rules: integer, signed or unsigned, and number, real or integer. - 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. A Note in section 3 (File Format, before section 3.1) of the Technical Note says that while it is possible to use a 2.2 font file with a 2.1 parser, it is also possible for it to be incompatible. (The appendix, Changes Since Earlier Versions, has no such warning.)
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 assigned by an installer program to keep track of the version of the included data. The value is intended to be valid only in a single environment, under the control of a single installer. 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; the 2.1 text also allows “some private font name” and encourages the creators of private font-name syntaxes to register unique name prefixes with the X Consortium to prevent naming conflicts. 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. The width in x and the height in y, then the x and y displacement of the lower-left corner from the origin (2.1 and 2.2 texts; 2.2 adds that all four are integer pixel values). Neither text says more about what the box bounds, so it is not defined here as a “smallest box”. |
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 (INT32) | The recommended typographic ascent above the baseline, in pixels, for interline spacing; glyphs may extend beyond it. If the current position of line n is [X, Y], the origin of the next line m is [X, Y + FONT_DESCENTn + FONT_ASCENTm] (allowing for a font change). If missing it can be approximated as the maximum ascent, in pixels, of any glyph in the font. |
FONT_DESCENT | integer (INT32) | The recommended typographic descent below the baseline, in pixels, for interline spacing; glyphs may extend beyond it. The logical extent of the font is inclusive between the Y coordinates Y − FONT_ASCENT and Y + FONT_DESCENT + 1. If missing it can be approximated as the maximum descent, in pixels, of any glyph in the font. |
DEFAULT_CHAR | integer (CARD32, unsigned) | The index of the glyph the X server uses when asked to display an undefined or nonexistent character. For a font in a 2-byte matrix format the index bytes are encoded as byte1 × 65536 + byte2. If DEFAULT_CHAR itself names an undefined or nonexistent glyph, nothing is displayed. It cannot be approximated if missing. |
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.
The XLFD (Chapter 8, BDF Conformance) says that if they are present they must follow
the definitions above. Every other name is one of the XLFD names below, a private
name of the form _ORGANISATION_NAME, or one of the tool conventions in
the next paragraphs.
Properties real files carry that the XLFD does not define
FONTNAME_REGISTRY: written as the first property of the X.Org Misc-Fixed fonts (for example 6x13:FONTNAME_REGISTRY "", an empty string). The XLFD defines FontNameRegistry only as the prefix of a font name (the-at the start of an XLFDFONTname), not as a property, and gives no meaning for it; the property appears to be the font tools’ copy of that registry part, but no specification says so. A reader should accept it and show its string._GBDFED_INFO: private property of the form_TOOL_NAME. In Misc-Fixed 6x13 it is_GBDFED_INFO "Edited with gbdfed 1.3.", evidently added by the gbdfed bitmap editor; no specification defines it, and it carries no font data.- Other private names that gbdfed 1.6 knows, from its source (
bdf.c), README and manual:_XFREE86_GLYPH_RANGES(the manual writes_XFREE86_GLYPH_RANGE, the README and the source_XFREE86_GLYPH_RANGES), which gbdfed ignores when it reads a font, and_ORIGINAL_FONT_NAME, in which its “Make XLFD Name” command saves the previous font name when the font had no XLFD name._XMBDFED_INFOonly appears in the property table ofbdf.c(commented “Throw this in to make it clear”) and is skipped on reading; neither the README nor the manual says that gbdfed writes it, so who writes it is not established here. - The underscore rule: a name starting
_belongs to an organisation or tool, and a reader that does not recognise it should keep it and show it as private, not reject the font.
Sources read for this section: the X Consortium BDF 2.1 text, the XLFD specification (X.Org, Chapter 8 and the Font Properties chapter), the Misc-Fixed 6x13.bdf file from X.Org, the gbdfed manual page and gbdfed 1.6 bdf.c. The X loader’s rules are from libXfont’s bdfread.c, bdfutils.c and bitmaputil.c (X.Org master, raw); how FontForge, otf2bdf and bdftopcf write or read a file was not read for this page.
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.
Syntax of the name
From the XLFD 1.5 specification (X.Org X11R7.7, chapter 3 “FontName”, read in this session).
- The name is a string of ISO 8859-1 characters and has at most 255 characters in all.
- It starts with the FontNameRegistry prefix. For every name that follows the XLFD this is
the single hyphen
-. A prefix of the form+version-(for example+1.4-) is reserved by the X Consortium for later XLFD versions, which would add fields after the fourteenth; any other prefix is a private registry, with a name of whatever syntax its owner defines (the 2.1 BDF text allows such privateFONTnames). - After the prefix come the fourteen fields in the order of the table above, each separated from the
last by
-. A field can be empty, asADD_STYLE_NAMEis in the example above (the double hyphen before the pixel size). - A field value is made of ISO 8859-1 graphic characters except these five:
-(the field delimiter),?and*(the X name wildcards),,(used by Xlib to separate names in a font set) and"(used by some products to quote a name). A space is allowed:ITC Avant Garde Gothicmay be aFAMILY_NAME. - Letters may be in either case, but case is for human readers only: a conforming server matches names without regard to case.
- Numeric fields are written as strings of digits. A leading
~(tilde) stands for a minus sign, which is howAVERAGE_WIDTHis written when negative (right-to-left fonts), because-is the delimiter. The same fields appear as properties with signed or unsigned integer values. - The
CHARSET_ENCODINGfield may end with a subsetting hint: a[, a list of ranges and a]. The hint tells the font source that the client wants only those characters (the source may return a font with exactly them or any superset, and the font properties may be worked out from the subset only). A range is a number, or two numbers joined by_for an inclusive range; a number is decimal or0xfollowed by hexadecimal digits (atofin lower case in the syntax); ranges are separated by a space. Example:-misc-fixed-medium-r-normal--0-0-0-0-c-0-iso8859-1[65 70 80_90]asks for characters 65, 70 and 80 to 90.
PIXEL_SIZE_MATRIX and POINT_SIZE_MATRIX
XLFD chapter 4, “Matrix Transformations”: in a font name, a PIXEL_SIZE or POINT_SIZE
field that begins with [ is not a number but a matrix [a b c d] (four floats separated by
spaces; ~ stands for a minus sign in a mantissa, as in the numeric fields). It describes a graphical
transformation of the glyphs of the font around the glyph origin, the matrix
( a b 0 / c d 0 / 0 0 1 ). The XLFD calls the two matrices PIXEL_SIZE_MATRIX and
POINT_SIZE_MATRIX. They relate to the scalar fields so that the scalar N in the
POINT_SIZE field gives the same glyphs as the matrix [N/10 0 0 N/10], and the scalar
N in PIXEL_SIZE the same as [N*RESOLUTION_X/RESOLUTION_Y 0 0 N]. If both
matrices are given they must satisfy, within an implementation-specific tolerance,
PIXEL_SIZE_MATRIX = [Sx 0 0 Sy] * POINT_SIZE_MATRIX with Sx = RESOLUTION_X / 72.27 and
Sy = RESOLUTION_Y / 72.27; if one field is unspecified (0 or a wildcard) the formulas give it
from the other.
They are names the XLFD uses for these two name fields, not BDF keywords or properties: a bitmap font cannot be
transformed, so a BDF file carries the numbers (the PIXEL_SIZE and POINT_SIZE
properties and the SIZE line), and the matrix form belongs to the scalable and polymorphic fonts that a
font server makes from a name such as that. The viewer shows the meaning of both in the Properties table.
When a BDF font conforms to the XLFD
XLFD chapter 8 “BDF Conformance”: a BDF font conforms if and only if all four hold.
- The value of the
FONTitem conforms to the syntax and meaning of an XLFD FontName (the rules above). - The name begins with the registry prefix
-. - All fourteen fields of the name are defined.
- Every font property it gives matches an XLFD property in name and meaning, or follows the
definition of a private property (a name starting
_).
The specification’s simple test: check that the prefix is -, that the number of
delimiters and the coded field values are valid, and that each property name is a standard XLFD name
or a private one. Where present, FONT_ASCENT, FONT_DESCENT and
DEFAULT_CHAR must also follow the definitions above.
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. (The XLFD’s property text calls it INT32; its table of built-in atoms says CARD32.) |
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.
Types of the fourteen name properties
Each is defined as in the font name, except for its property type and fallback:
| Property | Type | If a font omits it |
|---|---|---|
FOUNDRY, FAMILY_NAME, CHARSET_REGISTRY, CHARSET_ENCODING | ATOM | Cannot be calculated or defaulted. |
WEIGHT_NAME | ATOM | Defaults to "Medium". |
SLANT | ATOM | Defaults to "R". |
SETWIDTH_NAME | ATOM | Defaults to "Normal". |
ADD_STYLE_NAME | ATOM | Defaults to the empty string. |
PIXEL_SIZE | INT32 | Approximated as ROUND((RESOLUTION_Y × POINT_SIZE) ÷ 722.7). |
POINT_SIZE | INT32 | The design point size cannot be calculated or approximated. |
RESOLUTION_X, RESOLUTION_Y | CARD32 | Cannot be calculated or approximated. |
SPACING | ATOM | Calculated from the glyphs as the font name defines it. |
AVERAGE_WIDTH | INT32 | ROUND(MEAN(ABS(width of each glyph)) × 10), times 1 for a left-to-right dominant writing direction, −1 otherwise. |
ROUND(a) is FLOOR(a + 0.5); 722.7 is “DeciPointsPerInch”. Typographic spaces can be derived as EMspace = ROUND((RESOLUTION_X × POINT_SIZE) ÷ 722.7), ENspace = ROUND(EMspace ÷ 2), THINspace = ROUND(EMspace ÷ 3); or, device-independently, ROUND(POINT_SIZE ÷ 10), ÷ 20 and ÷ 30. The pitch of a monospaced font in characters per inch is (RESOLUTION_X × 10) ÷ AVERAGE_WIDTH when SPACING is not proportional.
Fallback formulas for the other properties
The XLFD says a client may approximate these when a font leaves them out (“maximum ascent” and “maximum descent” are of any glyph in the font, in pixels):
| Property | Fallback |
|---|---|
NORM_SPACE | The width of the space glyph if it exists, else ROUND(0.33 × RESOLUTION_X × POINT_SIZE ÷ 722.7). |
MIN_SPACE, MAX_SPACE, END_SPACE | ROUND(0.75 × NORM_SPACE), ROUND(1.5 × NORM_SPACE), NORM_SPACE. |
AVG_CAPITAL_WIDTH, AVG_LOWERCASE_WIDTH | ROUND(MEAN(ABS(width of each capital or lower-case glyph)) × 10), signed by writing direction as for AVERAGE_WIDTH; undefined if the font has no such glyphs. |
FIGURE_WIDTH | The width of the dollar sign if the numerals and dollar sign are defined and have equal widths; else undefined. |
SUPERSCRIPT_X, SUBSCRIPT_X | ROUND((0.40 × CAP_HEIGHT) ÷ TANGENT(ITALIC_ANGLE)) if that is defined, else ROUND(0.40 × CAP_HEIGHT). Superscripts begin at [X + SUPERSCRIPT_X, Y − SUPERSCRIPT_Y], subscripts at [X + SUBSCRIPT_X, Y + SUBSCRIPT_Y]. |
SUPERSCRIPT_Y, SUBSCRIPT_Y | ROUND(0.40 × CAP_HEIGHT). |
SUPERSCRIPT_SIZE, SUBSCRIPT_SIZE | ROUND(0.60 × PIXEL_SIZE). |
SMALL_CAP_SIZE | ROUND(PIXEL_SIZE × ((X_HEIGHT + ((CAP_HEIGHT − X_HEIGHT) ÷ 3)) ÷ CAP_HEIGHT)). |
UNDERLINE_POSITION | ROUND(maximum descent ÷ 2). |
UNDERLINE_THICKNESS | The average stem width of the capitals. |
STRIKEOUT_ASCENT, STRIKEOUT_DESCENT | The maximum ascent and the maximum descent. |
ITALIC_ANGLE | 90 × 64 (upright). |
CAP_HEIGHT | For a Latin font the ascent of the glyph X; else of some unaccented capital; undefined if there are no capitals. |
X_HEIGHT | For a Latin font the ascent of the glyph x; else of some unaccented lower-case glyph without an ascender; undefined if there are none. |
RELATIVE_SETWIDTH, RELATIVE_WEIGHT | 50 (ranges 10 to 90, or 0 if undefined or unknown). A calculated set width is AVG_CAPITAL_WIDTH ÷ (CAP_HEIGHT × 10). |
WEIGHT | ROUND((CapStemWidth × 1000) ÷ CAP_HEIGHT). |
FONT | Cannot be calculated if not provided. |
The ATOM properties FACE_NAME, COPYRIGHT, NOTICE, FONT_TYPE, FONT_VERSION and RASTERIZER_NAME are “human-understandable” strings; FONT_VERSION may be the value None. Source: XLFD (X.Org), Font Properties chapter.
What the X loader accepts: lines, header and properties
The two specifications leave a lot to the reader. The code that real X programs use is the
BDF reader of libXfont (bdfread.c and bdfutils.c, master branch at
gitlab.freedesktop.org, fetched raw in this session; the NetBSD xsrc copy read in an earlier session
behaves the same in everything described on these pages). It is
stricter than the specifications in the ways below, so a font that these programs load follows
all of them. The glyph checks are on the Glyphs
page. The viewer follows this reader line by line and lists what it would refuse or change in the Font tab, in a
section headed “X server behaviour”, as warnings: a valid 2.2 file is refused here, and the viewer does
not call it a problem.
How it reads lines
- Every carriage return (
CR) is dropped, wherever it is, so LF and CR LF endings both work. - Empty lines are skipped (only lines with no character at all once CR is dropped; a line of
spaces is not skipped), and so is any line that begins with the letters
COMMENT. Both are skipped wherever they fall, including inside a property block or a bitmap. (A comment that does not start in the first column is not recognised.) - A line is at most 1023 characters. In a longer line the first 1023 characters are the line,
the 1024th character is read and dropped, and reading goes on from the 1025th character as if it
began a new line (
bdfGetLineinbdfutils.c). - A last line with no line feed after it is never delivered: the reader treats it as the end of the
file, so a file whose
ENDFONThas no line ending fails with “missing ENDFONT”.
Header order and values
- The first line must be
STARTFONTfollowed by exactly2.1. A 2.2 file (or any other version) is rejected. The keywordsSTARTFONT,FONTandCHARSare matched withsscanfformats that have a blank after the keyword, and a blank in a format matches zero or more white-space characters, soSTARTFONT2.1andCHARS5are read like the spaced forms (bdfread.c). - Then, in this order and with nothing between but comments and blank lines:
FONT(its value is the rest of the line and must not be empty; the format reads at most 1023 characters, but a line itself is at most 1023, so withFONTand one blank in front the value has at most 1018, and at most 1019 with no blank);SIZEwith a real number and two integers, each of which must be at least 1 (soSIZE 0 75 75is an error);FONTBOUNDINGBOX, which only has to be there: the loader does not read its four numbers and works the bounds out from the glyphs itself; andSTARTPROPERTIESwith an integer count of at least 1. - The
STARTPROPERTIESblock is therefore required, although the specifications make it optional. Because the order is fixed, a 2.2 header keyword such asMETRICSSETorCONTENTVERSION, or a globalSWIDTH, betweenFONTBOUNDINGBOXandSTARTPROPERTIESmakes the file fail with “missing STARTPROPERTIES”.
The property block
- Exactly count property lines must follow
STARTPROPERTIES, then a line beginningENDPROPERTIES. AnENDPROPERTIESor the end of the file arriving early is an error (“followed by only n properties”), and so is anything butENDPROPERTIESafter the last one. Leading blanks on a property line are skipped. - A property line is read as up to three white-space-separated words. The first is the name. With only a name, the line is an error (“missing parameter value”).
- With two words: if the second begins with
"the value is a quoted string; if it is an integer (an optional+or-, or a digit, then only digits) the value is that integer; anything else is an error (“invalid parameter value”), so an unquoted word such asMediumis rejected. - With three or more words, only a quoted string is accepted (a value such as
"Edited with gbdfed"has spaces); an unquoted value is an error, even when the second word is an integer. - A quoted string is read from the text after the name: leading blanks are skipped, the outer quotes are removed, two quotes in a row stand for one, and the string ends at the first quote that is not doubled; anything after it on the line is ignored. A string with no closing quote is an error (“unterminated quoted string property”).
FONT_ASCENTandFONT_DESCENTmust both be present with integer values (a quoted or missing one is “missing FONT_ASCENT or FONT_DESCENT”). WithDEFAULT_CHARthey become fields of the font and are not kept in its property list. A quotedDEFAULT_CHARis ignored.- After
ENDPROPERTIESthe next line must beCHARSwith an integer of at least 1.
Properties the loader makes up
When the file lacks them, the loader adds these to the font’s properties (they are not in the file):
| Property | Value |
|---|---|
POINT_SIZE | The SIZE point size × 10, cut to an integer. |
FONT | The value of the FONT line, as a string. |
RESOLUTION | The SIZE x resolution × 100 ÷ 72.27, cut to an integer; added only when the x and y resolutions are equal. |
RESOLUTION_X, RESOLUTION_Y | The two SIZE resolutions. |
WEIGHT | (Also replaces a value of -1 given in the file.) The constant 10: the loader sets it from bitmapComputeWeight (bdfread.c), which in bitmaputil.c is only return 10;, so nothing is worked out from the glyphs. |
X_HEIGHT | From the glyph named x: its BBX height + y offset, or the height alone if that sum is 0 or less. With no glyph named x, or when that gives 0, the smallest ink ascent in the font. A value of -1 given in the file is replaced the same way. |
QUAD_WIDTH | (A value of -1 given in the file is replaced too.) The mean DWIDTH x of the glyphs named 0 to 9 (a one-character name), cut to an integer; with no such glyph, the mean of the narrowest and the widest character width in the font. |
DEFAULT_CHAR is split into a row (the value shifted right by 8) and a column (the low
byte), and used only if that row and column lie inside the range of codes the font has; otherwise the
font has no default glyph.
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.