B    Setting Up and Using User-Defined Character Databases

Japanese, Chinese, and Korean can include user-defined characters (UDCs) that supplement the characters defined in the standard character sets for Asian languages. This appendix explains how to create UDCs and the other kinds of files that support UDC input and display.

You create user-defined characters with the cedit application, discussed in Section B.1. You use the cgen utility, discussed in Section B.2, to create font, collation, and other support files for user-defined characters. X applications can also obtain fonts for user-defined characters directly from a UDC database by using font renderers. Refer to Section 6.15.2 for information about font renderers.

Note

The system default sort command does not access the collation files created for user-defined characters. Refer to Section 6.11 for information on sorting strings that may contain these characters.

There are setup operations that you need to complete before terminals or workstation monitors can display user-defined characters.

The atty driver includes a mechanism to allow on-demand loading of files associated with user-defined characters. You enable this mechanism and can change some of its default parameter values with the stty command. Table B-1 describes the stty options that you use with on-demand loading.

Table B-1:  The stty Options for On-Demand Loading of UDC Support Files

stty Option Description
odl Enables the software on-demand loading (SoftODL) service.
-odl Disables the software on-demand loading (SoftODL) service.
odlsize size Sets the maximum size of the ODL buffer. This size should be the same as a terminal's font-cache size. By default, size is 256 characters.
odltype type Sets the ODL buffer replacement strategy. Valid values for type are: fifo (first-in-first-out) and lru (least recently used)
odldb path

Sets the path to the database and other files that support user-defined characters.

If this path is not specified, either the system default files are used or, if users are allowed to create personal UDC databases, the process default files are used.

Default pathnames for various databases are specified in the /var/i18n/conf/cp_dirs file, which is described in Section 6.8. The cp_dirs file specifies, for example, that the systemwide defaults are /var/i18n/udc and /var/i18n/odl, and that the process defaults are $HOME/.udc and $HOME/.odl. Use the odldb option when you want to change the default odl file.

odlreset Resets the ODL service and clears the internal ODL buffers.
odlall Displays the current settings for the ODL service.

Figure B-1 shows the relationship among components mentioned in Table B-1 and the SoftODL service.

Figure B-1:  Components That Support User-Defined Characters

B.1    Creating User-Defined Characters

The user-defined character editor (cedit) is a curses application for managing attributes of user-defined characters. The character attributes that you usually manipulate with the cedit application include:

Each user-defined character has a character attribute record, which is stored in a character attribute, or UDC, database. A UDC database can be systemwide or private. There can be only one systemwide database that all users share; however, any user can have a private database as well. The following command invokes the user-defined character editor:

% cedit

With no options, the cedit command uses the default database. If you are superuser, the default database is /var/i18n/udc. If you are an unprivileged user, the default database is $HOME/.udc. There are a number of problems you can encounter when using user-defined characters that are maintained in private databases; therefore, it is best for a privileged user to maintain all user-defined characters in a systemwide database. The cedit command has a number of options and an argument, which are described in Table B-2.

Table B-2:  The cedit Command Options

cedit Options and Arguments Description
-c old_db Converts a Japanese ULTRIX fedit font file or an Asian ULTRIX character attribute database file to the format used by cedit.
cur_db Specifies the path of a character attribute database (to override the default path).
-h Displays cedit syntax.
-r ref_db

Specifies the path of the reference character attribute database (to override the default path).

This database provides a model for the UDC database on which you are working with the cedit utility.

The Reference Database item on the cedit File menu is an alternative to specifying the -r option on the cedit command line.

The following command displays the cedit syntax:

% cedit -h
Usage : cedit [-h] [-c <old_db>] [-r <ref_db>] [<cur_db>]

The cedit command returns an error message if your locale setting is not supported for creation of user-defined characters. Locales supported for user-defined characters include those for the Chinese and Japanese languages. After you invoke cedit, you can use the Options menu on the cedit user interface screen to change the language of user interface messages and help text back to English.

The following sections discuss the screens, menu items, editing modes, and function keys of the cedit utility.

B.1.1    Working on the cedit User Interface Screen

When the LANG variable is set to a supported locale, such as zh_TW.big5, the cedit command displays the user interface screen shown in Figure B-2.

Figure B-2:  The cedit User Interface Screen

The user interface screen is divided into three areas:

You can use the four arrow keys to select a menu and then press either Return or the space bar to see items on that menu. You can accomplish the same goal more directly by pressing the key for the letter that is underlined in the title of the menu.

Menu items are displayed in one of the following states:

To return to a higher menu level without activating items, press Ctrl-x.

Menus on the user interface screen provide the following options for managing user-defined characters and their attributes:

B.1.2    Editing Font Glyphs

