Examples
Figures 2 through 4, along with Example 1, illustrate the bitmap format and glyph metric information. Figures 2 and 3 show examples of individual glyphs, which are both included in the font shown in Example 1. Figure 4 shows a glyph defined for use in both writing direction 0 and 1.
#
Figure 2In Figure 2, the bounding box is expressed differently than other PostScript language files such as the Adobe Font Metrics (AFM) file. The first two numbers following BBX
are the width and height, the second two are the offsets in x and y.
The width from the origin (between the “+” indicators) is 8 pixels, which is how far the current point moves after rendering the character. It has nothing to do with the width of the bitmap.
The bounding box of the bitmap glyph can be used to predict how much data to read in the BITMAP
section. The first two numbers give the width and height of the bitmap and correspond exactly to the amount of data supplied. The offset then allows positioning without repeating lots of white bits. (see the following quoteright glyph for an illustration of a glyph with all black pixels located a distance from the origin).
#
Figure 3In Figure 3, the actual bitmap is much smaller, and the offset (2 in x, 12 in y) positions the glyph with respect to its origin. The bitmaps in both Figure 2 and 3 are from an italic font program. Notice that the glyph width of the quoteright leaves the origin to the left of the black bits after the glyph is drawn, as would be expected for an italic font.
The bitmap is started by the BITMAP
keyword and finished with the ENDCHAR
keyword; this is illustrated in Example 1, below). It is best to predict the amount of data needed (using the BBX
information) and use the ENDCHAR
as an error-checking method. If you have consumed what you think is the appropriate amount of data, the next thing in the file should be ENDCHAR
. If not, either the parser is in error, the file is not complete, or it is incorrect.
The bitmap is represented as hexadecimal digits, where each row corresponds to one row of the glyph bitmap. The bits are padded out to the nearest byte boundary with 0s. The BBX
bounding box information should be carefully consulted to determine how to extract the data.
#
Figure 4#
Sample BDF FontExample 1: Sample BDF Font
The following is an abbreviated example of a BDF bitmap file containing the specification of two glyphs ( j and quoteright from Figures 2 and 3):