class

Egui::Fonts

Inherits Reference < Object

Constants

LAYOUT_CACHE_MAX = 8

Memoized layouts (upstream caches galleys in Fonts too): a widget re-layouts its text every frame, which is fine for labels but pins a textarea with a multi-megabyte buffer to a full re-wrap (measure per word) at every frame. Keys compare by String identity first (== short-circuits on the same object), so an unchanged buffer hits in O(1). Small MRU ring — enough for the handful of texts on screen at one size and wrap width.

LINE_H_FACTOR = 1.3

Estimated line height as a font-size factor (matches MonospaceFonts; used by containers that need a row height before measuring).

Instance methods

fit(text : String, size : Float64, max_width : Float64) : String

Truncate text with an ellipsis so it measures at most max_width (upstream's galley truncation). Returns the text unchanged when it already fits, "…" when only the ellipsis fits, "" when not even that does. Binary-searches the prefix length through measure_cached, so a squeezed widget pays O(log n) measures.

Source
layout(runs : Array(TextRun), max_width : Float64 | Nil = nil, resolve : String | Nil, Bool, Bool -> Fonts | Nil = nil) : Galley

Lay styled runs out into rows. max_width nil = never wrap. resolve maps a run's family + bold/italic flags to its font stack (a Context#fonts_for closure) so runs tagged with another family (inline monospace code) or a real variant face MEASURE through that stack; nil measures everything through self (the historical behavior — fine when no run carries a family/variant).

Source
measure(text : String, size : Float64) : Vec2
Source
measure_cached(text : String, size : Float64) : Vec2

Memoized measure for STATIC text (label-like widgets — see AtlasFonts#measure_cached for the cache design). The base class and every non-AtlasFonts backend just measure; only the real font stacks gain a cache, so headless specs see identical behavior either way.

Source
source_path

Source font FILE this stack was built from (nil for synthetic stacks) — Context#primary_family_name reads the weight axis family through it. Set by the backends' from_system builders.

Source
source_path=(source_path : String | Nil)

Source font FILE this stack was built from (nil for synthetic stacks) — Context#primary_family_name reads the weight axis family through it. Set by the backends' from_system builders.

Source