Function unicode_bidi::visual_runs_for_line
source ยท pub(crate) fn visual_runs_for_line(
levels: Vec<Level>,
line: &Range<usize>,
) -> (Vec<Level>, Vec<LevelRun>)
Expand description
Find the level runs within a line and return them in visual order.
line
is a range of code-unit indices within levels
.
The first return value is a vector of levels used by the reordering algorithm, i.e. the result of Rule L1. The second return value is a vector of level runs, the result of Rule L2, showing the visual order that each level run (a run of text with the same level) should be displayed. Within each run, the display order can be checked against the Level vector.
This does not handle Rule L3 (combining characters) or Rule L4 (mirroring), as that should be handled by the engine using this API.
Conceptually, this is the same as running [reordered_levels()
] followed by
reorder_visual()
, however it returns the result as a list of level runs instead
of producing a level map, since one may wish to deal with the fact that this is operating on
byte rather than character indices.
http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels