Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
  Previous   Contents   Next 
   
 
Chapter 6

Complex Text Layout

Complex Text Layout (CTL) extensions enable Motif APIs to support writing systems that require complex transformations between logical and physical text representations, such as those required for Arabic, Hebrew, and Thai. CTL Motif provides character shaping, such as ligatures, diacritics, and segment ordering , and supports the transformation of static and dynamic text widgets. It also supports right-to-left and left-to-right text orientation and tabbing for dynamic text widgets. Because text rendering is handled through the rendition layer, other widget libraries can be easily extended to support CTL.

Overview of CTL Technology

To leverage the new features, users must have the Portable Layout Services (PLS) library and the appropriate language engine. CTL uses PLS as the interface to the language engine, and uses the language engine to transform text before the text is rendered. Applications that support CTL must include additional resources, as described in the CTL documentation.

Specifically, XomCTL supports the following complex language shaping and reordering features provided by underlying locale-dependent PLS module transformations:

  • Positional variation

  • Ligation (many-to-one) and character composition (one-to-many)

  • Diacritics

  • Bidirectionality

  • Symmetrical swapping

  • Numeral shaping

  • String validation

Overview of CTL Architecture

The CTL architecture is organized as shown in Figure 6-1. Dt Apps at the top of the stack employs Motif CTL functionality for rendering text. Motif in turn interfaces with locale-specific language engines using PLS, and performs transformations to support positional variation, numeral shaping, and so on.

The CTL architecture is built to support new languages by adding a new locale-specific engine. In other words, support for Thai and Vietnamese can be added without altering Motif or Dt Apps.

Figure 6-1 CTL Architecture

CTL Support for X Library Based Applications

XomCTL (Complex Text Layout support in X Library Output Module) allows all pure X Windows applications (such as an X-based terminal emulator) to have CTL support. XomCTL provides a full-featured Open Source XI18N implementation including X11 dumb font support.

New XOC Resources

The following XOC resources are provided by the Solaris 9 environment:

XNText

Enables user to set the text buffer on which CTL operation needs to be performed.

XNTextLayoutNumGlyphs

Provides number of glyphs for the text in the text buffer.

XNTextLayoutModifier

Same as XmNLayoutModifier of Motif.

XNTextLayoutProperty

Same as PLS Property, input-to-output and output-to-input.

XNTextLayoutMapInpToOut

Same as PLS Property, input-to-output and output-to-input.

XNTextLayoutMapOutToInp

Same as PLS Property, input-to-output and output-to-input.

Descriptions of these may be obtained from the specification of X/Open or PLS Portable Layout Services.

Changes in Motif to Support CTL Technology

The following chages to Motif support the CTL technology:

XmNlayoutDirection

Controls object layout.

XmStringDirection

Specifies the direction in which the system displays characters of a string.

XmRendition

Adds new pseudo resources to XmRendition.

XmText and XmTextField

Affects the layout behavior of the text associated with the XmRendition.

XmTextFieldGetLayoutModifier

Returns the layout modifier string of a rendition layout object.

XmTextGetLayoutModifier

Returns the value of the current layout object settings of the rendition associated with the widget.

XmTextFieldSetLayoutModifier

Sets the layout modifier values for the layout object tied to its rendition.

XmTextSetLayoutModifier

Modifies the layout object settings of a rendition associated with the widget.

XmStringDirectionCreate

Creates a compound string.

XmNlayoutDirection

The XmNlayoutDirection resource [See section 11.3 of the Motif Programmer's Guide (Release 2.1) for an overview of XmNlayoutDirection, and especially for a description of the interaction between XmStringDirection and XmNlayoutDirection.] controls object layout. It interacts with the orientation value of the LayoutObject in the manner described below.

Determining the Layout Direction

When XmNlayoutDirection is specified as XmDEFAULT_DIRECTION, then the widget's layout direction is set at creation time from the governing pseudo-XOC. In the case of dynamic text (XmText and XmTextField), the governing pseudo-XOC is the one that is associated with the XmRendition used for the widget. In the case of static text (XmList, XmLabel, XmLabelG), the layout direction is set from the first compound string component that specifies a direction. This specification happens in one of two ways:

Directly

The component is of type XmSTRING_COMPONENT_LAYOUT_PUSH or XmSTRING_COMPONENT_DIRECTION.

Indirectly

The component is of type XmSTRING_COMPONENT_LOCALE_TEXT, XmSTRING_COMPONENT_WIDECHAR_TEXT, or XmSTRING_COMPONENT_TEXT, from the component's associated XmRendition's and associated LayoutObject.

When XmNlayoutDirection is not specified as XmDEFAULT_DIRECTION, and the XmNlayoutModifier @ls orientation value is not specified explicitly in the layout modifier string, then the XmNlayoutDirection value is passed through to the XOC and its LayoutObject.

If both XmNlayoutDirection and the XmNlayoutModifier @ls orientation value are explicitly specified, then the behavior is mixed. The XmNlayoutDirection controls widget object layout, and the XmNlayoutModifier @ls orientation value controls layout transformations.

See CAE Specification: Portable Layout Services: Context-dependent and Directional Text. The Open Group: Feb 1997; ISBN 1-85912-142-X; document number C616 for a description of portable functions for handling context-dependent and bidirectional text transformations as a logical extension to the existing POSIX locale model. The document is intended for system and application programmers who want to provide support for complex-text languages.

XmStringDirection

XmStringDirection is the data type used to specify the direction in which the system displays characters of a string.

The XmNlayoutDirection resource sets a default rendering direction for any compound string (XmString) that does not have a component specifying the direction of that string. Therefore, to set the layout direction, you need to set the appropriate value for the XmNlayoutDirection resource. You do not need to create compound strings with specific direction components. When the application renders an XmString, the application should look to see if the string was created with an explicit direction (XmStringDirection). If there is no direction component, the application should check the value of the XmNlayoutDirection resource for the current widget and use that value as the default rendering direction for the XmString.

XmRendition

CTL adds the new pseudo resources to XmRendition listed in the following table:

Table 6-1 New Resources in XmRendition

Name

Class/Type

Access

Default Value

XmNfontType

XmCFontType/XmFontType

CSG

XmAS_IS

XmNlayoutAttrObject

XmClayoutAttrObject/String

CG

NULL

XmNlayoutModifier

XmClayoutModifier/String

CSG

NULL

 
 
 
  Previous   Contents   Next