To create or change the font glyph of a user-defined character, you must invoke the font editing screen of cedit as follows:

  1. Select a character by choosing the Character item from the Edit menu.

    The cedit program prompts you to enter the hexadecimal code value (without the \x prefix) for the character to be edited. The range of valid codes for UDC characters is defined in a set of configuration files. When more than one codeset is supported for the language and territory of your current locale, cedit attempts to supply values for the additional codesets so the character can be used with all the associated locales.

    If cedit cannot determine the character's value in other codesets, you can change the codeset setting through the Options menu and then explicitly specify the character's encoding in the additional codeset. In general, it is a good idea to define user-defined characters to have values that can be mapped to other codesets supported for the language. For more information on codes for user-defined characters in specific Asian languages, refer to the language-specific technical reference guides available on the Tru64 UNIX documentation CD-ROM.

    The cedit utility first searches your current UDC database for the code that you enter. If a character with that code is not found in the UDC database, the utility searches the current reference character database.

  2. Choose the Font item from the Edit menu to see options for font style/size.

  3. Choose one of the font style/size options.

    If you are creating a font glyph for use in a Motif application, the available size options may not be appropriate for the window area where you intend to use the font. In this case, choose the smallest size option that will accommodate both dimensions of your font.

The cedit program then displays the full-screen font editor interface as shown in Figure B-3.

Figure B-3:  The cedit Font Editing Screen

The cedit font editing screen has several windows:

Note

There are some hardware restrictions regarding font glyph displays in the small windows.

Font glyph displays in the reference and display windows are enabled only on local-language terminals that support the Dynamic Replacement Character Set (DRCS) function.

On terminal emulation windows, the font glyph in the Display window does not appear in its actual size.

Fonts created in the editing window for use with system software are processed to occupy the size dimensions you selected before the editor interface screen appeared.

You can also create a font for use with Motif applications and whose dimensions are smaller than those selected. In this case, you confine your editing operations to a rectangle that originates at the upper-left corner of the editing window and has dimensions smaller than the available editing space (see Figure B-4). The UDC font converter that supports a Motif application considers the upper-left corner of the editing window as the font origin, generates dimensions needed to encompass the glyph based on this origin, and discards unused space outside these dimensions. This utility also allows you to explicitly specify the size dimensions for the compiled font glyphs.

Figure B-4:  Interpretation of Font Editing Screen for Sizing a Font

All functions in cedit are bound to keys; in other words, you press a key to invoke a function. Press either the PF2 or the Help key to see a diagram of how keys are bound to editing functions. Note that your online diagram may vary from the one shown here due to differences in keypad design on some systems. There are four kinds of editing modes for the cedit editing screen:

The cedit font editor uses four buffers to store bitmap data. Some of these buffers are used by editing functions, which are discussed following the buffer descriptions.

When you are working on windows in the font-editing screen, you invoke editing functions by using keystrokes or, in some cases, through a pop-up menu that appears when you press the Do key. The following functions are available on the pop-up menu:

Figure B-5 shows the keypad keymaps for invoking different editing functions. The keypad functions, along with the letter keys used for drawing, are described in the following tables.

Figure B-5:  Keymap for cedit Functions

Table B-3:  Keys for Miscellaneous Font Editing Functions

Key Description
Help or PF2 Shows you which keys are bound to which editing functions. Press Help along with another key in the diagram for more information on a particular key's editing function.
PF1 Toggles the GOLD state. Some keypad keys represent more than one function; in this case, one of those functions is invoked by pressing PF1 and then the other keypad key.
KP. Displays the font glyph in actual size on the display window.
GOLD KP. Clears the font glyph displayed in the editing window.
U or u Undoes the previous operation.
Ctrl-L Redraws the screen.
Ctrl-z Suspends the cedit program.
Do Displays the pop-up menu for invoking SCALE, USE, and REFER functions.
Enter Saves changes and exits from the font editor.
GOLD Enter Quits the font editor without saving changes.

Table B-4:  Keys for cedit Mode Switching

Key Description
PF3 Toggles Cursor mode.
PF4 Toggles Paste mode.
KP- Toggles Type mode.
KP. Toggles Wrap mode.

Table B-5:  Keys for Fine Control of Cursor Movement

Key Description
Up-arrow Moves the cursor up.
Down-arrow Moves the cursor down.
Left-arrow Moves the cursor left.
Right-arrow Moves the cursor right.
KP7 Depending on Cursor mode, moves the cursor up and left.
KP8 Depending on Cursor mode, moves the cursor up.
KP9 Depending on Cursor mode, moves the cursor up and right.
KP4 Depending on Cursor mode, moves the cursor left.
KP6 Depending on Cursor mode, moves the cursor right.
KP1 Depending on Cursor mode, moves the cursor down and left.
KP2 Depending on Cursor mode, moves the cursor down.
KP3 Depending on Cursor mode, moves the cursor down and right.
KP5 Toggles the pixel under the cursor without moving the cursor.

