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§
Source§impl LayoutRun<'_>
impl LayoutRun<'_>
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.