FZX is a royalty-free compact bitmap font file format designed primarily for storing bitmap fonts for the Sinclair ZX Spectrum.
FZX has the following features:
- proportional spacing
- characters can be up to 16 pixels in width
- characters can be up to 192 pixels in depth
- up to 244 characters per font (code 32 to 255)
The format consists of a three byte header followed by a variable-length table and a variable-length set of character definitions.
The header format is:
baseline - vertical gap between baselines in pixels This is the number of pixels to move down after a carriage return.
tracking - horizontal gap between characters in pixels Character definitions should not include any white space and this value should normally be a positive number. It may be zero for script style fonts where characters run together.
lastchar - the ASCII code of the last definition in the font All characters up to and including this character must have an entry in the list of definitions although the entry can be blank.
The table consists of a three byte entry for each character from ASCII 32 to the last character defined (lastchar) followed by a word containing the length of the file (the offset to the byte after the last byte of the last definition).
The table entry format is:
offset - word containing the offset to the character definition This is calculated from the start of the table and stored as an offset rather than an absolute address to make the font relocatable.
leading - nibble containing the amount of leading for the character (0-15) This is the number of vertical pixels to skip before drawing the character. When more than 15 pixels of white space are required the additional white space must be added to the character definition.
width - nibble containing the width of the character (1-16) The width of the character definition in pixels. The value stores is one less than the required value.
The byte containing the leading and width can be calculated as follows:
The character definitions consist of a byte or pair of bytes for each row of the character, depending on whether the character is 1 to 8 pixels wide (byte), or 9 to 16 pixels wide (pair of bytes).