Complex Text Layout Language Support in the Solaris Operating Environment

1.3 Bidirectional Scripts

Arabic and Hebrew use bidirectional script. In a bidirectional script, the default text direction is from right to left. However, numbers and Western-language text (such as quotations or proper names) are written from left to right. Text justification depends on line direction--typically, right-to-left text is right justified and left-to-right text is left justified.

Because input characters are stored in order, an application must manage the display of blocks of right-to-left and left-to-right text in the proper order. In Figure 1-1, text direction is left to right for the English text and right to left for the Arabic text. Note that the cursor is to the left of the Arabic text after input.

Figure 1-1 Bidirectional text

Graphic


Note -

In the Solaris operating environment, complex text layout issues are managed by Motif. Applications using Motif do not need to address these issues directly. For more information, see Section 2.1, Architecture.


1.3.1 Managing Bidirectional Text

In an application supporting bidirectional script, the global direction determines text flow and alignment. For example, in an Arabic word processor, the global direction is right to left for justification, tabulation, and related formatting operations. Roman words and phrases within an Arabic text string, however, remain left-to-right aligned. When a line break occurs in the middle of an Arabic string imbedded in an English sentence, however, the break must still respect the left-to-right text flow as shown in Figure 1-2.

Figure 1-2 English-Arabic-English left-to-right text flow

Graphic

1.3.2 Symmetrical Swapping

Some characters have a meaning related to their direction, such as greater than (>) and less than (<). Bidirectional text strings containing these characters may need to replace one character with its complement to retain the correct meaning. For example, the expression 3 < 4 (three is less than four) is stored in the sequence in which it is typed. To display this expression correctly in a right-to-left string, however, it must appear as 4 > 3 (read right to left as 3 less than 4). Because a direct transposition of the three characters in storage would give 4 < 3, which is incorrect, the transformation process must swap < and >.

Replacing complementary symbols to retain their correct meaning is called symmetrical swapping. Characters requiring symmetrical swapping include parentheses: ( and ), angle brackets: < and >, square brackets: [ and ], and curly brackets: { and }.