Bidirectional text in TRichView

<< Click to display table of contents >>

Bidirectional text in TRichView

Bidirectional mode specifies the reading order of text, order of items in lines, and placement of a vertical scrollbar.

The support for bidirectional text (Arabic or Hebrew) is turned off by default. In order to turn it on, set BiDiMode property of TRichView either to rvbdLeftToRight or to rvbdRightToLeft.

BiDiMode of document can be overridden by BiDiMode of paragraph, BiDiMode of paragraph can be overridden by BiDiMode of text item.

Mixed right-to-left and left-to-right text is supported, even inside the same text item.

Attaching of adjacent characters (common for Arabic languages) is supported too, but only inside the same item (not between items).

Bullets and numbering of paragraphs take BiDiMode into account: for RTL (right-to-left) paragraphs, list markers are positioned to the right.

Tab stops support BiDiMode too: they are inverted (including tab alignments) for RTL paragraphs.

Differences in Windows API and Uniscribe

The results depends on the value of TextEngine:

if Windows API is selected, in rvbdUnspecified mode, results are completely incorrect for RTL text (wrong selection drawing and caret positions); the results are unreliable in other modes (may depend on the chosen font);

if Uniscribe is selected, the results are correct is all modes; in rvbdUnspecified mode, only rearrangement of items on lines is turned off.


BiDiMode works in Windows versions supporting right-to-left languages (for example, on Win2000 and newer with RTL support installed, see Control Panel, Regional and Language Options, tab Languages, Install files for complex scripts and right-to-left languages). In all other versions of Windows, right-to-left text will be displayed left-to-right.

(if Windows API is used) BiDiMode mode for Unicode text works only under WinNT-based systems (WinNT 4, 2000, XP, 7, 8 and so on)

Demo project