| United States-English |
|
|
|
![]() |
Common Desktop Environment: Internationalization Programmer's Guide > Chapter 2 Internationalization
and the Common Desktop EnvironmentFont Management |
|
When rendering text in an X Windows TM client, at least two aspects are sensitive to internationalization:
“Extracting Localized Text” describes how to choose the correct fonts to render localized text. A font contains a set of glyphs used to render the characters of a locale. However, you may also want to do the following for a given locale:
The last two fields of a font XFLD identify which glyphs are contained in a font and which value is used to obtain a specific glyph from the set. These last two fields identify the encoding of the glyphs contained in the font. For example:
The last two fields of this XLFD name are iso8859 and 1. These fields specify that the ISO8859-1 standard glyphs are contained in the font. Further, it specifies that the character code values of the ISO8859-1 standard are used to index the corresponding glyph for each character. The font charset used by the application to render data depends on the locale you select. Because the font charset of the data changes is based on the choice of locale, the font specification must not be hardcoded by the application. Instead, it should be placed in an app-defaults file, allowing localized versions of the app-defaults file to be created. Further, the font should be specified as a fontset. A fontset is an Xlib concept in which an XLFD is used to specify the fonts. The font charset fields of the XLFD are specified by the Xlib code that creates the fontset and fills in these fields based on the locale that the user has specified. For many languages (such as Japanese, Chinese, and Korean), multiple font charsets are combined to support single encoding. In these cases, multiple fonts must be opened to render the character data. Further, the data must be parsed into segments that correspond to each font, and in some cases, these segments must be transformed to convert the character values into glyphs indexes. The XFontset, which is a collection of all fonts necessary to render character data in a given locale, also deals with this set of problems. Further, a set of rendering and metric routines are provided that internally take care of breaking strings into character-set-consistent segments and transforming values into glyph indexes. These routines relieve the burden of the application developer, who needs only the user fontsets and the Xlib rendering and metric application program interfaces (APIs). For more information on matching fonts to character sets, refer to DtStdInterfaceFontNames(1,5). Also note that if your CDE provides the set of Standard Application Font Names, you can use a locale-independent resource. This section describes the following font objects:
Generally, all internationalized programs expecting to draw localized text using Xlib are required to use an XmFontSet for specifying the locale- dependent fonts. Specific fonts within a font set should be specified using XLFD naming conventions without the charset field specified. The resource name for an XFontset is *fontSet. Refer to “Localized Resources” for a list of font resources. Applications directly using Xlib to render text (as opposed to using XmString functions or widgets) may take advantage of the string-to-fontSet converter provided by Xt. For example, the following code fragment shows how to obtain a fontset when using Xt and when not using Xt:
Internationalized programs should avoid using fonts directly, that is, XFontStruct, unless they are being used for a specific charset and a specific character set. Use of XFontStruct may be limiting if the server you are connecting to does not support the specific charsets needed by a locale. The resource name for an XFontStruct is *font. Table 2-1 “Font Set and Render Table Syntax” shows the syntax for a font set and render table. Table 2-1 Font Set and Render Table Syntax
Here are some examples of font resource specifications:
The preceding renderTable specifies a fontset, consisting of one or more 24-point Adobe Courier fonts, as appropriate for the user's locale.
This renderTable specifies a fontset consisting of an 18-point Courier font (if available) for some characters in the users data, and an 18-point Gothic font for the others. The following Xlib font management API functions are available:
The following Motif Render Table API functions are available:
To improve basic interchange, fonts are organized according to the standard X- Consortium font charsets. Selecting base font names of a font set associated with a developer's language is usually easy because the developer is familiar with the language and the set of fonts needed. Yet, when selecting the base font names of a font set for various locales, this task can be difficult because an XLFD font specification consists of 15 fields. For localized usage, the following fields are critical for selecting font sets:
This simplifies the number of fields, yet the possible values for each of these fields may vary per locale. The actual point size (POINT_SIZE) may vary across platforms. Throughout this documentation, the following convention should be used when specifying localized fonts:
The following describes the minimum set of recommended values for each field to be used within the desktop for the critical fields when specifying font sets in resource (app-defaults) files.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||