libepaper 2.0.0
A C++23 library for controlling Waveshare e-paper displays on Raspberry Pi, featuring transparent sleep/wake management and a fluent builder API.
Loading...
Searching...
No Matches
Classes | Namespaces
font.hpp File Reference

Bitmap font rendering for e-paper displays. More...

#include <cstddef>
#include <cstdint>
#include <span>
Include dependency graph for font.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  epaper::FontMetrics
 Font dimension metrics. More...
 
class  epaper::Font
 

Namespaces

namespace  epaper
 

Detailed Description

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:

Usage Patterns:

// Using built-in fonts
const Font& f = Font::font16();
display.draw(display.text("Hello").at({10,10}).font(&f).build());
// Custom font from external data
extern const uint8_t my_font_data[];
Font custom_font{my_font_data, 16, 20}; // 16px wide, 20px tall

Text Rendering Process:

  1. TextCommand specifies string and font
  2. Graphics::draw_text() iterates characters
  3. Font::char_data() retrieves bitmap for each char
  4. Bitmap bits decoded MSB-first, drawn as pixels

Limitations:

See also
Graphics::draw_text(), TextCommand, FontMetrics