HPlogo HP Xlib Extensions: > Chapter 7 Internationalization Support

Internationalized Output

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

X11 R5 provides support for internationalized output through the use of font sets, which are accessed through XCreateFontSet and its associated routines. That X standard capability should be used instead of the associate font mechanism explained in this chapter.

The associate font mechanism explained here was provided by HP to support internationalized text output before the X standard supported this functionality. The HP associate font mechanism is provided to maintain compatibility with software that still uses the HP associate font mechanism for internationalized output. However, this mechanism will be removed from the library at the next major release of HP-UX.

Associate Font Support

Xlib provides transparent text handling capability, including mixed 8-bit and 16-bit characters, for the following six Xlib functions:

  • XTextWidth

  • XTextExtents

  • XQueryTextExtents

  • XDrawText

  • XDrawString

  • XDrawImageString

In order to allow these functions to support mixed 8-bit and 16-bit characters, the following functions will concurrently load and unload separate 8-bit (font) and 16-bit (associate font) files.

  • XLoadFont

  • XQueryFont

  • XLoadQueryFont

  • XFreeFont

  • XUnloadFont

If the following conditions are fulfilled when loading a font with XLoadFont or XLoadQueryFont, an 8- and 16-bit mixed font will be loaded by Xlib, until XFreeFont or XUnloadFont are called.

  1. There exists a language designation in the specified font.

    The XLoadFont and XLoadQueryFont functions look for the language designation in the following order:

    • First examine the value of the font property LANGUAGE. This is an 8-bit STRING type property.

    • Next examine the value of the environment variable LANG. Currently, japanese, japanese.euc, korean, chinese-s, and chinese-t are supported as valid LANGUAGE property or LANG environment variable designations.

  2. There exists the associate font designation in the specified font.

    XLoadFont and XLoadQueryFont look for the associate font in the following order:

    • First examine the value of the font property ASSOCIATE_FONT. This is an 8-bit STRING type property.

    • Next examine the value of the environment variable XASSOCFONT.

In summary, XLoadFont and XLoadQueryFont look for the font properties LANGUAGE and ASSOCIATE_FONT in the specified font first. If either or both are undefined, then the environment variables LANG and XASSOCFONT are examined instead.

If the logically mixed font is implicitly specified as the font argument for XTextWidth, XTextExtents, XQueryTextExtents, XDrawText, XDrawString, or XDrawImageString, then the string argument for these functions may point to a string containing mixed 8- and 16-bit characters encoded by HP-15 or EUC. Otherwise, all the characters will be interpreted as 8-bit characters. This provides transparency with standard X11 fonts.

Getting the Associate Font

For a specified font, which includes both the language and the associate font designations, XQueryFont and XLoadQueryFont return a pointer to the XFontStruct structure of the specified font. To obtain the XFontStruct of the associate font, use the XHPGet16bitMixedFontStruct.

XFontStruct *XHPGet16bitMixedFontStruct(font)
Font font;

Title not available (Getting the Associate Font )

font

Specifies the font ID.

If the specified font is a mixed 8- and 16-bit font, XHPGet16bitMixedFontStruct returns a pointer to an XFontStruct structure of the associated font. If the specified font is not an 8- and 16-bit mixed font, then NULL is returned.

The XFontStruct structure returned by this function may not be freed.

Checking for 16-bit Characters

To determine if two bytes are defined as a 16-bit character for a specified font, use XHPIs16bitCharacter.

Bool XHPIs16bitCharacter(font, byte1, byte2)
Font font;
unsigned char byte1,
byte2;

Title not available (Checking for 16-bit Characters )

font

Specifies the font to check for a 16-bit character.

byte1

Specifies the first byte of a 16-bit character.

byte2

Specifies the second byte of a 16-bit character.

XHPIs16bitCharacter returns True if byte1 and byte2 are defined as the first and second bytes of a 16-bit character. In this function, the 16-bit character is based on HP-15 or EUC encoding determined by the language designation included in the specified font.

This function should not be called for EUC data in HP-UX 10.0 or later releases, since EUC characters can then consist of 24-bit or 32-bit values. Results of this routine on such data is undefined.

Conversions Between X11 Keysyms and HP Roman 8 Codes

To convert an X11 Keysym into an HP Roman 8 character, use the XHPKeysymToRoman8 function.

int XHPKeysymToRoman8(keysym, r8_return)
Keysym keysym;
char *r8_return; /* RETURN */

Title not available (Conversions Between X11 Keysyms and HP Roman 8 Codes)

keysym

Specifies an X11 KeySym.

r8_return

Specifies a pointer to a location to receive the converted Roman 8 character to keysym, if any.

XHPKeysymToRoman8 takes an X11 KeySym and converts it to an HP Roman 8 character. The character is returned to the location pointed to by r8_return. If no Roman 8 character for keysym exists, then XHPKeysymToRoman8 returns 0 (zero) and *r8_return remains unchanged.

Some Keysyms are unique to Hewlett-Packard equipment because Roman 8 contains characters that were not encoded in the Keysyms distributed by MIT.

To convert an HP Roman 8 character into an X11 KeySym, use XHPRoman8ToKeysym.

Keysym XHPRoman8ToKeysym(r8_char)
char r8_char;

XHPRoman8ToKeysym takes an HP Roman 8 character and returns a KeySym.

NOTE: Most of the KeySyms returned by XHPRoman8ToKeysym will be ISO Latin-1 and various terminal functions. Two of the characters in the Roman 8 set ('S' with caron and 's' with caron) convert to Keysyms in the ISO Latin-2 set.
© 1995 Hewlett-Packard Development Company, L.P.