Text
ANVL ships its own fonts and its own glyph atlas, so text looks the same on every device. Shaping is cached: a string is shaped once and drawn from the cache after that.

Fonts
| Role | Font | Use |
|---|---|---|
FontRole::Ui | Inter (Regular, Medium, SemiBold, Italic) | Interface text: labels, buttons, titles. The default. |
FontRole::Body | Noto Sans (Regular, Medium), on a 1.5 line | Paragraphs and long reading text. |
FontRole::Mono | Fira Mono Medium | Code and aligned figures. |
The fonts are compiled into the binary and read in place, so they cost about 0.4 MB of memory
and the system's fonts are never picked by mistake. Weights are CSS numbers:
WEIGHT_REGULAR (400), WEIGHT_MEDIUM (500) and WEIGHT_SEMIBOLD
(600, for display sizes).
Text in elements
In an element tree, use text("…") with .body(), .heading(),
.title(), .caption(), .label(), .medium(),
.semibold(), .mono(), .italic(), .nowrap(),
.color(…) and .text_size(px). Size and color inherit from parents. Text
wraps to the width it gets and measures its own height. See
Text builders.
TextStyle
Immediate-mode text takes a TextStyle:
let style = TextStyle::new(15.0, ui.theme().text).medium();
let w = ui.text(x, y, "Saved", style); // returns its width
ui.text_fit(x, y, &title, style, max_w); // one line, ellipsized
let h = ui.text_wrapped(x, y, max_w, ¶graph, TextStyle::new(15.0, ui.theme().text).body());
ui.text_center(button_rect, "OK", style);
Builders: .medium(), .semibold(), .body(),
.mono(), .italic(). Sizes are logical pixels; positions are physical.
Measuring
ui.text_width(content, style): the width of one line.ui.measure(content, style) -> (key, size)andmeasure_wrapped(content, style, max_w): the size, and a key to draw the same shaping again.ui.fit_text(content, style, max_w) -> String: the string ellipsized to fit.
Rules ADL follows
- Single-line text that does not fit ends in an ellipsis. It never overflows its box.
- Paragraphs wrap at word boundaries; a word too long for a line breaks by character.
- Every text run is clipped to its container.