The font file comprises four sections: a file header, a segment table, a pointer table, and a glyph table.
Values are big-endian.
File header
The file header is 12 bytes long.
Bytes | Description |
---|---|
0x04 |
BFNT , identifies the file as a Bedrock font file. |
0x02 |
Address of the pointer table. |
0x02 |
Address of the glyph table. |
0x02 |
Length of file in bytes. |
0x01 |
The ascent distance of the font in pixels, including the baseline. |
0x01 |
Colour depth of the glyph data, either 0x00 or 0x01. |
Segment table
The segment table maps character codes to glyph indices. Must contain at least one segment.
Bytes | Description |
---|---|
0x02 |
Start character code. |
0x02 |
End character code. |
0x02 |
Start glyph index. |
Pointer table
The pointer table maps glyph indices to glyph data.
Glyph 0 must be the fallback glyph for when a glyph can’t be found for a character.
Glyph 1 must be the error glyph, for when a character code cannot be decoded.
Bytes | Description |
---|---|
0x02 |
Address of the first byte of glyph data for this glyph. |
Glyph table
The glyph table contains compressed sprite data.
Bytes | Description |
---|---|
0x01 |
Width of the glyph in pixels, including kerning. |
... |
Sprite definitions for this glyph. |
The first byte of a glyph is the width of that glyph, used for setting characters. The width includes kerning.
The remaining bytes define a series of sprites which comprise the glyph shape. Sprites are sorted left-to-right in rows, and then the rows are sorted top-to-bottom. Sprite definitions are variable-width.
The first byte of a sprite definition is a byte with packed fields.
Bits | Description |
---|---|
0x01 |
Set if this sprite is not the final sprite of the row. |
0x01 |
Set if this sprite is not in the final row of the glyph. |
0x03 |
Number of empty rows preceding sprite data. |
0x03 |
Number of rows of sprite data following this header, minus 1. |