intmetrics
size description
40 name of font, padded with return (&0d) characters
4 16
4 16
1 n=number of defined characters
3 reserved - currently 0
256 character mapping (ie indices into following arrays). for
example, if the 40th byte in this block is 4, then the fourth
entry in each of the following arrays refers to that character.
a zero entry means that character is not defined in this font.
2n x0 |
2n y0 | bounding cox of character (in 1/1000th em)
2n x1 | coordinates are relative to the 'origin point'
2n y1 |
2n x-offset after printing this character
2n y-offset after printing this character
the bounding boxes and offsets are given as 16-bit signed numbers, with the low byte
first.
x90y45 font files
each font file starts with a series of 4-word index entries, corresponding to the sizes
defined:
size description
1 point size (not multiplied by 16)
1 bits per pixel (4)
1 pixels per inch (x-direction)
1 pixels per inch (y-direction)
4 reserved - currently 0
4 offset of font data in file
4 size of font data
the list is terminated by:
1 0
font data
font data is limited to 64k per block. each block starts word-aligned relative to the
start of the file:
size description
4 x-size in 1/16ths point * x pixels per inch
4 y-size in 1/16ths point * y pixels per inch
4 pixels per inch in the x-direction
4 pixels per inch in the y-direction
1 x0 | maximum bounding box for any character
1 y0 | bottom-left is inclusive
1 x1 | top-rightis exclusive
1 y1 | all coordinates are in pixels
512 2 byte offsets from table start of character data. a zero value
means the character is not defined. these are low/high byte
pairs (ie little-endian)
character data
size description
1 x0 | bounding box
1 y0 |
1 x1 - x0 = x
1 y1 - y0 = y
x*y/2 4-bits per pixel (bpp), consectutive rows bottom to top.
not aligned until at the end.
0 - 3.5 alignment
new font file formats
the new font file formats includes definitions for the following types of font files:
- f9999x9999 (new style 4-bpp anti-aliased fonts)
- b9999x9999 (1-bpp bitmaps)
- outlines (outline font format, for all sizes)
'9999' = pixel size (ie point size * 16 * dpi / 72) zero-suppressed decimal number.
if the length of an outlines file is less than 256 bytes, then contents are the name of
another font whose glyphs are to be used instead (with this fonts metrics).
if the length of a x90y45 file is less than 256 bytes then contents are the
name of the f9999x9999 file to use as master bit maps.
file header
the file header is of the following form:
size description
4 "font - identification word
1 bits per pixel:
0 = outlines
1 = 1 bpp
4 = 4 bpp
1 version number of file format
4:no "don't draw skeleton lines unless smaller than this"
byte present
5:byte at [table+512] = max pixel size for skeleton
lines (0 => always do it)
6:byte at [chunk+indexsize] = dependency mask (see below)
instrument data
instrument names are not recorded; only channel numbers.
size description
1 3 indicates instrument data follows
this is followed by 8 blocks of 2 bytes each:
1 channel number. always consecutive 1-8
1 voice number; 0=no voice attached
volume data
size description
1 4 indicates volume data follows
1*8 volume on each channel = 0-7 = ppp-fff. one byte for
each channel.
stereo position data
size description
1 5 indicates stereo data follows
1*8 stereo position of channel n = 0-7 = full left...full right.
one byte for each channel.
tempo data
size description
1 6 indicates tempo data follows
1 0-14, which corresponds to one of:
40, 50, 60, 65, 70, 80, 90, 100, 115, 130, 145, 160, 175, 190, 210
beats per minute
to convert to values to program into swi sound_tempo, use the formula:
sound_tempo value = beats per minute * 128 * 4096/6000
title string
size description
1 7 indicates title string follows
n null terminated string of n characters total length
instrument names
size description
1 8 indicates instrument names follow
n1..n8 8 null terminated strings for each voice number used in
ascending order under
notes and rests are each stored in a 2 byte block that has some common elements.
if a rest coincides with a note, its position is determined by the following note on
the same channel.