Skip to main content

TextLayout

Struct TextLayout 

Source
pub struct TextLayout<'a, Font: AbstractFont> {
    pub font: &'a Font,
    pub letter_spacing: Option<<Font as TextShaper>::Length>,
    pub line_height: Option<<Font as TextShaper>::Length>,
}

Fields§

§font: &'a Font§letter_spacing: Option<<Font as TextShaper>::Length>§line_height: Option<<Font as TextShaper>::Length>

The absolute line height, or None to use FontMetrics::height.

Implementations§

Source§

impl<Font: AbstractFont> TextLayout<'_, Font>

Source

pub fn half_leading(&self) -> Font::Length

The offset from the top of a line box to the top of the glyph box within it: half of the leading, following the CSS convention of centering the glyphs in the line box, like the parley based layout. Negative when the line height is smaller than the natural font height.

Source

pub fn cursor_band(&self) -> (Font::Length, Font::Length)

The origin (relative to the top of the line box) and height of cursor and selection rectangles: the full line box, but never smaller than the glyph box, mirroring parley’s clamping for negative leading.

Source

pub fn text_size( &self, text: &str, max_width: Option<Font::Length>, text_wrap: TextWrap, max_lines: Option<usize>, ) -> (Font::Length, Font::Length)
where Font::Length: Debug,

Source

pub fn content_widths( &self, text: &str, max_lines: Option<usize>, ) -> (Font::Length, Font::Length)
where Font::Length: Debug,

Auto Trait Implementations§

§

impl<'a, Font> Freeze for TextLayout<'a, Font>

§

impl<'a, Font> RefUnwindSafe for TextLayout<'a, Font>

§

impl<'a, Font> Send for TextLayout<'a, Font>
where &'a Font: Send, Option<<Font as TextShaper>::Length>: Send,

§

impl<'a, Font> Sync for TextLayout<'a, Font>
where &'a Font: Sync, Option<<Font as TextShaper>::Length>: Sync,

§

impl<'a, Font> Unpin for TextLayout<'a, Font>
where &'a Font: Unpin, Option<<Font as TextShaper>::Length>: Unpin,

§

impl<'a, Font> UnsafeUnpin for TextLayout<'a, Font>

§

impl<'a, Font> UnwindSafe for TextLayout<'a, Font>

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.