Skip to main content

TextLayoutResult

Struct TextLayoutResult 

Source
pub struct TextLayoutResult {
    pub line_count: usize,
    pub width_px: f32,
    pub height_px: f32,
    pub first_baseline: f32,
    pub last_baseline: f32,
    pub did_overflow_width: bool,
    pub did_overflow_height: bool,
    pub lines: Vec<TextLineInfo>,
}
Expand description

Result of text layout computation, provided to the on_text_layout callback. Exposes key information about the rendered text layout.

Fields§

§line_count: usize

Number of visual lines in the layout.

§width_px: f32

Total content width in px.

§height_px: f32

Total content height in px.

§first_baseline: f32

First baseline position in px.

§last_baseline: f32

Last baseline position in px.

§did_overflow_width: bool

Whether text overflows the available width.

§did_overflow_height: bool

Whether text overflows the available height.

§lines: Vec<TextLineInfo>

Per-line layout information.

Implementations§

Source§

impl TextLayoutResult

Source

pub fn get_line_start(&self, line_index: usize) -> Option<usize>

Source

pub fn get_line_end(&self, line_index: usize) -> Option<usize>

Source

pub fn get_line_end_visible(&self, line_index: usize) -> Option<usize>

Source

pub fn is_line_ellipsized(&self, _line_index: usize) -> bool

Source

pub fn get_line_top(&self, line_index: usize) -> Option<f32>

Source

pub fn get_line_baseline(&self, line_index: usize) -> Option<f32>

Source

pub fn get_line_bottom(&self, line_index: usize) -> Option<f32>

Source

pub fn get_line_left(&self, line_index: usize) -> Option<f32>

Source

pub fn get_line_right(&self, line_index: usize) -> Option<f32>

Source

pub fn get_line_for_offset(&self, offset: usize) -> usize

Source

pub fn get_line_for_vertical_position(&self, vertical: f32) -> usize

Source

pub fn get_horizontal_position( &self, offset: usize, _use_primary_direction: bool, ) -> f32

Source

pub fn has_visual_overflow(&self) -> bool

Returns true if the text has visual overflow in either direction.

Source

pub fn get_bounding_box(&self, offset: usize) -> Rect

Returns the bounding box of the character at the given offset. Returns a zero rect if the offset is out of range.

Source

pub fn get_cursor_rect(&self, offset: usize) -> Rect

Returns the cursor rectangle at the given offset.

Source

pub fn get_offset_for_position(&self, position: (f32, f32)) -> Option<usize>

Returns the offset closest to the given position.

Source

pub fn get_word_boundary(&self, _offset: usize) -> TextRange

Returns the text range of the word at the given offset.

Source

pub fn get_paragraph_direction(&self, _offset: usize) -> u8

Returns the paragraph direction at the given offset.

Source

pub fn get_bidi_run_direction(&self, _offset: usize) -> u8

Returns the BiDi run direction at the given offset.

Trait Implementations§

Source§

impl Clone for TextLayoutResult

Source§

fn clone(&self) -> TextLayoutResult

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextLayoutResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.