FZX format

From Sinclair Wiki
Revision as of 16:39, 21 June 2013 by Guesser (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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.

Header

height - 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.

Table

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).


offset - word containing the offset to the character definition (plus any kern in the high two bits)

This is calculated from the start of the table and stored as an offset rather than an absolute address to make the font relocatable. The kern is the left shift towards the previous character and can be between 1 and 3 pixels.

The byte containing the offset can be calculated as follows:

  offset + 16384 * kern


shift - 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:

  16 * shift + width - 1

Definitions

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).