Skip to main content

TextLayout

Struct TextLayout 

Source
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

Source

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.

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.