In Motif environments, such as CDE, you use versions of fonts, codesets, servers, and applications that support features discussed in earlier chapters. This chapter provides more detail on using features that help support Asian languages. Topics include the following:
Tuning the cache and unit size of the X display server for languages with ideographic characters (Section 3.1)
Setting fonts for local language display (Section 3.2)
Customizing an application window for local languages (Section 3.3)
For information on font rendering and on how to use font renderers for
multibyte PostScript fonts, UDC fonts, and TrueType fonts, see the
Writing Software for the International Market
manual.
3.1 Tuning the X Server for Ideographic Languages
Asian languages have large ideographic character sets, so all characters needed for display are not loaded into memory at the same time. Instead, only as many characters as will fit in the memory cache are simultaneously loaded. When characters needed for display are not currently cached in memory, the least recently used font glyphs are removed from the cache to make room. The font-cache mechanism allows you to display ideographic text in multiple typefaces, font sizes, and font styles without increasing the amount of memory that systems must have to support ideographic languages.
The X server font-cache mechanism allows you to change the number of cache units and the size of these units to best accommodate the character sets used in displays. You will probably need to change the default values set for cache parameters to achieve the best performance from your system if it will display Asian language text. Consider the following criteria when deciding on the optimal values for font caching:
The number of ideographic languages that you want to display
If you intend to work with several ideographic languages during the same CDE session, you need larger values for acceptable performance.
The number of fonts that will be used simultaneously
Variation in font number and size is affected by the type of application you run. A desktop publishing application typically requires more fonts than other types of applications. A software development tool typically requires fewer fonts than other types of applications.
The number of frequently used characters in the languages you want to display
In Asian languages, only a subset of characters are used frequently. The size of this subset varies from one language to another. For example, approximately 20,000 standard characters are supported for Taiwan but only 5,000 of those characters are used frequently. Estimates for the number of frequently used characters for other Asian countries are: People's Republic of China (3000), Korea (2000), and Japan (2000). Font-cache parameters are tuned to accommodate the subset of frequently used characters.
To change the cache size (which
is the number of cache units) and the size of each cache unit, you must modify
the X server configuration file
/usr/lib/X11/xdm/Xservers
.
This file contains a line, similar to the following one, that starts the X
server:
:0 local /usr/bin/X11/X
You can modify this line to add definitions for cache size and unit size. For example:
:0 local /usr/bin/X11/X -cs
cache_size
-cu
unit_size
Table 3-1
describes the options that tune the
font-cache mechanism.
Table 3-1: X Server Options for Tuning the Font-Cache Mechanism
stty Option | Description |
-cs
cache_size |
Defines the number of cache units. The minimum (and also default) value for this parameter is 1024. If you specify a cache size smaller than 1024, font caching is disabled. For one ideographic language, the recommended value is the lowest multiple of 1024 that accommodates the number of frequently used characters in that language. If a workstation displays multiple ideographic languages simultaneously, you must add together the values required for each language to get the minimum cache size. Specify an even larger value if you intend to run applications, such as desktop publishing software, that require multiple font styles and sizes for each ideographic character. |
-cu
unit_size |
Defines the size of each cache unit. The minimum value for unit size is 31 bytes and the default value is 128 bytes. If you specify a value smaller than 31 bytes, the value has no effect. If a particular font requires more memory space than 128 bytes, the font-cache mechanism automatically allocates one or more additional units to store its glyphs. |
Note
Font caching applies only to uncompressed fonts in
pcf
format. Font caching is not applied to any compressed fonts or to fonts inbdf
format. Because font caching cannot be used with compressed fonts, the 2-byte fonts for Asian languages are not installed in compressed format.
You can calculate cache unit size with the following formula:
unit_size = ((floor(ceil((double)WIDTH / 8.0) /4.0)) + 1.0) * 4.0 * (double)HEIGHT
Consider the following calculation for a typical font size of 24x24:
unit_size in bytes = ((floor(ceil((double) 24 / 8.0 / 4.0)) + 1.0) * 4.0 * (double) 24 = 96
For 34x34 fonts, the unit size calculation would yield 272 bytes.
Given that 96 bytes are needed to cache a 24x24 font glyph and 272 bytes are needed to cache a 34x34 font glyph, the default unit size of 128 has the following implications:
For 24x24 fonts, each character needs one cache unit. If cache size is set to 4096, the cache can accommodate 4096 characters.
For 34x34 fonts, each character needs three cache units. If cache size is set to 4096, the cache can accommodate 1365 characters.
Small fonts (those whose characters require a single 128-byte unit)
are used to display ideographic characters.
Therefore, you usually have to
change only the cache size to achieve acceptable performance in text displays
of languages with ideographic characters.
3.2 Setting Fonts for Display of Local Languages
The system on which you install language variant subsets is automatically updated with the fonts required to display text in the supported languages.
In CDE, applications access local language fonts through a font
alias mechanism.
The
/usr/dt/config/xfonts/i18n/{75,100}dpi/fonts.alias
files rather than files installed in the
/usr/dt/config/xfonts/locale-name/
areas are most critical for resolution
of which fonts an application uses.
This arrangement supports both a consistent
session language and the ability to run an individual application in a language
different from the session language.
X or Motif applications require non-ASCII fonts to display Chinese (and other, non-English) characters. Therefore, you must set the font path appropriately before starting an application that displays Chinese characters. An application can find Chinese fonts for codesets other than GBK or GB18030 in either of the following directories:
/usr/i18n/lib/X11/fonts/decwin/75dpi
/usr/i18n/lib/X11/fonts/decwin/100dpi
Chinese fonts for GBK and GB18030 are installed in
/usr/i18n/lib/X11/fonts/SChineseTT
(for TrueType font).
For CDE applications, the appropriate fonts are installed
on the system or available through a font server.
Thus, you do not need to
enter manual commands to ensure that the appropriate fonts are found.
You
can use the
xset
command to check the font path or to add
an appropriate font to the path as described in
xset
(1X)3.2.1 Accessing Local Language Fonts for Remote Displays
The system where local language subsets are installed may function as a client in a client/server display environment. In this case, the local language fonts must also be available to the window managers for all the server systems where native language text is displayed.
To make local language fonts available for other server systems, you must do one of the following:
Install fonts for other locales on the individual systems used for remote login to the system where language variant subsets are installed.
Make the fonts known to the other systems through a font server.
You can use the
/usr/bin/X11/
command to determine which fonts are currently installed
on your system.
xlsfonts
See
Appendix A
for tables on fonts that describe,
for each font set, the language, typeface code, style, sizes, and support
for 75 or 100 dots-per-inch resolution.
3.3 Customizing a Terminal Emulation Window for Asian Languages
The following features and restrictions apply to terminal windows that you create when an Asian language is specified for the language setting:
The language setting determines the additional menu items, push buttons, toggle switches, and text entry fields that may be available to you for customizing terminal window features.
Terminal emulation always follows the selected language for
your session if the terminal is invoked from the CDE Personal Applications
Menu.
If a terminal window is invoked from another terminal window where the
LANG
or
LC_ALL
variable has been set to the locale
for another language, then the language of the new window changes.
Setting
locale in the parent window does not change the language of the parent window,
only of child windows invoked from the parent window.
For a language supported by an input method server, you must be sure the input server is connected to the terminal window where you input characters in that language. Otherwise, you cannot use the input method for character entry. The connection between a terminal window and an input server does not exist if one of the following occurs:
The terminal window was started before the input server started
At the start of a CDE session, the input server starts automatically when the session language is selected. For example, if Chinese is your session language, the input server for Chinese is automatically attached to terminal windows by default. However, if Chinese is your session language and you want to create a window to work in Korean, you must manually start the input server for Korean (in addition to setting a Korean locale) before invoking the new terminal window.
The input method server was killed for some reason
If the connection between a terminal window and the input method server was broken, you can start the input method server and then create another terminal window where you can use the input method.