Revision 6

Display Font Format

Overview

Display Fonts are variable spaced, proportional unicode fonts.

Spacing

Fonts have both top and bottom interline spacing, and font characters have both left and right inter-character spacing. The spacing between any two characters in a message is determined by taking the minimum of the left character's right spacing and the right character's left spacing. Similarly, line spacing is determined by taking the minimum of the top line's bottom spacing and the bottom line's top spacing.

Kerning

Kerning maps between characters are supported. Kerning maps give the spacing on a per-character-combination, allowing the font to describe things like less space between "To" and more space between "mm". Kerning in the font format is supported between any two unicode characters which can be specified with 16 bit unicode. However, the rendering implementation does not guarantee support for kerning between characters with different high bytes; that is, rendering implementations may only support kerning between characters on the same code page.

Direction

Each character has a preferred direction, based upon the language that it comes from. The direction of a line is determined by counting the number of characters with each direction: the winner is whichever direction has the plurality of characters, or left-to-right in the event of a tie.

Run-Length Encoding

Solartech fonts are bit-mapped (as opposed to vector-based), and for efficency of storage, loading, and drawing are stored run-length encoded.

The font block indicates the RLE format, but currently only the monochrome 8-bit length format is supported. (When hardware supports grayscale, additional RLE formats will be defined.) In the monchrome 8-bit length encoding, the data is represented as follows:

The Data_Length indicates the number of bytes, but this is also the number of RLE entries, so no separate entry length is needed. Each entry is 1 byte long, and represents the length of the run. The starting opacity is OPAQUE. Each subsequence entry is for the opposite color from the one before it. That is, the first byte is the length of OPAQUE, the next is the length of TRANSPARENT, the next is the length of OPAQUE, and so on. Lengths of zero are permitted. (N.B. there is no requirement that Data_Length be even.)

Decoding the run-length encoded data produces a stream of pixel opacities, which represent the bitmap in row-major order. The stream so produced will always exactly fill the size of the bitmap represented. Please note that it is perfectly valid for an opacity run to cross 1 or more line boundaries; when rendering an RLE font into an array, it is your responsibility to line-wrap as appropriate.

Data Format

Font Block
Byte Count Data Type Value Description
2 unsigned short (character_count) The number of characters in this font
1 unsigned byte height the line height of the font (in pixels)
1 unsigned byte the spacing above the line
1 unsigned byte the spacing below the line
1 unsigned byte the font weight characterization:
1 thin
2 normal
3 bold
1 unsigned byte the font width characterization:
1 condensed
2 narrow
3 normal
4 wide
1 unsigned byte Character Data Format Designator:
0 Monochrome RLE, 8-bit length
2-65,537 Java UTF-8 String The name of the font.
2 unsigned short kerning_count The number of kerning blocks

kerning_count kerning blocks of the form:
Kerning Block
Byte Count Data Type Value Description
2 unsigned short the unicode character code of the inital character
1 unsigned byte mapping_count The number of kerning mappings for characters following this character

mapping_count spacing blocks:
Spacing Block
Byte Count Data Type Value Description
2 unsigned short the unicode character code of the following character
1 signed byte the spacing between the two characters. (can be negative.)

character_count character blocks:
Character Block
Byte Count Data Type Value Description
2 unsigned short the Unicode character code
1 unsigned byte (width) the width of the character, in pixels
1 unsigned byte the spacing on the left
1 unsigned byte the spacing on the right
1 unsigned byte The layout direction of this character:
0 any
1 Left to Right
2 Right to Left
3 Top to Bottom
4 Bottom to Top
Data_Length unsigned short The number of bytes of image data that follows. Depending on the data format, there may be an additional header in the data.

Data_Length bytes of image data.