Motif permits users to modify a large number of text properties. The color, fonts, and size of text are all accessible through the modification of resources, as well as tab stops and some miscellaneous other properties such as underlining and strike-through. The data structure controlling these properties is called a rendition and is introduced in the following section.
Note: | While Motif may allow a user to modify many different aspects of text display, there is no guarantee that a particular application program will continue to function properly once such a modification is made. For example, a user may change the color of some text so that it matches the background color perfectly. This user should not then be surprised that the text in question is rendered illegible. When modifying the resources for an application, it is best to proceed with caution, and with the program's documentation at hand. |
A rendition is simply a collection of all the information necessary to render text. Each segment of text on display (segments can be as long or as short as circumstances warrant) is tagged with a "tag," indicating which of a list of possible renditions is to be used for that text. That list, containing one or more renditions, is called a render table and is described in Section 7.1.2.
Note: | Some of the Motif widgets used for text input do not use renditions. This means that a user can change the fonts used in these widgets but not the color or tabs or other rendition properties. In these cases, a font list structure is available that is analogous to the render table. |
A rendition is neither a widget nor a gadget. However, the style used to specify resources for widgets and gadgets is a simple and familiar way to set data values, and it has been implemented for renditions and render tables as well. To change the foreground color for a rendition, for example, a user must set a "resource" called renditionForeground for that rendition, in the same way a user would change the color resource for some widget.
A rendition can have any of the following resources:
Any of these resources (except tag, tabList, and fontType) can have the value AS_IS, which specifies that the resource take its default value, which is usually inherited from the parent widget. If a tabList resource is missing, the widget will usually have default tab stops set. Note that the application foreground and background use unspecified pixel colors.
A font is typically identified by such characteristics as its family, point size, weight, slant, and character set. Sometimes a single font may be used to display a given language, as in English, Swedish, Italian, Greek, and most other alphabetic languages. However, some languages may require more than one font to display its characters. A font set is a set of one or more fonts used to display a single language. Fonts from the set are loaded according to a list of base font names supplied by the application and the character sets required by the locale.
A fontName can be an X Logical Font Description (XLFD) string, or a site-specific name of a font. When specifying fonts, you can provide a detailed description for a given font, or you can use the * (asterisk) wildcard to indicate fields whose values can be selected by the font-loading routines called by an application. The following resource entry specifies a 12-point Courier font that can be of any weight, slant, or set width. The font is to be part of a rendition called rend1.
*renderTable.rend1.fontName: -Adobe-Courier-*-*-*--12-120-100-100-*-* *renderTable.rend1.fontType: FONT_IS_FONT
The following example specifies a font set for an application running in a Japanese language environment. The font set contains three fonts in a comma-separated list.
*renderTable.rend1.fontName: -JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240,\ -JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120,\ -Adobe-Courier-Bold-R-Normal--24-240-100-100-M-100 *renderTable.rend1.fontType: FONT_IS_FONTSET
By definition, when an application creates a font set, the character sets used to display the text in the current locale are automatically established. The advantage of supplying a font set is that you do not need to know the character sets required by the locale; the system determines them for you.
Whether you need to specify fonts or font sets for a font resource is application dependent. Internationalized applications can adopt different approaches to setting the language environment and handling text display. Certain applications can require that you explicitly specify a font, including its character set. Consult the documentation for an application if you need to specify any font resources.
To create a tab stop in a resource file, use the following syntax:
resource_spec: tab [, tab ]*
The resource value string consists of one or more tabs separated by commas. Each tab identifies the value of the tab, the unit type, and whether the offset is relative or absolute. The tab stop specification uses the following syntax:
tab = [ + ] float [ units ]
The tab contains a decimal number ( float), and an indication of the units to be used. If no units are specified, the default unit is pixels. The presence or absence of a sign indicates, respectively, a relative offset or an absolute offset model. A relative tab stop is measured from the previous tab stop in the list, while an absolute tab stop is measured from the left margin (or the right margin if the layout direction is right-to-left). Note that negative tab values are not permitted and that, if a tab stop would cause two segments of text to be overwritten, the x position of one segment will be moved (the tab will be ignored).
For example, the following line of a resource file sets a tab list for a rendition (rend1) in a render table used by a widget called List. It specifies a tab list consisting of a 1-inch absolute tab followed by a 1-inch relative tab (equivalent to a 2-inch absolute tab, unless and until a third tab is inserted between the two).
*List.renderTable.rend1.tabList: 1in, +1in
The recognized units and their abbreviations include the following:
Please refer to the Motif Programmer's Guide for a definition of font units, and for more information about tab lists.
Render tables are specified in resource files with the following syntax:
resource_spec: [ tag [, tag ]* ]
where tag is some string suitable to be the name of a rendition. This line creates an initial render table containing one more rendition than the number of tags specified. The renditions are attached to the specified tags, with the untagged rendition going with the tag _MOTIF_DEFAULT_LOCALE. If no tags are specified, then a render table will be created that contains only a rendition with a tag of _MOTIF_DEFAULT_LOCALE.
Specific values for specific rendition resources are specified using the following syntax:
resource_spec [*|.] rendition[*|.] resource_name: value
where resource_spec specifies the render table, rendition is a tag (or is omitted), resource_name is the name of a particular resource, and value is the specification of the value to be set.
Any resource line that consists of just a resource name or class component with no rendition component will be assumed to specify resource values for a rendition with a tag of _MOTIF_DEFAULT_LOCALE.
For example, the following:
*List.renderTable: green, variable *List.renderTable.green.renditionForeground: Green *List.renderTable.green.fontName: AS_IS *List.renderTable.variable.underlineType: SINGLE_LINE *List.renderTable.variable.renditionForeground: Red *List.renderTable.variable.fontName: variable *List.renderTable.variable.fontType: FONT_IS_FONT *List.renderTable.variable.underlineType: DOUBLE_LINE *List.renderTable.renditionForegound: black *List.renderTable.fontName: fixed *List.renderTable.fontType: FONT_IS_FONT *List.renderTable.variable.underlineType: NO_LINE *List.renderTable*tabList: 1in, +1.5in, +3in
would set the renderTable resource of List to a render table consisting of three renditions tagged with _MOTIF_DEFAULT_LOCALE, green, and variable with values for resources set as described in the resource specifications. Note that the tabList resource will be shared by all three renditions.