Table B-6:  Keys for Moving Cursor to Window Areas

Key Description
GOLD KP7 Moves the cursor to the upper-left corner.
GOLD KP8 Moves the cursor to the top row.
GOLD KP9 Moves the cursor to the upper-right corner.
GOLD KP4 Moves the cursor to the leftmost column.
GOLD KP5 Moves the cursor to the center of the window.
GOLD KP6 Moves the cursor to the rightmost column.
GOLD KP1 Moves the cursor to the lower-left corner.
GOLD KP2 Moves the cursor to the bottom row.
GOLD KP3 Moves the cursor to the lower-right corner.

Table B-7:  Keys for Drawing Font Glyphs

Key Description
L or l Draws a line connecting two selected points.
C or c Draws a circle centered at a selected point.
r Draws an open rectangle in a selected area.
R Draws a solid rectangle in a selected area.
e Draws an open ellipse in a selected area.
E Draws a solid ellipse in a selected area.
X or x Mirrors the font glyph along the horizontal axis (X-axis).
Y or y Mirrors the font glyph along the vertical axis (Y-axis).
/ Mirrors the font glyph along the 45-degree diagonal axis.
\ Mirrors the font glyph along the 135-degree diagonal axis.
F or f Depending on cursor mode, fills an area.
T or t Inverts the state of all pixels.

Table B-8:  Keys for Editing Font Glyphs

Key Description
KP0 Changes the display in the Edit window from the font glyph in the Edit buffer to the font glyph in the Use buffer.
GOLD KP. Displays font glyphs in the reference windows.
GOLD KP0 Changes the display in the Edit window from the font glyph in the Use buffer to the font glyph in the Edit buffer.
Select Starts or cancels a selected area.
Insert Inserts the contents of the CUT-AND-PASTE buffer.
Remove Cuts a selected area to the CUT-AND-PASTE buffer.
GOLD Remove Copies a selected area to the CUT-AND-PASTE buffer.
GOLD Up-arrow Shifts the font glyph up by one line.
GOLD Down-arrow Shifts the font glyph down by one line.
GOLD Left-arrow Shifts the font glyph left by one column.
GOLD Right-arrow Shifts the font glyph right by one column.

There is often more than one way to perform the same editing operation. The following summary discusses one method to accomplish various operations:

After you create a font glyph, you need to specify its name, input key sequence, collating value, and, optionally, the name of the class to which the character belongs. Use the Edit menu items on the cedit user interface screen to specify these attributes.

B.2    Creating UDC Support Files That System Software Uses

The character attributes stored in the UDC database must be directed to specific kinds of files to meet the needs of different kinds of system software. Terminal driver software and the asort utility, for example, must recognize user-defined character attributes but cannot directly access information in UDC databases. Therefore, after you create or change character attributes in a UDC database, you use the cgen command to create the following support files:

The following command creates some of these files for the UDC database ~wang/.udc:

% cgen -odl -pre -col -iks ~wang/.udc

If you enter the cgen command without specifying options, statistical information about the specified database is displayed. If you enter the command without specifying a UDC database, the private user database is used for a nonprivileged user and the system database for the superuser. In other words, the database specification in the preceding example would not be needed if the user who entered the command was logged on as wang.

Table B-9 describes cgen command options.

Table B-9:  The cgen Command Options

Option Description
-bdf Creates .bdf files needed for X and DECwindows Motif applications.
-col Creates collating value tables. You must use the asort command, rather than the sort command, if you want to apply these tables during sort operations.
-dpi 75|100 Sets resolution to either 75 or 100 when creating .bdf and .pcf files with the -bdf and -pcf options.
-fprop property Sets the font property when creating .bdf and .pcf files with the -bdf and -pcf options.
-iks Creates the input key sequence file.
-merge font_pattern

Invokes the fontconverter command to merge the UDC fonts with an existing pcf font file that matches the specified font_pattern (for example, '*-140-*jisx0208*').

If you specify the -merge option, you must also specify the -pcf and -size options. The output .pcf file is in the form registry_width_ height.pcf, where registry is the font registry field of the specified font file.

-osiz widthxheight

Specifies the font size for bdf output format.

The font size in bdf format may be different from the size of the font defined in the UDC database. The font sizes that the cedit command supports are limited; the -osiz option lets you override these size restrictions both in the .bdf file and the .pcf file generated from the .bdf file.

If the size parameters specified for the -osiz option are smaller than the size parameters specified for the -size option, only the upper-left portion of the UDC font glyph is used. If the size parameters specified for the -osiz option are larger than the size parameters specified for the -size option, the lower-right portion of the resulting font glyph is filled with OFF pixels.

