Ports the CP437 font renderer from wds to the framebuffer: proportional advance from measured ink bounds, luminance-keyed mask, word wrap. The right 80 px strip becomes a HUD with name, HP bar, population and a log fed from sim events; Attacked/Died now carry the type ids the log needs, since the victim is gone from the world by the time events are read. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1017 B
Executable File
1017 B
Executable File
Text Renderer
Current state
game/src/font.rs — a CP437 bitmap font ported from the wds project.
- Atlas: 32 columns × 8 rows of fixed cells, codepoint = index (
Aat 65 → column 1, row 2). Loaded withImage::from_png; the mask is derived from luminance (white on black), so the caller paints glyphs in any RGB565 color. - Proportional advance: on load the ink span of every glyph (leftmost/rightmost lit
column) is measured.
drawcrops to that span and advances by ink width + 1 px tracking; blank glyphs (space) advance half a cell. cp437(char)maps ASCII 1:1 and the accented letters the atlas has (ä ö ü ß …); everything else becomes?.text_widthandwrap(word wrap with hard\n) for layout.- Font in use:
assets/fonts/cga-8x8.png(Oldschool PC Font Pack, CGA 8×8).
Open questions
- A second, smaller or larger font (the EGA 8×14 from
wds) once the UI needs hierarchy. - Text color per span / inline markup for the log — not before it is needed.