GDOS Font file format

From Atari Wiki
Jump to navigation Jump to search
Filenames ending with the extension '.FNT' represent bitmap font files. These files may
be utilized by loading them through any version of GDOS. FNT files are composed of a file
header, font data, a character offset table, and (optionally) a horizontal offset table.

The FNT Header:

Font files begin with a header 88 BYTEs long. WORD and LONG format entries in the header
must be byte-swapped as they appear in Intel ('Little Endian') format (see FONT_HDR 
structure).

The font header is formatted as follows:

BYTE(s)    Contents                                       Related VDI Call
 0 -  1    Face ID (must be unique).                      vqt_name()
 2 -  3    Face size (in points).                         vst_point()
 4 - 35    Face name.                                     vqt_name()
36 - 37    Lowest character index in face (usually 32     vqt_fontinfo()
           for disk-loaded fonts).
38 - 39    Highest character index in face.               vqt_fontinfo()
40 - 41    Top line distance expressed as a positive      vqt_fontinfo()
           offset from baseline.
42 - 43    Ascent line distance expressed as a positive   vqt_fontinfo()
           offset from baseline.
44 - 45    Half line distance expressed as a positive     vqt_fontinfo()
           offset from baseline.
46 - 47    Descent line distance expressed as a positive  vqt_fontinfo()
           offset from baseline.
48 - 49    Bottom line distance expressed as a positive   vqt_fontinfo()
           offset from baseline.
50 - 51    Width of the widest character.                 N/A
52 - 53    Width of the widest character cell.            vqt_fontinfo()
54 - 55    Left offset.                                   vqt_fontinfo()
56 - 57    Right offset.                                  vqt_fontinfo()
58 - 59    Thickening size (in pixels).                   vqt_fontinfo()
60 - 61    Underline size (in pixels).                    vqt_fontinfo()
62 - 63    Lightening mask (used to eliminate pixels,     N/A
           usually 0x5555).
64 - 65    Skewing mask (rotated to determine when to     N/A
           perform additional rotation on a character
           when skewing, usually 0x5555).
66 - 67    Font flags as follows:                         N/A
             Bit  Meaning (if Set) 
              0   Contains System Font
              1   Horizontal Offset Tables
                  should be used.
              2   Font data need not be byte-swapped. 
              3   Font is mono-spaced.
68 - 71    Offset from start of file to horizontal        vqt_width()
           offset table.
72 - 75    Offset from start of file to character offset  vqt_width()
           table.
76 - 79    Offset from start of file to font data.        N/A
80 - 81    Form width (in bytes).                         N/A
82 - 83    Form height (in scanlines).                    N/A
84 - 87    Pointer to the next font (set by GDOS after    N/A
           loading).

Font Data:

The binary font data is arranged on a single raster form. The raster's height is the same
as the font's height. The raster's width is the sum of the character width's padded to
end on a WORD boundary.

There is no padding between characters. Each character may overlap BYTE boundaries. Only
the last character in a font is padded to make the width of the form end on an even WORD
boundary.

If bit #2 of the font flags header item is cleared, each WORD in the font data must be
byte-swapped.

Character Offset Table:

The Character Offset Table is an array of WORDs which specifies the distance (in pixels) 
from the previous character to the next. The first entry is the distance from the start
of the raster form to the left side of the first character. One succeeding entry follows
for each character in the font yielding (number of characters + 1) entries in the table.
Each entry must be byte-swapped as it appears in Intel ('Little Endian') format.

Horizontal Offset Table:

The Horizontal Offset Table is an optional array of positive or negative WORD values
which when added to the values in the character offset table yield the true spacing 
information for each character. One entry appears in the table for each character. This 
table is not often used.

Back to ST Picture Formats