I want to know about the mechanism of (Converting LTR to RTL)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mo1998

there issues will add meaningful to my question

:bust_in_silhouette: Reply From: bruvzg

Basic workflow is following:

  1. Use Unicode BiDi algorithm to split text into direction runs and get order of the runs. (implementation provided by ICU)
  2. Split text by script (using parts of Unicode text segmentation rules and ICU UCDN).
  3. Optionally split text by language (user supplied), and if your text uses multiple fonts or associated OpenType features also split by these.
  4. Reorder resulting monotone runs according to BiDi order (see 1).
  5. Send each monotone run to the shaper HarfBuzz (for TrueType/OpenType fonts or fallback shaping of bitmap fonts) or/and Graphite (for SIL smart fonts).
  6. Render text using glyph indices, offsets and advances returned by HarfBuzz.

You can find more information on various aspects of #21791 implementation (specifically first 4 documents) and set of potentially useful links (APIs, other implementation, general articles related to topic) at https://bruvzg.github.io/gdtl_docs/

PR #21791 have BiDi text rendering, line breaking (using ICU break-iterators and dictionaries), justification (space and kashida elongation) implemented. Integration of BiDi rendering/input into complex controls is incomplete (Label and LineEdit have some work done but quite buggy, multiline text and rich text controls are not touched).

There’s also stand-alone implementation of #21791 with some additional stuff, a bit smarter font fallback (font substitution based on run script) and rich text input control demo (as new base control, with limited capabilities): GitHub - bruvzg/godot_tl: BiDi, shaping and basic text layout for Godot Engine