pub struct ShapedLineLayout {
pub rtl: bool,
pub line_width: f32,
pub clusters: Vec<VisualGraphemeCluster>,
}Expand description
Shaped single-line BiDi layout containing visual left-to-right grapheme cluster geometry.
Fields§
§rtl: booltrue when the resolved Unicode BiDi paragraph direction is RTL.
line_width: f32Total visual advance width of the line in logical pixels (including trailing spaces).
clusters: Vec<VisualGraphemeCluster>Grapheme clusters ordered left-to-right by visual X coordinate.
Implementations§
Source§impl ShapedLineLayout
impl ShapedLineLayout
Sourcepub fn caret_x_at(&self, text: &str, byte_index: usize) -> f32
pub fn caret_x_at(&self, text: &str, byte_index: usize) -> f32
Maps a logical UTF-8 byte offset (clamped to a UAX #29 grapheme boundary) to its visual caret X offset in logical pixels relative to line origin.
At LTR/RTL run boundaries, paragraph-direction-matching clusters take precedence so caret motion remains monotonic within every run.
Sourcepub fn hit_test_x(&self, text: &str, local_x: f32) -> usize
pub fn hit_test_x(&self, text: &str, local_x: f32) -> usize
Hit-tests a visual local_x (logical pixels from line origin) into the closest valid
UAX #29 logical grapheme byte boundary.
Sourcepub fn selection_spans_for_range(
&self,
text: &str,
start: usize,
end: usize,
) -> Vec<(f32, f32)>
pub fn selection_spans_for_range( &self, text: &str, start: usize, end: usize, ) -> Vec<(f32, f32)>
Computes visual (x_left, width) selection spans for logical range start..end.
Pure LTR/RTL selections produce one contiguous span; mixed BiDi selections that cross an LTR/RTL reversal produce disjoint visual spans ordered left-to-right.