pub struct VisualLine {
pub visual: Vec<char>,
pub logical_to_visual: Vec<usize>,
pub visual_to_logical: Vec<usize>,
pub base_level: u8,
}Expand description
The visual-order result of driving the full UAX #9 §3 + §3.4 bidirectional pipeline over one display line.
A renderer that wants correct bidirectional text walks
VisualLine::visual left-to-right (the natural rendering
direction of the output device), feeding each character to the
shaper / cmap and laying the glyphs out in increasing x. The
per-character permutation VisualLine::logical_to_visual and its
inverse VisualLine::visual_to_logical let the caller map a
visual glyph back to its source character (cursor hit-testing,
selection-rectangle building) and vice versa.
visual already has rule L4 mirroring applied — every
character whose resolved level is odd (right-to-left) and that has
a Bidi_Mirroring_Glyph pair (a bracket, an angle quotation mark,
a mathematical relation, …) is the mirrored code point, not the
logical one — so the renderer must not mirror again.
Fields§
§visual: Vec<char>The line’s characters in left-to-right visual order, with L4
mirroring applied. visual.len() equals the line’s character
count.
logical_to_visual: Vec<usize>Permutation entry k is the logical index of the character
that belongs at visual position k (the UAX #9 §3.4 L2
output). visual[k] is the L4-mirrored form of the logical
character at index logical_to_visual[k].
visual_to_logical: Vec<usize>The inverse permutation: entry i is the visual position of
the character whose logical index is i. Equivalent to
inverting Self::logical_to_visual; precomputed for
O(1) logical-to-visual hit-testing.
base_level: u8The paragraph embedding level resolved by P2 / P3 (or supplied
by the caller as the HL1 override). 0 for an LTR line, 1
for an RTL line.
Implementations§
Source§impl VisualLine
impl VisualLine
Sourcepub fn to_visual_string(&self) -> String
pub fn to_visual_string(&self) -> String
Collect Self::visual into a String — the line in the
order a left-to-right renderer paints it.
Trait Implementations§
Source§impl Clone for VisualLine
impl Clone for VisualLine
Source§fn clone(&self) -> VisualLine
fn clone(&self) -> VisualLine
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VisualLine
impl Debug for VisualLine
impl Eq for VisualLine
Source§impl PartialEq for VisualLine
impl PartialEq for VisualLine
Source§fn eq(&self, other: &VisualLine) -> bool
fn eq(&self, other: &VisualLine) -> bool
self and other values to be equal, and is used by ==.