# QMK Font Format :id=qmk-font-format QMK uses a font format _("Quantum Font Format" - QFF)_ specifically for resource-constrained systems. This format is capable of encoding 1-, 2-, 4-, and 8-bit-per-pixel greyscale- and palette-based images into a font. It also includes RLE for pixel data for some basic compression. All integer values are in little-endian format. The QFF is defined in terms of _blocks_ -- each _block_ contains a _header_ and an optional _blob_ of data. The _header_ contains the block's _typeid_, and the length of the _blob_ that follows. Each block type is denoted by a different _typeid_ has its own block definition below. All blocks are defined as packed structs, containing zero padding between fields. The general structure of the file is: * _Font descriptor block_ * _ASCII glyph block_ (optional, only if ASCII glyphs are included) * _Unicode glyph block_ (optional, only if Unicode glyphs are included) * _Font palette block_ (optional, depending on frame format) * _Font data block_ ## Block Header :id=qff-block-header The block header is identical to [QGF's block header](quantum_painter_qgf.md#qgf-block-header), and is present for all blocks, including the font descriptor. ## Font descriptor block :id=qff-font-descriptor * _typeid_ = 0x00 * _length_ = 20 This block must be located at the start of the file contents, and can exist a maximum of once in an entire QGF file. It is always followed by either the _ASCII glyph table_ or the _Unicode glyph table_, depending on which glyphs are included in the font. _Block_ format: ```c typedef struct __attribute__((packed)) qff_font_descriptor_v1_t { qgf_block_header_v1_t header; // = { .type_id = 0x00, .neg_type_id = (~0x00), .length = 20 } uint24_t magic; // constant, equal to 0x464651 ("QFF") uint8_t qff_version; // constant, equal to 0x01 uint32_t total_file_size; // total size of the entire file, starting at offset zero uint32_t neg_total_file_size; // negated value of total_file_size, used for detecting parsing errors uint8_t line_height; // glyph height in pixels bool has_ascii_table; // whether the font has an ascii table of glyphs (0x20...0x7E) uint16_t num_unicode_glyphs; // the number of glyphs in the unicode table -- no table specified if zero uint8_t format; // frame format, see below. uint8_t flags; // frame flags, see below. uint8_t compression_scheme; // compression scheme, see below. uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented) } qff_font_descriptor_v1_t; // _Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF"); ``` The values for `format`, `flags`, `compression_scheme`, and `transparency_index` match [QGF's frame descriptor block](quantum_painter_qgf.md#qgf-frame-descriptor), with the exception that the `delta` flag is ignored by QFF. ## ASCII glyph table :id=qff-ascii-table * _typeid_ = 0x01 * _length_ = 290 If the font contains ascii characters, the _ASCII glyph block_ must be located directly after the _font descriptor block_. ```c #define QFF_GLYPH_WIDTH_BITS 6 #define QFF_GLYPH_WIDTH_MASK ((1<