Skip to main content

LayoutCtx

Struct LayoutCtx 

Source
pub struct LayoutCtx<'a> { /* private fields */ }
Expand description

Borrowed text system used by layout code to shape and measure text.

Measurements are not cached here; the underlying TextSystem owns any caching that may occur.

Implementations§

Source§

impl<'a> LayoutCtx<'a>

Source

pub fn new(text: &'a mut TextSystem, default_font_size: f32) -> LayoutCtx<'a>

Creates a context that borrows text and uses default_font_size for callers that do not specify a size.

Source

pub fn default_font_size(&self) -> f32

Returns the default font size for this layout pass.

Source

pub fn text_width(&mut self, text: &str, size: f32) -> f32

Measures the width of a single line of text.

Source

pub fn text_width_weighted( &mut self, text: &str, size: f32, weight: FontWeight, ) -> f32

Measures the width of a single line using the given font weight.

Source

pub fn text_width_spaced(&mut self, text: &str, size: f32, spacing: f32) -> f32

Measures the width of a single line with letter spacing.

Source

pub fn text_width_weighted_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, ) -> f32

Measures the width of a single line with weight and letter spacing.

Source

pub fn text_width_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, family: Option<&str>, style: FontStyle, ) -> f32

Measures the width of a single line with weight, spacing, family, and style.

Source

pub fn caret_positions( &mut self, text: &str, size: f32, weight: FontWeight, ) -> Vec<f32>

Returns caret positions along a single line of text.

Source

pub fn caret_positions_spaced( &mut self, text: &str, size: f32, weight: FontWeight, spacing: f32, ) -> Vec<f32>

Returns caret positions along a single line with letter spacing.

Source

pub fn text_wrapped_size( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, ) -> Size

Measures wrapped text within width, returning its size.

Source

pub fn text_wrapped_size_spaced( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: f32, ) -> Size

Measures wrapped text within width with letter spacing.

Source

pub fn text_wrapped_size_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, width: f32, mode: WrapMode, spacing: f32, family: Option<&str>, style: FontStyle, ) -> Size

Measures wrapped text with weight, spacing, family, and style.

Source

pub fn text_elided_size( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, ) -> Size

Measures text elided to max_width with the given elision mode.

Source

pub fn text_elided_size_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: f32, ) -> Size

Measures elided text with letter spacing.

Source

pub fn text_elided_size_styled_spaced( &mut self, text: &str, size: f32, weight: FontWeight, max_width: f32, mode: ElideMode, spacing: f32, family: Option<&str>, style: FontStyle, ) -> Size

Measures elided text with weight, spacing, family, and style.

Source

pub fn text_line_height(size: f32) -> f32

Returns the line height used for a font size.

Source

pub fn rich_size( &mut self, spans: &[TextSpan], size: f32, width: f32, mode: WrapMode, spacing: f32, align: RichAlign, ) -> Size

Measures rich text spans, returning their shaped size.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for LayoutCtx<'a>

§

impl<'a> !Send for LayoutCtx<'a>

§

impl<'a> !Sync for LayoutCtx<'a>

§

impl<'a> !UnwindSafe for LayoutCtx<'a>

§

impl<'a> Freeze for LayoutCtx<'a>

§

impl<'a> Unpin for LayoutCtx<'a>

§

impl<'a> UnsafeUnpin for LayoutCtx<'a>

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> 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.