Complex text layout
Complex text layout or complex text rendering is the typesetting of writing systems in which the shape or positioning of a grapheme depends on its relation to other graphemes. The term is used in the field of software internationalization, where each grapheme is a character.
Scripts which require CTL for proper display may be known as complex scripts. Examples include the Arabic alphabet and scripts of the Brahmic family, such as Devanagari, Khmer script or the Thai alphabet. Many scripts do not require CTL. For instance, the Latin alphabet or Chinese characters can be typeset by simply displaying each character one after another in straight rows or columns. However, even these scripts have alternate forms or optional features which require CTL to produce on computers.
Characteristics requiring CTL
The main characteristics of CTL complexity are:- Bi-directional text, where characters may be written from either right-to-left or left-to-right direction.
- Context-sensitive shaping and ligatures, where a character may change its shape, dependent on its location and/or the surrounding characters. For example, a character in Arabic script can have as many as four different shape-forms, depending on context.
- Ordering, where the displayed order of the characters is not the same as the logical order. For example, in Devanagari, which is written from left to right, the grapheme for "short i" appears to the left of the consonant that it follows: in कि ki, the ि -i should render on the left, its bow reaching until above the क k- to the right.
Implementations
Most text-rendering software that is capable of CTL will include information about specific scripts, and so will be able to render them correctly without font files needing to supply instructions on how to lay out characters. Such software is usually provided in a library; examples include:- Core Text for macOS
- Uniscribe and DirectWrite for Microsoft Windows
- HarfBuzz, a cross-platform library
- Pango, a cross-platform library which nowadays incorporates HarfBuzz
Examples of this latter approach include Apple Advanced Typography and Graphite. Both of these names encompass both the instruction format and the software supporting it; AAT is included on Apple operating systems, while Graphite is available for Microsoft Windows and Linux-based systems.
The OpenType format is primarily intended for systems using the first approach, but it has a few features that assist with CTL, such as contextual ligatures. AAT and Graphite instructions can be embedded in OpenType font files.