skip to main content
Programmer's documentation > Advanced globalization in JViews Charts > Bidirectional text > Base text direction: concepts
 
Base text direction: concepts
Describes concepts essential to understanding base text direction.
*Bidirectional character type
*Refers to bidirectional character type as defined in the Unicode standard.
*Strong directional character
*Defines strong characters with their own predefined reading direction.
*Directional run
*Describes how directional runs define different orientations of segments in a sequence of bidirectional text.
*Character direction
*Pertains to the reading direction of strong and not strong characters and is distinct from base text direction.
*Base text direction
*Describes base test direction, which refers to the order of directional runs in a sentence.
Bidirectional character type
The Unicode standard assigns to each character its own invariant bidirectional character type.
See http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types.
Strong directional character
Strong directional characters have their own predefined reading direction and can affect the reading direction of neighboring characters.
Characters with the left-to-right, right-to-left, and right-to-left Arabic types are called ““strong directional””, or just ““strong”” characters.
The reading direction of characters that are not ““strong”” depends on their context.
Numbers are a special case; their reading direction is always left to right, but they do not affect the reading direction of neighboring characters. Even numbers that are displayed with Arabic-Indic digits have a left-to-right character direction.
Directional run
Bidirectional text, as its name implies, can contain segments that are read from right to left and segments that are read from left to right.
The following example shows a right-to-left sentence with a mixture of right-to-left words in Arabic, Hebrew, Urdu, and so on, and left-to-right words, for example, in English. Uppercase letters represent letters in Arabic or Hebrew script. The example sentence contains five directional runs.
Sentence with five directional runs
In the example sentence:
*The segment ““SAW I NEHW”” is a right-to-left directional run.
*““23”” is a number and is therefore read from left to right, that is, it is a left-to-right directional run.
*““EHT OT TNEW I,”” is a right-to-left directional run.
*““united states”” is a left-to-right directional run.
*The final period on its own is a right-to-left directional run.
This mixing of different directional runs in the text sequence is called bidirectional text.
A directional run delimits a sequence of adjacent characters that are read in the same direction; it is the formal term for what was earlier referred to as a ““segment””.
Character direction
Character direction refers to the effective reading direction of specific occurrences of characters.
The effective direction can be affected by the context of specific occurrences of characters. Character direction is fixed for strong characters and for digits. For other types of characters, character direction depends on the context. Character direction corresponds to the reading order of letters in words. Character direction is uniform within a directional run. It should not be confused with base text direction.
Base text direction
Base text direction refers to the order in which directional runs are laid out in a sentence.
For left-to-right sentences, for example, in English, the proper base text direction is Left To Right (LTR), even if a sentence includes Arabic, Hebrew, Urdu, or Farsi words. For right-to-left sentences, for example, in Arabic or Hebrew, the proper base text direction is Right To Left (RTL), even if a sentence includes English words or numbers.
Determining whether a sentence is, for example, English or Arabic, is not always easy. Examine the example sentence in Directional run. This sentence is an Arabic and Hebrew sentence and therefore has a right-to-left base text direction. The directional runs must be laid out on the line one after the other from right to left. The following example shows each directional run enclosed in square brackets.
[.] [united states][ EHT OT TNEW I ,] [23][ SAW I NEHW]
Consecutive English words form a left-to-right directional run even when they are embedded in an Arabic, Hebrew, or Urdu sentence. Consecutive Arabic or Hebrew words form a right-to-left directional run, even when embedded in an English sentence. The ordering of successive directional runs depends on the value of the base text direction.
The natural text direction of a language, right to left for Arabic, Hebrew, or Urdu and left to right for English, is inherent in the script used to write the text and is independent of the component direction, which is handled by the GUI mirroring mode, and of the user locale. Even if the GUI of a product is not mirrored, bidirectional text entered by the user of an application, that is, bidirectional text that the user directly or indirectly introduces and sees through a product’s GUI, should be displayed according to its natural base text direction. The user should have control over document and paragraph base text direction independently of the component direction (GUI mirroring mode).
The base text direction of bidirectional text affects its display. Consider how the string hello world !, listed in logical order, that is, the order in which the text is pronounced, is displayed when its base text direction is changed.
With left-to-right base text direction, the string is displayed:
hello world !
With right-to-left base text direction, the same string is displayed:
! hello world
In the example of right-to-left base text direction the exclamation mark (!) appears on the left side of the string.
The string is not displayed as ““! world hello”” when the base text direction is right to left. Even though the base text direction is right to left, consecutive English words always constitute a left-to-right directional run, so that each word is displayed left to right and the progression of words in the run is also left to right.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.