Bitmap font rendering for e-paper displays.
Provides fixed-width bitmap font support using Waveshare font format. Fonts are stored as packed bitmap arrays with MSB-first encoding.
Font Format Specification:
Waveshare Bitmap Font Format
├─ Fixed-width: All characters same dimensions (width × height)
├─ ASCII Range: 0x20 (space) to 0x7E (tilde) = 95 printable characters
├─ Bitmap Layout: Row-major, MSB-first bit packing
└─ No Kerning: Characters placed at fixed intervals
Bitmap Encoding:
Character 'A' (8×12 font):
Row 0: [76543210] ← MSB is leftmost pixel
Row 1: [76543210]
...
Row 11: [76543210]
Total bytes = ceil(width/8) × height
Example: 8×12 → 1 byte/row × 12 rows = 12 bytes
12×16 → 2 bytes/row × 16 rows = 32 bytes
Memory Layout:
Font table array:
[Char_0x20][Char_0x21][Char_0x22]...[Char_0x7E]
↓ ↓ ↓ ↓
Space '!' '"' '~'
Each character occupies bytes_per_char() bytes sequentially.
Built-in Fonts:
- font8(): 8×8 pixels - Small, compact (terminals, labels)
- font12(): 12×12 pixels - Medium (body text)
- font16(): 16×16 pixels - Large (headers, important text)
- font20(): 20×20 pixels - Extra large (titles)
- font24(): 24×24 pixels - Display headers
Usage Patterns:
const Font& f = Font::font16();
display.draw(display.text("Hello").at({10,10}).font(&f).build());
extern const uint8_t my_font_data[];
Font custom_font{my_font_data, 16, 20};
Text Rendering Process:
- TextCommand specifies string and font
- Graphics::draw_text() iterates characters
- Font::char_data() retrieves bitmap for each char
- Bitmap bits decoded MSB-first, drawn as pixels
Limitations:
- No variable-width fonts (monospaced only)
- No Unicode support (ASCII 0x20-0x7E only)
- No anti-aliasing (1-bit bitmaps)
- No font scaling (use different size fonts)
- See also
- Graphics::draw_text(), TextCommand, FontMetrics