Skip to main content

Module text

Module text 

Source
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.
LoadedFont
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_w and win_h are both > 0.0, labels with centered = true are repositioned to the centre of the viewport. clips maps 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 in build_text_calls. top_inset is the gap from the box top down to the text origin (the label’s y), which LayoutContainer uses to place the box. Returns None for a hidden label, or one with no font to draw with at all, so a LayoutContainer drops it and reserves no space.
text_advance_width
Advance width of content in scaled pixels for the given font, for placing a caret or sizing a field’s text. Newlines carry no advance.

Type Aliases§

FontMetrics
One face’s per-glyph metrics, keyed by Unicode code point.