BDF

Also Known As: Bitmap Distribution Format


Type Bitmap
Colors Mono
Compression None
Maximum Image Size Unlimited
Multiple Images Per File Yes
Numerical Format ASCII
Originator X Consortium
Platform Any supporting X Window System
Supporting Applications Many X applications
See Also None

Usage
Used to store and exchange font information.

Comments
Can be used to store arrays of ornamental glyph and other bitmap data.

Vendor specifications are available for this format.

Code fragments are available for this format.


BDF (Bitmap Distribution Format) is used by the X Window System as a method of storing and exchanging font data with other systems. The current version of BDF is 2.1; it is part of X11 Release 6. BDF is similar in concept to the PostScript Page Description Language. Both formats store data as printable ASCII characters, using lines of ASCII text that vary in length. Each line is terminated by an end-of-line character that may be a carriage return (ASCII 0Dh), a linefeed (ASCII 0Ah), or both.

Contents:
File Organization
File Details
For Further Information

Each BDF file stores information for exactly one typeface at one size and orientation (in other words, a font). A typeface is the name of the type style, such as Goudy, Courier, or Helvetica. A font is a variation in size, style, or orientation of a typeface, such as Goudy 10 Point, Courier Italic, or Helvetica Reversed. A glyph is a single character of a font, such as the letter "j". A BDF file therefore contains the data for one or more glyphs of a single font and typeface.

File Organization

A BDF file begins with information pertaining to the typeface as a whole, followed by the information on the font, and finally by the bitmapped glyph information itself. The information in a BDF file is stored in a series of records. Each record begins with an uppercase keyword, followed by one or more fields called tokens:

KEYWORD <token> <token> ...

All records, keywords, and information fields contain only ASCII characters and are separated by spaces. Lines are terminated by a <CR>, <LF>, or <CR/LF> pair. More than one record may appear on a physical line.

File Details

Following are some of the more common records found in BDF files:

STARTFONT <version>
ENDFONT

All BDF files begin with the STARTFONT record. This record contains a single information field indicating the version of the BDF format used in the file. The STARTFONT record contains all of the information within the BDF file and is terminated by the ENDFONT keyword as the last record in the file.

COMMENT <text>

COMMENT records may be found anywhere between the STARTFONT and ENDFONT records. They usually contain human-readable text that is ignored by font-reader applications.

FONT <fontname>

The FONT record specifies the name of the font contained within the BDF file. The name is specified using either the XFD font name or a private font name. The name may contain spaces, and the line containing the FONT record must be terminated by an end-of-line character.

SIZE <pointsize> <x resolution> <y resolution>

SIZE specifies the size of the font in points and the resolution of the output device that is to support the font.

FONTBOUNDINGBOX <width> <height> <x offset> <y offset>

The FONTBOUNDINGBOX record stores the size and the position of the font's bounding box as an offset from the origin (the lower-left corner of the bitmap).

STARTPROPERTIES <number of properties>
ENDPROPERTIES

The STARTPROPERTIES record contains subrecords that define the characteristics of the font. The STARTPROPERTIES keyword is followed by the number of properties defined within this record. The subrecords specify information such as the name of the font's creator, the typeface of the font, kerning and other rendering information, and copyright notices. The ENDPROPERTIES record always terminates the STARTPROPERTIES record. Following the ENDPROPERTIES record is the actual font data.

Following are descriptions of some common record keywords that may be used to describe the font data:

CHARS <number of segments>

The CHARS record indicates the number of font character (glyph) segments stored in the file.

STARTCHAR <glyphname>
ENDCHAR

The STARTCHAR record contains subrecords that store each glyph's information and data. The STARTCHAR keyword is followed by the name of the glyph. This name can be up to 14 characters in length and may not contain any spaces. The subrecords specify the index number of the glyph, the scalable width, and the position of the character.

The BITMAP record contains the actual glyph data encoded as 4-digit hexadecimal values. All bitmapped lines are padded on the right with zeros out to the nearest byte boundary. All of the glyph information is contained between the STARTCHAR record and the terminating ENDCHAR record. There is one STARTCHAR/ENDCHAR section per glyph stored in the BDF file.

Refer to the BDF documentation included with the X11R6 distribution for more information about the BDF information records.

Following is an example of a BDF file containing the characters j and quoteright (\&'). Note that more than one record appears per physical line:

STARTFONT 2.1 COMMENT This is a sample font in 2.1 format.
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 STARTCHAR
j ENCODING 106 SWIDTH 355 0 DWIDTH 8 0 BBX 9 22 -2 -6 BITMAP
0380 0380 0380 0380 0000 0700 0700 0700 0700 0E00 0E00 0E00
0E00 0E00 1C00 1C00 1C00 1C00 3C00 7800 F000 E000 ENDCHAR
STARTCHAR quoteright ENCODING 39 SWIDTH 223 0 DWIDTH 5 0 BBX
4 6 2 12 ATTRIBUTES 01C0 BITMAP 70 70 70 60 E0 C0 ENDCHAR
ENDFONT

The following is the same BDF file with each of the records stored on separate lines and indented to illustrate the layering of BDF records and subrecords:

STARTFONT 2.1
    COMMENT This is a sample font in 2.1 format.
    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
    STARTCHAR j
        ENCODING 106
        SWIDTH 355 0
        DWIDTH 8 0
        BBX 9 22 -2 -6
        BITMAP 0380 0380 0380 0380 0000 0700 0700 0700 0700 0E00 0E00
0E00 0E00 0E00 1C00 1C00 1C00 1C00 3C00 7800 F000 E000
    ENDCHAR
    STARTCHAR quoteright
        ENCODING 39
        SWIDTH 223 0
        DWIDTH 5 0
        BBX 4 6 2 12
        ATTRIBUTES 01C0
        BITMAP 70 70 70 60 E0 C0
    ENDCHAR
ENDFONT

For Further Information

For further information, see the BDF specification on the CD-ROM. You may also find information about the BDF format in the X11R5 distribution of the X Window System, available via FTP from:

ftp://ftp.x.org.



Copyright © 1996, 1994 O'Reilly & Associates, Inc. All Rights Reserved.