96-Character Font File StructureThe structure of a Fastgraph/Fonts 96-character font file is surprisingly simple. A 96-character font file contains definitions for ASCII characters 32 through 127 decimal, although character 127 isn't used. Each character is stored in a bitmap that is the same size for all characters in the font. The bitmap width is the width of the font's widest character, while its height is the height of the font's tallest character. Given this information, we can summarize the font file structure in the following table.
Each character's bitmap is stored in rows from top to bottom and includes space for descender characters (even if the character is not a descender). Within each row, the bitmap values are stored from left to right. In addition, each row may include one or more blank pixels (for kerning) appended to the end of the row. To illustrate the bitmap format, consider the following two bitmaps for the lower case characters "x" and "y". The "x" bitmap is 10 pixels wide (including one pixel of kerning) and 10 pixels high (including three rows for descenders, even though "x" is not a descender). The "y" bitmap is 9 pixels wide and 10 pixels high.
The hexadecimal values to the right of each row are the bitmap values for the bytes in that row. To compute these values, set the dot (.) pixels to 0 and the asterisk (*) pixels to 1, then convert the resulting binary values to hex. When the rows do not contain a multiple of 8 pixels, logically pad them with zero pixels to compute the hex values. 96-character font files contain bitmaps for the characters whose ASCII decimal values are 32 through 127. This means the offset for a given character is
where ASCIIvalue is the character's ASCII value, and size is the bitmap size for each character (the value 194 is the offset within the file for the first character's bitmap). For this example, let's assume the value of MaxX is 2 and the value of MaxY is 15, making the bitmap size 30 bytes. The ASCII value of "x" is 120, so its bitmap offset is (120-32)*30+194, or 2,834. Similarly, the ASCII value of "y" is 121, so its offset is 2,864. The bitmap values are then stored in the file as shown below.
The ww bytes are the end of the bitmap for the "w" character, and the zz bytes are the beginning of the "z" bitmap. The ** bytes are filler bytes that pad the "x" and "y" bitmaps to their fixed 30-byte size. All such filler bytes must be zero.
|
 
copyright 2001 Ted Gruber Software, Inc.