Skip to main content

Module rtl

Module rtl 

Source
Expand description

Right-to-left text, as MapLibre GL JS draws it with the @mapbox/mapbox-gl-rtl-text plugin (0.3.0, ICU compiled to WebAssembly):

  • apply_arabic_shaping: ICU u_shapeArabic with U_SHAPE_LETTERS_SHAPE | U_SHAPE_TEXT_DIRECTION_LOGICAL. Arabic letters become their isolated / initial / medial / final presentation forms (U+FB50–U+FDFF, U+FE70–U+FEFC) from their neighbours’ joining types; lam + alef becomes one ligature (the text shrinks); tashkeel are transparent and take their own isolated or medial forms. Applied to every label after text-transform.
  • process_bidi: ICU ubidi with a default-LTR paragraph level. Lines are broken on the logical text first; each line is then reordered for display (UAX #9 with bracket pairs, rule L1 for trailing whitespace), right-to-left runs reversed with mirrored brackets, and bidi controls removed (UBIDI_DO_MIRRORING | UBIDI_REMOVE_BIDI_CONTROLS).

The shaping tables and the joining walk are ported from ICU’s ushape.cpp (© Unicode, Inc. and others, Unicode License); the mirroring pairs are BidiMirroring.txt (Unicode 15).

Functions§

apply_arabic_shaping
The plugin’s applyArabicShaping (ushape_arabic).
is_rtl_char
A character of a right-to-left script (Hebrew, Arabic, Syriac, Thaana, NKo, Samaritan, Mandaic and their presentation forms).
process_bidi
The plugin’s processBidirectionalText: chars in logical order with line breaks (char indices, the last one the text length) chosen on it; returns each line in visual order. Paragraph ends (after a paragraph separator) are merged into the breaks as the plugin does.