Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.
Directional runs of a line of text: the single-level core of UAX #9.
A label in a right-to-left screen is not simply "all right to left": a Latin or digit label reads left to right, an Arabic one right to left, and a mixed one is a sequence of runs. This module resolves that, with the rules that matter for a line of UI text and no explicit formatting (no embeddings, overrides or isolates):
- [
paragraph_dir]: the base direction is the direction of the first strong character (P2/P3); text without one takes the direction of the subtree. - [
runs]: the weak rules (W1-W7), the neutral rules (N1-N2) and the implicit levels (I1-I2) for one paragraph level, then the runs: maximal stretches of one level, in logical order. The direction a run is shaped in is its level's parity ([Run::dir]). - L1: a tab or a line break and the blanks before one (or before the end of the text) take the paragraph level, so a trailing space never sits inside a right-to-left run.
- [
visual_order]: the runs in visual order (L2): the sequences at the highest level and below are reversed down to the lowest odd level.
The runs are the unit: the shaper gets each one with its own direction, so the glyphs inside a run are already in visual order and the runs only need to be placed. The directional isolates LRI, RLI, FSI and PDI of a string are interpreted (X5a-X6a, any depth up to 62 levels deep; the content of an isolate is resolved as a paragraph of its own at the next level and the marks stay neutral in the text around it); the other explicit marks (LRE, RLE, LRO, RLO, PDF) are not.
Structs
structaster_blueprint::bidi::Run
pub struct Run { /* see fields */ }A run of text at one embedding level: its bytes and its level (odd is right to left, even left to right).
Public fields
| field | type | |
|---|---|---|
range | std::ops::Range<usize> | The byte range in the text. |
level | u8 | The resolved level: 0 or 2 read left to right, 1 right to left. |
Methods
fn dir(&self) -> Direction— The direction the run is shaped in.
Trait implementations: Clone, Debug, Eq, PartialEq, StructuralPartialEq
Functions
fnaster_blueprint::bidi::paragraph_dir
pub fn paragraph_dir(text: &str, fallback: layout::Direction) -> layout::DirectionThe base direction of a paragraph: the direction of its first strong
character (UAX #9 P2/P3); text with no strong character takes fallback.
fnaster_blueprint::bidi::runs
pub fn runs(text: &str, base: layout::Direction) -> Vec<Run>The runs of text for a paragraph of direction base, in logical order.
Text that cannot have a right-to-left character in a left-to-right paragraph is one run at level 0 (nothing is analysed). The empty text has no run.
fnaster_blueprint::bidi::single_run
pub fn single_run(text: &str, base: layout::Direction) -> Option<layout::Direction>The direction of the only run of text, when it has just one and nothing needs analysing
(no allocation: the hot path of left-to-right text). None: ask [runs].
fnaster_blueprint::bidi::visual_order
pub fn visual_order(levels: &[u8]) -> Vec<usize>The visual order of runs (L2): the indices into levels, left to right.