Common Desktop Environment: Internationalization Programmer's Guide

Compound Strings and Font Lists

When the desktop displays a compound string, it associates each segment with a font or font set by means of the font list element tag for that segment. The application must have loaded the desired font or font set, created a font list that contains that font or font set and its associated font list element tag, and created the compound string segment with the same tag.

The desktop follows a set search procedure when it binds a compound string to a font list entry in this way:

  1. The desktop searches the font list for an exact match with the font list element tag specified in the compound string. If it finds a match, the compound string is bound to that font list entry.

  2. If this does not provide a binding between the compound string and the font list, the desktop binds the compound string to the first element in the font list, regardless of its font list element tag.

For backward compatibility, if an exact match is not found, a value of XmFONTLIST_DEFAULT_TAG in either a compound string or a font list matches the tag that results from creating a compound string or font list entry with a tag of XmSTRING_DEFAULT_CHARSET.

Figure 4-1 shows the relationships between a compound string, a font set, and a font list when the font list element tag is set to something other than XmFONTLIST_DEFAULT_TAG.

Figure 4-1 Relationships between compound strings, font sets, and font lists when the font list element tag is not XmFONTLIST_DEFAULT_TAG

Graphic

The following example shows how to use a tag called tagb.

XFontSet     *font1;  
XmFontListEntry			font_list_entry; 
 XmFontList font_list;  
XmString label_text;
char**			missing;
int			missing_cnt;
char*			del_string;
char *tagb;				/* Font list element tag */
char *fontx;				/* Initialize to XLFD or font alias */
char *button_label;				/* Contains button label text */
  		.
  		.  
font1 = XCreateFontSet (XtDisplay(toplevel), fontx, & missing,
  		& missing_cnt, & def_string);  
font_list_entry = XmFontListEntryCreate (tagb, XmFONT_IS_FONTSET,
  		(XtPointer)font1);  
font_list = XmFontListAppendEntry (NULL, font_list_entry);  
XmFontListEntryFree (font_list_entry);   
label_text = XmStringCreate (button_label, tagb);

The XCreateFontSet() function loads the font set and the XmFontListEntryCreate() function creates a font list entry. The application must create an entry and append it to an existing font list or create a new font list. In either case, use the XmFontListAppendEntry() function. Because there is no font list in place, the preceding code example has a NULL value for the font list argument. The XmFontListAppendEntry() function creates a new font list called font_list with a single entry, font_list_entry. To add another entry to font_list, follow the same procedure but supply a nonnull font list argument.

Figure 4-2 shows the relationships between a compound string, a font set, and a font list when the font list element tag is set to XmFONTLIST_DEFAULT_TAG. In this case, the value field is locale text.

Figure 4-2 Relationships between compound strings, font sets, and font lists when a font list element tag is set to XmFONTLIST_DEFAULT_TAG

Graphic

Here, the default tag points to Font_Set_C, which in turn identifies the fonts needed to display the characters in the language.