Expand description
Font atlas data and text draw-call assembly. No backend ownership; the renderer uploads the atlas textures; this module only builds the quad geometry from TextLabel components each frame.
Structs§
- FontSet
- The faces a frame draws with: every font loaded at init, keyed by handle, plus the face a label naming no font of its own falls back to.
- Loaded
Font - Per-font data kept in memory after init() so step() can build text quads each frame.
Functions§
- build_
text_ calls - Build one TextDrawCall per TextLabel, laying out character quads using the
loaded font metrics. When
win_wandwin_hare both > 0.0, labels withcentered = trueare repositioned to the centre of the viewport.clipsmaps an element id to a reference-space clip band; a label found there has its call scissored to that band (mapped to the window), so a scrollable panel’s off-band rows do not bleed over its chrome. - build_
text_ calls_ into build_text_calls, appending onto an existing draw list so a caller assembling a frame from several element groups reuses one buffer (and, in steady state, the pooled geometry of the spent frame it recycled).- derive_
cap_ px - Cap height (logical px) for vertical centering: the bearing of an uppercase reference glyph (‘H’), falling back to the tallest uppercase glyph, then to a fraction of the em when no metrics are available.
- measure_
label_ box - Measure a label’s background-box extent for layout: a box hugging the visible
glyphs grown by the label’s padding on every side, plus one line height per
extra
\n-split line. Mirrors the background-box math inbuild_text_calls.top_insetis the gap from the box top down to the text origin (the label’sy), whichLayoutContaineruses to place the box. ReturnsNonefor a hidden label, or one with no font to draw with at all, so aLayoutContainerdrops it and reserves no space. - text_
advance_ width - Advance width of
contentin scaled pixels for the given font, for placing a caret, sizing a field’s text, or centring a line. Newlines carry no advance, so a multi-line string measures as if its lines were concatenated. - widest_
line_ width - Width of the widest line of
contentin scaled pixels: what a label’s background box and its centre / right alignment are both sized against.
Type Aliases§
- Font
Metrics - One face’s per-glyph metrics, keyed by Unicode code point.