LayoutRun

Struct LayoutRun 

Source
pub struct LayoutRun<'a> {
    pub line_i: usize,
    pub text: &'a str,
    pub rtl: bool,
    pub glyphs: &'a [LayoutGlyph],
    pub decorations: &'a [DecorationSpan],
    pub line_y: f32,
    pub line_top: f32,
    pub line_height: f32,
    pub line_w: f32,
}
Expand description

A line of visible text for rendering

Fields§

§line_i: usize

The index of the original text line

§text: &'a str

The original text line

§rtl: bool

True if the original paragraph direction is RTL

§glyphs: &'a [LayoutGlyph]

The array of layout glyphs to draw

§decorations: &'a [DecorationSpan]

Text decoration spans covering ranges of glyphs

§line_y: f32

Y offset to baseline of line

§line_top: f32

Y offset to top of line

§line_height: f32

Y offset to next line

§line_w: f32

Width of line

Implementations§

Source§

impl LayoutRun<'_>

Source

pub fn highlight( &self, cursor_start: Cursor, cursor_end: Cursor, ) -> impl Iterator<Item = (f32, f32)>

Return an iterator of (x_left, x_width) pixel spans for the highlighted areas between cursor_start and cursor_end within this run.

For pure LTR or pure RTL runs this yields at most one span. For mixed BiDi runs (where selected and unselected glyphs interleave visually) it yields multiple disjoint spans.

Returns an empty iterator if the cursor range does not intersect this run.

Source

pub fn cursor_position(&self, cursor: &Cursor) -> Option<f32>

Returns the visual x position (in pixels) of cursor within this run, or None if the cursor does not belong to this run.

For RTL glyphs the cursor is placed at the right edge minus the offset; for LTR glyphs it is placed at the left edge plus the offset.

Source

pub fn cursor_glyph(&self, cursor: &Cursor) -> Option<(usize, f32)>

Find which glyph in this run contains cursor, returning (glyph_index, pixel_offset_within_glyph), or None if the cursor is not on this run.

Source

pub const fn cursor_from_glyph_left(&self, glyph: &LayoutGlyph) -> Cursor

Get the left-edge cursor position of a glyph, accounting for paragraph direction.

Source

pub const fn cursor_from_glyph_right(&self, glyph: &LayoutGlyph) -> Cursor

Get the right-edge cursor position of a glyph, accounting for paragraph direction.

Trait Implementations§

Source§

impl<'a> Debug for LayoutRun<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LayoutRun<'a>

§

impl<'a> RefUnwindSafe for LayoutRun<'a>

§

impl<'a> Send for LayoutRun<'a>

§

impl<'a> Sync for LayoutRun<'a>

§

impl<'a> Unpin for LayoutRun<'a>

§

impl<'a> UnwindSafe for LayoutRun<'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 = 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.