[tocstart]: # (toc start)
* [U8g2 Font Format](#u8g2-font-format)
* [Font header](#font-header)
* [Glyph data](#glyph-data)
* [Glyph bitmaps](#glyph-bitmaps)
* [Pitches and distances](#pitches-and-distances)
* [Font Decoder](#font-decoder)
[tocend]: # (toc end)
# U8g2 Font Format
The data format of U8G2 fonts is based on the BDF font format. Its glyph bitmaps are compressed
with a run-length-encoding algorithm and its header data are designed with variable bit field width to minimize flash memory footprint.
| Font Header |
| Offset (Byte) | Size | Content |
| 0. | 1 Byte | Number of glyphs |
| 1. | 1 Byte | Bounding Box Mode (not relevant for decoding) |
| 2. | 1 Byte | m0 Bit width of Zero-Bit run-length encoding in bitmap |
| 3. | 1 Byte | m1 Bit width of One-Bit run-length encoding in bitmap |
| 4. | 1 Byte | Bit width of glyph bitmap width (bitcntW) |
| 5. | 1 Byte | Bit width of glyph bitmap height (bitcntH) |
| 6. | 1 Byte | Bit width of glyph bitmap x offset (bitcntX) |
| 7. | 1 Byte | Bit width of glyph bitmap y offset (bitcntY) |
| 8. | 1 Byte | Bit width of glyph character pitch, delta to next glyph (bitcntD) |
| 9. | 1 Byte | Font Bounding Box width |
| 10. | 1 Byte | Font Bounding Box height |
| 11. | 1 Byte | Font Bounding Box x Offset |
| 12. | 1 Byte | Font Bounding Box y Offset |
| 13. | 1 Byte | Ascent (size above baseline) of letter "A"
|
| 14. | 1 Byte | Descent (size below baseline) of letter "g" |
| 15. | 1 Byte | Ascent of "(" |
| 16. | 1 Byte | Descent of "(" |
| 17+18. | 2 Bytes | Array offset of glyph "A" |
| 19+20. | 2 Bytes | Array offset of glyph "a" |
| 21+22. | 2 Bytes | Array offset of glyph 0x0100 |