Expand description
Bitmap glyph fonts and CP437 mapping, shared by retroglyph’s graphical backends.
A BitmapFont holds a static 1-bit-per-pixel glyph table. Each glyph is stored as
glyph_height bytes, one byte per row, MSB = leftmost pixel. For the standard 8-pixel-wide
VGA format one byte covers all 8 pixels of a row; wider fonts would need two bytes per row,
but that is not yet supported.
This module is the dependency-free glyph-source layer both retroglyph-software (CPU
rasterizer) and retroglyph-gl (GPU atlas) build on, so their text output stays
pixel-identical. It lives here (rather than in a standalone crate) because both consumers
already depend on retroglyph-window for Presenter, and it needs none of
winit: it is available with default-features = false. Enable the default-font feature for
the embedded Unscii 16 font (unscii16::FONT); leave it off to supply your own via
BitmapFont::new.
§Future work
-
Expanded glyph cache: For wider fonts (>8px), consider pre-computing expanded scanlines to avoid per-frame bit extraction. Currently the bit extraction loop is not a bottleneck for 8px-wide fonts at typical grid sizes, but wider fonts (10px, 16px) would benefit from caching.
-
Wider glyphs: To support glyphs wider than 8px, change
BitmapFont::rowsto returnceil(glyph_width / 8)bytes per row and update the consumers’ bit extraction to index across bytes. Tracked in retroglyph issue #164; deferred until a second, non-8px-wide font is actually needed.
Modules§
- legacy_
computing - Generated fallback
BitmapFonts, embedded when thelegacy-computingfeature is enabled. - unscii16
- The Unscii 16 font, embedded when the
default-fontfeature is enabled.
Structs§
- Bitmap
Font - A 1-bit-per-pixel bitmap glyph font.
- Font
Chain - The glyph source a backend draws from: a primary
BitmapFontplus an ordered list of fallback fonts. - Resolved
Glyph - A glyph resolved from a
FontChain: the glyph index plus the specificBitmapFontit came from, since each font in a chain owns its own bitmap data.