-pcf

Invokes the bdftopof command to create the .pcf files needed for X and Motif applications.

When you use this option, the cgen command also invokes the mkfontdir and xset commands to make the fonts known to the font server and available to applications.

-pre

Creates preload font files.

Preload font files are files that are directly and completely loaded to a terminal and some printers. Preload files are not useful when UDC databases are large because of the limited memory available on most devices. On-demand loading (ODL), which uses ODL font files, is an alternative to using preload font files.

-odl

Creates ODL font files.

The terminal driver handles loading of fonts from ODL font files on an incremental basis, according to need and available memory.

-win userfont

Generates a font file with the name userfont, which can be copied to a Windows Version 3.1 or Windows NT Version 3.5 system. You must also specify the -size flag because only one size can apply to the specified file. Supported codesets for font files created by this option are big5 (for Chinese Windows systems), SJIS (for Japanese Windows systems), and deckorean (for Korean Windows systems).

B.3    Processing UDC Fonts for Use with X11 or Motif Applications

The preload font files created with the -pre option of the cgen utility must be converted to BDF (Bitmap Distribution Format) or PCF (Portable Compiled Format) for use by X11 or Motif applications. The fontconverter command performs this conversion and can do one of two things with the converted output:

The remainder of this section discusses the fontconverter command and its options. The cgen command has comparable options; in other words, you can perform fontconverter operations indirectly by using similar options on the cgen command line.

B.3.1    Using fontconverter Command Options

The following example shows the simplest form of the fontconverter command, which produces a default name for the output files. Assume for this example and the following discussion that the locale is set to a Japanese locale when the command is entered and that 24x24 was specified in the cedit utility when the font glyphs were created.


% fontconverter \
-font -jdecw-screen-medium-r-normal--24-240-75-75-m-240-jisx0208-kanji11 \
my_font.pre

The preceding command converts fonts in the my_fonts.pre file. By default, the command creates the JISX.UDC_24_24.pcf and JISX.UDC_24_24.bdf font files.

The default base name for the output font files varies according to language, as follows:

Font width and height are automatically appended to the base name in the names of output font files. The base name is also used in the XLFD (X Logical Font Description) as the registry name. For the fonts to be available to applications, perform one of the following actions with the compiled (.pcf) fonts:

Table B-10 lists and describes options of the fontconverter command. With the exception of -preload, the options are listed in command-line order. See Section B.3.2 for examples that use these options.

Table B-10:  Options and Arguments of the fontconverter Command

Argument or Option Description
-merge

Specifies that command output be merged with an existing font file.

See also the entry for the -font option.

-w

Specifies the font width.

Use this option when the fonts are created with a width smaller than the one specified for the cedit font editing window.

-h

Specifies the font height.

Use this option when the fonts are created with a height smaller than the one specified for the cedit font editing window.

-udc base_name

Specifies the base file name of the output UDC font file.

Use this option when you are creating a standalone output file (you are not merging output into an existing file) and you do not want your output file to have a default base name.

-font reference_font

Specifies a reference font. The reference font is the name of a font that is available on the current display. Use the xlsfonts command (see xlsfonts(1X)) to determine which fonts are available.

If you use the -font option with the -merge option, reference_font indicates the font with which converted font glyphs are merged.

If you use the -font option without the -merge option, the header of reference_font is used as a reference for generating the header of the standalone output file. Information in reference_font is also used to determine default characters in the standalone output file. A default character is a glyph (usually a square) that appears when the font does not contain any glyphs for a specified code.

-preload preload_font

Specifies the input file (created by the cgen -pre command).

Use this option when you want to specify the preload_font argument at an arbitrary position in the fontconverter command line. You can omit -preload when placing preload_font at the end of the command line.

B.3.2    Controlling Output File Format

X and Motif applications require loadable fonts in PCF format.

If you do not use the -merge option, the fontconverter command creates standalone font files in both PCF and BDF format. When you specify the -merge option, the command merges converted fonts with the standard PCF font specified by the -font option and creates a standalone file only in PCF format.

When you merge UDC fonts with standard fonts, you can use the combined file with all Motif applications.

When you create independent font files, you can use the fonts with applications that explicitly load the file. If the font registry is one of the UDC registries for a particular locale, you can also use the files with standard system applications.

Note that fontconverter processing time is longer when you merge fonts into an existing font file as compared to when you create independent files.

The following example:

% fontconverter -merge -font \
-jdecw-screen-medium-r-normal--24-240-75-75-m-240-jisx0208-kanji11 \
udc_font.pre

The following command:

% fontconverter -udc deckanji.udc -font \
-jdecw-screen-medium-r-normal--24-240-75-75-m-240-jisx0208-kanji11 \
udc_font.pre