exf/Spec.md

2.8 KiB

Expressive Text Format (EXF or ETF)

EXF is a new (or old) text format that encodes pictures rather than codepoints. EXF-8 encodes an octet stream where, like in UTF-8, the highest bit of each octet is a continuation bit. For the continuation bit, 1 indicates that the next octet is part of the current element, and 0 indicates the end of the current element. An element is composed of the leftover (non-continuation) bits of each octet.

Elements

An element encodes a sequence of bits that represent exactly one header and one body, where body is either a glyph or control code.

Header

A header encodes an 8 bit data structure. The first bit indicates whether this header is a control header or a glyph header.

Control header

The remaining bits indicate control data.

Glyph header

The next bit in the header indicates whether a courtesy space should be rendered between the previous glyph and this one. The width of a courtesy space is up to the renderer. Glyph data begins at the start of the next octet.

Body

Control Data

The control data may be interpreted as an unsigned integer where the least significant bits come first. Valid values for a control code are in the range 0..256. Anything outside of this range is implementation-defined. Control data more than 128 bits in length is an error. The meaning and interpretation of control data is subject to change and should not be relied on before this spec is finalized.

Glyph

Glyphs are a sequence of bits that encode a quadtree representing the raster data of the glyph. Empty glyph data (all 0) indicates whitespace.

Raster data

Raster data encodes a 64 by 64 bitmap where a 1 indicates a point should be drawn and a 0 indicates whitespace.

Quadtree

A quadtree is a recursive data structure composed of a header and a body. The 6th level of this data structure is terminal and the header encodes direct bit values for the raster image. The top-left, top-right, bottom-left and bottom- right regions of a raster image correspond to the 0th, 1st, 2nd, and 3rd nodes within a quadtree, respectively.

Quadtree header

A quadtree header encodes a 4 bit data structure. Each bit corresponds to a quadregion in the resulting raster image. A bit value of 0 indicates that the underlying quadtree node is homogenous. Its corresponding data length is 1 bit and encodes the resulting value for that entire region. A bit value of 1 indicates that the underlying quadtree data is heterogenous. Its corresponding data encodes another quadtree.

Quadtree body

A quadtree body is made up of 4 packed data regions. The order of these data regions corresponds to the order of the quadtree header bits.