Bidirectional text

From
Wikipedia:Bidirectional text
, is text that contains two text directionalities, right-to-left (RTL) and left-to-right (LTR).
Concepts
Text direction
while editing, setting text direction changes the interaction of the editor with the text. It affects text navigation, selection, and insertion.
Text alignment
a stylized form of presenting text. E.g: English text can be aligned to the right despite being LTR language, but this does not change the direction of the text which is LTR.
Fake Bidi
a fake locale displaying completely reversed English sentences to mimic a RTL context. This helps who are not familiar with RTL language to visualize RTL issues. For example:
This English sentence contains SDROW CIBARA EMOS and ends with English words.
Poor man's bidi mode
automatic visual text order right-to-left input in normal terminal.
Logical navigation
words are traversed as they are read.
Visual navigation
words are traversed as they are displayed.
This GIF
demonstrates the difference between the two.
Logical navigation is the correct way of navigation that programs should implement to fully support Bidi.
Unicode support
In Unicode-supported text editors, text direction can be controlled by inserting special formatting characters in front of it:
Wikipedia:RLM
(U+200F),
Wikipedia:LRM
(U+200E), which is a workaround for text editors not supporting switching text direction.
Bidirectional Algorithm
is the set of rules applied to display text in the correct order.
Support
In order for a program to fully support Bidi text, it must have:
Text shaping (RTL shaping)
correctly apply letter rendering and ligatures. See
Wikipedia:HarfBuzz
and
Wikipedia:Complex text layout
.
Unicode Bidirectional Algorithm (UBA)
determine the directionality of text segments and apply the appropriate rendering rules.
Editing and input (Nav)
the ability to force text direction and correct behavior of cursor movement, selection, deletion, and insertion (logical navigation).
Some implementations of UBA and letter-shaping:
fribidi
is an open source implementations of Bidi Algorithm.
python-bidi
AUR
is a python library for related functions.
SheenBidi
: Improved Unicode Implementation in C.
Browsers
App
RTL
UBA
Nav
Notes
chromium
Yes
No
No
firefox
Yes
No
No
qtwebbrowser
Yes
Yes
No
webkit
Yes
Yes
No
Editors
App
RTL
UBA
Nav
Notes
AbiWord
Yes
No
No
emacs
Yes
No
No
With
extension
. See also:
emacs bidi editing
.
gedit
Yes
Yes
No
For Gedit <= 2.1, workaround by
extension
.
ghostwriter
Yes
Yes
No
Qtwebbrowser-based
kate
Yes
Yes
No
LibreOffice
Yes
No
Yes
See:
LibreOffice#Bidirectional support
marktext
AUR
Yes
No
No
Blink-based
neovim
No
No
Yes
See
Vim#Bidirectional support
notepadqq
AUR
Yes
No
No
Won't fix.
texworks
Yes
Yes
No
vim
No
No
Yes
see
Vim#Bidirectional support
featherpad
Yes
Yes
No
Visual Studio Code
Yes
No
No
mousepad
Yes
Yes
No
pluma
Yes
Yes
No
GTK
Yes
Yes
No
xed
Yes
Yes
No
Terminal
VTE-based terminals
support special escape sequences that changes Bidi behavior. For example, to enable UBA support for command output, use
echo '\e[?2501h'
. For reading more about Bidi escaping sequences see
[1]
.
App
RTL
UBA
Nav
Notes
alacritty
No
No
No
Tested with
alacritty
version 0.13.0-3, the 2024-01-03. Does not support RLO (U+202E).
contour
No
No
No
Tested with
contour
version 0.3.12, the 2024-01-03. Does not support RLO (U+202E).
dvtm
No
No
No
extraterm
No
No
No
Tested with
extraterm-bin
AUR
version  0.74.0-1, the 2024-01-03. Does not support RLO (U+202E).
kitty
Yes
No
Tested with
kitty
version 0.31.0-1, the 2024-01-02. Does not support RLO (U+202E).
konsole
Yes
No
Tested with
konsole
version 23.08.4-2, the 2024-01-02.
libvte
Yes
No
including
libvte-based
like Gnome, sakura, xfce4, terminator... Minor issues:
1
mlterm
AUR
Yes
No
Tested with
mlterm
AUR
version 3.9.3-2, the 2024-01-03.
neatvi-git
AUR
No
pymux
No
qterminal
No
No
Tested with
qterminal
version 1.4.0-1, the 2024-01-02. Does not support RLO (U+202E).
radare2
No
Terminator
Yes
No
Tested with
terminator
version 2.1.3-3, the 2024-01-02.
tmux
No
Won't fix
Urxvt
No
No
Tested with
rxvt-unicode
version 9.31-4, the 2024-01-03. Does not support RLO (U+202E).
wezterm
No
xst
AUR
No
less
–
No
–
Other
App
RTL
UBA
Notes
electronjs
No
groff
No
No
irssi
No
latex
Yes
Yes
Using LuaTeX or XeLaTeX with polyglossia
Pandoc
Yes
No
typst
Yes
No
Wikipedia:HTML
Yes
Yes
wine
Yes
No
Troubleshooting
Verify
UTF-8 Encoding
is properly configured first. Make sure you install the
fonts
corresponding to your language:
Arabic
,
Persian
,
Hebrew
. For some terminals, (
bicon-git
AUR
) is required to properly display RTL text.
See also
Internal links
Locale
Localization
External links
freedesktop specification for Bidi support
:
terminal
.
Comprehensive guide of RTL styling in HTML