JFLib

text/bidi.rs#

Source: lib/text/bidi.rs

bidi -- lines with right-to-left characters in their visual order, also without set_shaping

  has_rtl(s)                       s has right-to-left characters (what set_bidi lays out)
  set_bidi(on) -> previous         (default on) a line with right-to-left characters (Hebrew,
                                   Arabic, Syriac, Thaana, N'Ko, ... or the marks RLM, RLE,
                                   RLO, RLI) is laid out by the Unicode bidi algorithm while
                                   shaping is off; off: every line in logical order (text
                                   that is in visual order already)

The line's directional runs come in visual order (text_shape::visual_runs; the line's
direction is that of its first strong character).  A right-to-left run's characters from a
TrueType / OpenType font (the fallback font of Hebrew or Arabic, usually) are shaped with
it (HarfRust: Arabic joining, marks, ligatures, mirrored brackets); the others are drawn
one grapheme cluster after the other as run draws them, right to left, brackets mirrored.
Left-to-right runs are drawn as run draws them.  Draw, measure, caret_x, hit and
selection_spans all read the same layout (shaping.rs: the line laid out last, with the 128
bidi lines before it).  Lines without right-to-left characters keep run's metrics and
pixels.
  • fn has_rtl(s: &[u8]) -> bool Whether s has right-to-left characters (Hebrew, Arabic, ... or the marks RLM, RLE, RLO, RLI): a line with them is laid out in its visual order (set_bidi). Views that place their carets by logical prefixes draw such text cluster by cluster to keep the logical order.

impl Text

  • fn set_bidi(&mut self, on: bool) -> bool Lay out lines with right-to-left characters in their visual order while shaping is off (default on). Returns the previous state.

Source: docs/API.md in the JFLib repository.