FZX format: Difference between revisions

From Sinclair Wiki
Jump to navigation Jump to search
mNo edit summary
(→‎Useful Links: Updated link)
Tags: Mobile edit Mobile web edit
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
* up to 244 characters per font (code 32 to 255)
* 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 following image (presented as loading screen by FZX driver) illustrates how most definition parameters (detailed below) are combined to generate the image of each character:
 
[[File:FZX.gif]]
 
The FZX format consists of a three byte header (containing parameters in yellow that are applied to the entire fontset), followed by a variable-length table containing data for each character (containing character parameters in cyan and magenta), and a variable-length set of character definitions.


== Header ==
== Header ==
height - vertical gap between baselines in pixels
'''height''' - vertical gap between baselines in pixels


This is the number of pixels to move down after a carriage return.
This is the number of pixels to move down after a carriage return.




tracking - horizontal gap between characters in pixels
'''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.
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
'''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.
All characters up to and including this character must have an entry in the list of definitions although the entry can be blank.
Line 29: Line 33:




offset  - word containing the offset to the character definition (plus any kern in the high two bits)
'''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.
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.
Line 38: Line 42:




shift  - nibble containing the amount of leading for the character (0-15)
'''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.
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)
'''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 width of the character definition in pixels. The value stores is  one less than the required value.
Line 52: Line 56:
   16 * shift + width - 1
   16 * shift + width - 1


== Definitions ==
== Character 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).
 
== Useful Links ==
https://spectrumcomputing.co.uk/index.php?cat=96&id=28171 - official FZX release and available fonts


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).
http://zx-modules.de/ - FZX editor
 
http://www.z88dk.org/ - Z80 C cross-compiler with built-in FZX support


[[category:specifications]]
[[category:specifications]]
[[category:native_file_formats]]
[[category:native_file_formats]]

Revision as of 21:19, 12 April 2018

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 following image (presented as loading screen by FZX driver) illustrates how most definition parameters (detailed below) are combined to generate the image of each character:

FZX.gif

The FZX format consists of a three byte header (containing parameters in yellow that are applied to the entire fontset), followed by a variable-length table containing data for each character (containing character parameters in cyan and magenta), 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

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

Useful Links

https://spectrumcomputing.co.uk/index.php?cat=96&id=28171 - official FZX release and available fonts

http://zx-modules.de/ - FZX editor

http://www.z88dk.org/ - Z80 C cross-compiler with built-in FZX support