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.
Auto Trait Implementations§
impl !Freeze for TextLayout
impl !RefUnwindSafe for TextLayout
impl !Sync for TextLayout
impl !UnwindSafe for TextLayout
impl Send for TextLayout
impl Unpin for TextLayout
impl UnsafeUnpin for TextLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.