Skip to main content

Module text

Module text 

Source
Expand description

Text element — renders text with template variable resolution, word wrapping, alignment, and colour mapping.

§Features

  • Template variable resolution via DataContext::resolve
  • Word wrapping when TextParams::wrap is true
  • Left / centre / right alignment within the element rect
  • Colour mapping from named ink-ramp strings and #RRGGBB hex literals

Functions§

align_offset
Compute horizontal tile offset for a given alignment.
parse_color
Parse a colour string to an Rgba.
render_text
Render a text element into the framebuffer via painter.
word_wrap
Word-wrap text to fit within max_chars per line, breaking at space boundaries when possible. Words longer than a line are hard-broken.
word_wrap_px
Word-wrap text to a pixel max_px width using the painter’s proportional font metrics (Painter::measure_text_px). Breaks at spaces where possible; a run wider than a line (e.g. CJK with no spaces) is split per-character by measured width. Explicit \n start new lines. Used by the proportional path.