feat(text): optional vendored stb_truetype backend for runtime external fonts

This commit is contained in:
Martino Ferrari committed 2026-09-28 16:07:27 +02:00
1 parent daff60e3f0
commit 14d664a246
12 files changed
+6511 -19

No files matched your search

+11 -5
View File
@@ -8,11 +8,11 @@ namespace plot::render {
/// The renderer's built-in text backend: an anti-aliased greyscale atlas of
/// Adwaita Mono, baked at authoring time and committed as data.
///
/// There is no font file, FreeType or stb_truetype behind this: the coverage
/// bytes and the glyph table are generated by `tools/fonts/gen_atlas.py` into
/// `src/render/embedded_mono_font.cpp`, so `plot_core` stays dependency-free and
/// nothing rasterises at build or run time. That file carries the provenance --
/// source face, its version, the em size, the supersample factor and the
/// There is no font file, FreeType or third-party rasteriser behind this: the
/// coverage bytes and the glyph table are generated by `tools/fonts/gen_atlas.py`
/// into `src/render/embedded_mono_font.cpp`, so `plot_core` stays dependency-free
/// and nothing rasterises at build or run time. That file carries the provenance
/// -- source face, its version, the em size, the supersample factor and the
/// coverage set -- and `gen_atlas.py --check` fails if it has drifted from its
/// input. Adwaita Mono is SIL OFL 1.1 (a copy is committed at
/// `licences/OFL-1.1.txt`); the class is named neutrally because OFL reserves
@@ -27,6 +27,12 @@ namespace plot::render {
///
/// A codepoint outside the coverage set draws the baked fallback box, so a label
/// the atlas cannot spell is visible rather than silently blank.
///
/// This is the only backend the core library ships. The one that bakes a font
/// file at run time belongs to the optional target -- `plot/text/true_type_font.hpp`,
/// deliberately not part of `include/plot/plot.hpp` -- and no public header
/// outside `plot/text/` names what rasterises it, which is the isolation that
/// target exists to keep.
class EmbeddedMonoFont final : public TextBackend {
public:
/// The size the atlas was baked at, in font pixels, and the coverage samples