Skip to main content

Module text_base_direction

Module text_base_direction 

Source
Expand description

The base direction of a text a user types: the direction its paragraph reads in, which decides where the text starts, where an empty field puts its caret, and which way a screen reader is told it runs.

A text input resolves it, every time it lays out, in this order:

  1. an explicit TextBaseDirection::LeftToRight or TextBaseDirection::RightToLeft, used as given;
  2. with TextBaseDirection::Auto (the default), the first strongly directional character of the text (UAX #9, rules P2 and P3): Arabic text reads right to left, Latin text left to right, whatever the window’s direction;
  3. when the text has none (it is empty, or only digits and punctuation), the content_language declared on or above the field, through LanguageTag::likely_direction;
  4. with no language declared, the window’s layout direction.

So an empty field declared Arabic opens with its caret on the right, and a field declared Japanese that holds Arabic text still reads right to left: the language never decides against the text. This is HTML’s dir="auto", falling back on the language before the surrounding direction.

Enums§

TextBaseDirection
Which way a typed text’s paragraph reads. See the module for how a text input resolves it.