Struct LayoutRun
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: usizeThe index of the original text line
text: &'a strThe original text line
rtl: boolTrue 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: f32Y offset to baseline of line
line_top: f32Y offset to top of line
line_height: f32Y offset to next line
line_w: f32Width of line
Implementations§
§impl LayoutRun<'_>
impl LayoutRun<'_>
pub fn highlight(
&self,
cursor_start: Cursor,
cursor_end: Cursor,
) -> impl Iterator<Item = (f32, f32)>
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.
pub fn cursor_position(&self, cursor: &Cursor) -> Option<f32>
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.
pub fn cursor_glyph(&self, cursor: &Cursor) -> Option<(usize, f32)>
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.
pub const fn cursor_from_glyph_left(&self, glyph: &LayoutGlyph) -> Cursor
pub const fn cursor_from_glyph_left(&self, glyph: &LayoutGlyph) -> Cursor
Get the left-edge cursor position of a glyph, accounting for paragraph direction.
pub const fn cursor_from_glyph_right(&self, glyph: &LayoutGlyph) -> Cursor
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§
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> UnsafeUnpin for LayoutRun<'a>
impl<'a> UnwindSafe for LayoutRun<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more