Common Desktop Environment: Internationalization Programmer's Guide

Font Set and Font List Syntax

Table 2-1 shows the syntax for a font set and font list.

Table 2-1 Font Set and Font List Syntax

Resource Type 

XLFD Separator 

Terminator 

FontEntry Separator 

*fontSet: (Xlib)

comma 

None 

None 

*fontList: (Motif)

semicolon 

colon 

comma 

Here are some examples of font resource specifications:

app_foo*fontList: -adobe-courier-medium-r-normal--24-240-75-75-m-\  150-*:

The preceding fontList specifies a fontset, consisting of one or more 24-point Adobe Courier fonts, as appropriate for the user's locale.

app_foo*fontList: -adobe-courier-medium-r-normal--18-*; *-gothic-\  *-18-*:

This fontList 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.

Motif-based applications sometimes need direct access to the font set contained in a font list. For example, an application that uses a DrawingArea widget may want to label one of the images drawn there. The following sample code shows how to extract a font set from a font list. In this example, the tag XmFONTLIST_DEFAULT_TAG looks for the font set because this is the tag that says "codeset of the locale." Applications should use the tag XmFONTLIST_DEFAULT_TAG for any string that could contain localized data.

XFontSet FontList2FontSet( XmFontList fontlist)  
{  
XmFontContext context;
 XmFontListEntry next_entry;  
XmFontType type_return = XmFONT_IS_FONT;  
char* font_tag;  
XFontSet fontset;  
XFontSet first_fontset;  
Boolean have_font_set = False;   

if ( !XmFontListInitFontContext(&context, fontlist)) {
		 XtWarning("fl2fs: can't create fontlist context...");
		 exit 0;  
}   

while ((next_entry = XmFontListNextEntry(context) != NULL) {
  fontset = (XFontSet) XmFontListEntryGetFont(next_entry,
				 &type_return);
  if (type_return == XmFONT_IS_FONTSET ) {
  		font_tag = XmFontListEntryGetTag(next_entry);

      if (!strcmp(XmFONTLIST_DEFAULT_TAG, font_tag) {
              return fontset;
      }
      /* Remember the 1st fontset, just in case... */
      if (!have_font_set) {
              first_fontset = fontset;
					  have_font_set = True;
      }
   }
}  
if (have_font_set)
      return first_fontset;  
return (XFontSet)NULL; 
}