Skip to main content

Fonts (FNT)

File formats · Field reference · Schema

In brief​

The two fonts of the game draw characters 0 to 127 as small bitmaps: FONT6.FNT is 6 pixels wide and high, FONT8.FNT 8 by 8. Both are loaded at start-up. FONT8.FNT is loaded with the display driver and is the font of the start menu, and FONT6.FNT that of the play screen. See also fonts among the game's images.

From the file Fonts (FNT) to the game. The file holds, in order: Size (2 bytes); Offsets (128 × 2 bytes); Height, width (2 bytes); Glyphs (rest). The game: Allocate the stored size and read the file at start-up. In memory: Two fonts: FONT8 and FONT6. Used by: Start menu and questions (FONT8), Play screen (FONT6).
The game turns it into two fonts: FONT8 and FONT6.

Organization​

BytesContents
0–1The size of the rest of the file, which the game allocates and reads.
2–257128 offsets, one per character, of the character's glyph from the start of the file.
258Height of every glyph, in rows.
259Width of every glyph, in pixels, which is also the advance from one character to the next.
260–The glyphs.

A glyph is a column of rows, top to bottom, each of one byte per eight pixels of width: one byte in both fonts. The leftmost pixel is the most significant bit; a set bit is drawn in the text colour and a clear bit in the background colour, and a background colour of 0 leaves the screen as it is.1 In both files the glyphs follow one another in character order from byte 260, and the last one ends with the file.

Reading the file​

Both fonts are loaded at start-up: FONT8.FNT with the display driver, when the display mode is set. The game allocates the size stored in the file and reads the rest of the file into that block.2

What it becomes in memory​

The fonts stay in memory as they are read, and the game installs one or the other as the current font. FONT8.FNT is that of the start menu, and the game installs it again for the two-choice questions, the defeat message and the ending; FONT6.FNT becomes the font of the play screen when a game starts: messages, names and the inventory.2 The game's text routines turn bytes from 0x80 up into pairs of characters before drawing, so only characters 0 to 127 reach the font; see item names.

Anomaly

The game allocates the stored size and reads that many bytes 2 bytes into the block, so the font ends 2 bytes past the size it requested. The allocator's rounding leaves room for both original fonts; a stored size of 12 modulo 16 would leave none, and the last bytes would overwrite what follows the block (inferred). A faithful reimplementation of the original files needs no special handling. (ANOMALY-142)

Example​

The glyph of A in FONT6.FNT, 6 rows of one byte:

70 .###....
88 #...#...
f8 #####...
88 #...#...
88 #...#...
00 ........

Sources​

Locations refer to the game executable reference; the files are identified in the file inventory.

Footnotes​

  1. The VGA driver's draw one glyph and draw a line of text. ↩

  2. Load a font, the program start-up settings, the display mode setup, which loads FONT8.FNT, and install a font. ↩ ↩2