pub struct TextLayout { /* private fields */ }Expand description
A finished text layout: positioned glyph runs plus a cached measured size.
Produced by crate::TextContext::layout. It borrows nothing from the
context, so it can outlive the layout pass and be measured or converted to
scene runs on demand.
Implementations§
Source§impl TextLayout
impl TextLayout
Sourcepub fn size(&self) -> Size
pub fn size(&self) -> Size
The measured size (width x height) of the laid-out block.
Width is the longest line’s advance (bounded by the layout’s
max_width when one was given); height is the sum of line heights.
Sourcepub fn to_scene_runs(&self, origin: Point) -> Vec<GlyphRun>
pub fn to_scene_runs(&self, origin: Point) -> Vec<GlyphRun>
Converts the layout into frust_scene::GlyphRuns placed at origin.
See [crate::convert] for the coordinate convention. The origin-invariant
run construction (the parley walk) is memoized on first call and reused
across frames (see base_runs); each call re-applies
only the cheap origin translation onto the cached runs’ transforms.
A caller supplying its own run.brush after this call (a gradient
foreground, say) must resolve that brush’s geometry relative to
origin too — never as an already-window-space point. The render
backends apply a GlyphRun’s transform to its active paint, not
just its glyph outlines (vello’s Scene::draw_glyphs(..).transform(t)
composes t with the brush the same way it composes t with the
glyphs; vello_cpu’s set_transform likewise precedes set_paint),
so a brush baked with origin already added gets it added a second
time at paint time. Every other frust_scene::Command variant’s
origin/position argument does not auto-translate its brush this
way (see the frust-material gradient-button decoration’s own
PaintScene doc note) — this contract is specific to
frust_scene::Command::GlyphRun.