Files
forgotten_caves/notes/04-text_renderer.md
T
irrlichtandClaude Opus 5 bb12f095d8 Add bitmap font, UI primitives and a HUD with message log
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>
2026-09-20 17:31:17 +02:00

22 lines
1017 B
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 (`A` at 65 → column 1,
row 2). Loaded with `Image::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. `draw` crops 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_width` and `wrap` (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.