pub struct TextLayout {
pub runs: Vec<GlyphRun>,
pub decos: Vec<Deco>,
pub lines: Vec<LineInfo>,
pub inner: Rect,
pub content_height: f64,
pub content_width: f64,
pub font_scale: f64,
pub line_reduction: f64,
pub overflow: bool,
pub rotation: f64,
pub para_lines: Vec<(usize, usize)>,
pub boundaries: Vec<Vec<bool>>,
}Fields§
§runs: Vec<GlyphRun>§decos: Vec<Deco>§lines: Vec<LineInfo>§inner: RectInner text box (insets applied), shape-local.
content_height: f64Height of the laid-out text (before anchoring).
content_width: f64Widest line.
font_scale: f64Autofit font scale used (1 = none).
line_reduction: f64§overflow: bool§rotation: f64Text rotation about the shape centre, degrees (vertical text = 90/270).
para_lines: Vec<(usize, usize)>Per paragraph: (first line index, line count).
boundaries: Vec<Vec<bool>>Per paragraph: whether a caret may stand at each character offset 0..=len (grapheme boundaries), for logical caret movement.
Implementations§
Source§impl TextLayout
impl TextLayout
Sourcepub fn line_of(&self, pos: Pos) -> Option<usize>
pub fn line_of(&self, pos: Pos) -> Option<usize>
The line containing a caret position (the later line at a soft wrap boundary).
Sourcepub fn line_of_affine(&self, pos: Pos, affinity: Affinity) -> Option<usize>
pub fn line_of_affine(&self, pos: Pos, affinity: Affinity) -> Option<usize>
The line containing a caret position: at a soft wrap boundary, the earlier line for an upstream caret and the later one for a downstream caret.
Sourcepub fn caret(&self, pos: Pos) -> Option<(f64, f64, f64)>
pub fn caret(&self, pos: Pos) -> Option<(f64, f64, f64)>
Caret line segment (x, top, bottom) in shape-local, unrotated coordinates (downstream).
Sourcepub fn caret_at(&self, pos: Pos, affinity: Affinity) -> Option<(f64, f64, f64)>
pub fn caret_at(&self, pos: Pos, affinity: Affinity) -> Option<(f64, f64, f64)>
Caret line segment (x, top, bottom) for a position and affinity: downstream at the leading edge of the character after the boundary, upstream at the trailing edge of the one before.
Sourcepub fn hit_affinity(&self, p: Point) -> (Pos, Affinity)
pub fn hit_affinity(&self, p: Point) -> (Pos, Affinity)
Nearest caret position for a point, with the affinity that keeps the caret on the side of the character that was hit (bidi text has two carets at a direction change).
Sourcepub fn move_caret(
&self,
pos: Pos,
affinity: Affinity,
forward: bool,
mode: MoveMode,
) -> (Pos, Affinity)
pub fn move_caret( &self, pos: Pos, affinity: Affinity, forward: bool, mode: MoveMode, ) -> (Pos, Affinity)
Move a caret one grapheme: logically (forward = towards the end of the text, crossing
paragraphs) or visually (forward = to the right on screen, continuing on the next or
previous line in the paragraph’s direction at the line’s edge).
Sourcepub fn selection_rects(&self, a: Pos, b: Pos) -> Vec<Rect>
pub fn selection_rects(&self, a: Pos, b: Pos) -> Vec<Rect>
Selection highlight rectangles between two positions: per line, the union of the visual boxes of the selected characters (one logical range can be several boxes in bidi text).
Sourcepub fn composition_underlines(&self, a: Pos, b: Pos) -> Vec<(f64, f64, f64)>
pub fn composition_underlines(&self, a: Pos, b: Pos) -> Vec<(f64, f64, f64)>
Underlines for text an input method is composing, from a to b (#101): (x0, x1, y) per
visual span, a little below each line’s baseline (PowerPoint underlines the composition
in place). A composition that wraps gets one underline per line.
Sourcepub fn vertical(&self, pos: Pos, down: bool, x: f64) -> Pos
pub fn vertical(&self, pos: Pos, down: bool, x: f64) -> Pos
Vertical caret movement: the position on the line above/below closest to x.
Sourcepub fn line_index(&self, pos: Pos, affinity: Affinity) -> Option<usize>
pub fn line_index(&self, pos: Pos, affinity: Affinity) -> Option<usize>
The line a caret is on. An upstream caret at the start of a soft-wrapped line (where End leaves it, after the previous line’s trailing spaces) belongs to the line before.
Sourcepub fn vertical_affine(
&self,
pos: Pos,
affinity: Affinity,
down: bool,
x: f64,
) -> (Pos, Affinity)
pub fn vertical_affine( &self, pos: Pos, affinity: Affinity, down: bool, x: f64, ) -> (Pos, Affinity)
Up/Down from a caret with its affinity: the position on the line above/below nearest x.
Sourcepub fn line_bounds(&self, pos: Pos) -> (Pos, Pos)
pub fn line_bounds(&self, pos: Pos) -> (Pos, Pos)
Start/end of the visual line containing pos (logical: Home/End).
Sourcepub fn line_bounds_affine(&self, pos: Pos, affinity: Affinity) -> (Pos, Pos)
pub fn line_bounds_affine(&self, pos: Pos, affinity: Affinity) -> (Pos, Pos)
Start/end of the visual line a caret with this affinity is on.
Sourcepub fn line_end_caret(&self, pos: Pos, affinity: Affinity) -> (Pos, Affinity)
pub fn line_end_caret(&self, pos: Pos, affinity: Affinity) -> (Pos, Affinity)
Where End puts the caret: after a soft wrap, past the line’s trailing spaces at the start of the next line with upstream affinity (so it is still drawn on this line), else the end of the paragraph.