Operators |
set_font — Set the font used for text output.
set_font( : : WindowHandle, Font : )
set_font sets the font Font for the output window WindowHandle. All subsequent text outputs (e.g., with the operators write_string or read_string) will now use the new font instead of the default font (see set_system('default_font',Font)). All available fonts can be queried with query_font.
The syntax for the specification of Font differs for Linux, Windows, and OS X environments:
On Windows environments, a string with the following components is used:
-FontName-Height-Width-Italic-Underlined-Strikeout-Bold-CharSet-
where “Italic”, “Underlined”, “Strikeout” and “Bold” can take the values 1 and 0 to activate or deactivate the corresponding feature. “CharSet” can be used to select the character set, if it differs from the default one. You can use the names of the defines ANSI_CHARSET, BALTIC_CHARSET, CHINESEBIG5_CHARSET, DEFAULT_CHARSET, EASTEUROPE_CHARSET, GB2312_CHARSET, GREEK_CHARSET, HANGUL_CHARSET, MAC_CHARSET, OEM_CHARSET, RUSSIAN_CHARSET, SHIFTJIS_CHARSET, SYMBOL_CHARSET, JOHAB_CHARSET, HEBREW_CHARSET, ARABIC_CHARSET, or the integer value.
All parameters are optional, however it is only possible to omit parameters from the end of the string. At the beginning and the end of the string a hyphen is required. To use the default setting, a * can be used for the corresponding feature. If no font with the specified characteristics is available, an alternative font which matches as many parameters as possible is chosen.
Examples:
-Arial-10-*-1-*-*-1-ANSI_CHARSET-
-Arial-10-*-1-*-*-1-
-Arial-10-
Please refer to the Windows documentation (Fonts and Text in the MSDN) for a detailed discussion.
On Linux environments the Font is specified by a string with the following components:
-FOUNDRY-FAMILY_NAME-WEIGHT_NAME-SLANT-SETWIDTH_NAME-ADD_STYLE_NAME -PIXEL_SIZE-POINT_SIZE-RESOLUTION_X-RESOLUTION_Y-SPACING-AVERAGE_WIDTH -CHARSET_REGISTRY-CHARSET_ENCODING,
where FOUNDRY identifies the organisation that supplied the Font. The actual name of Font is given in FAMILY_NAME (e.g. 'courier'). WEIGHT_NAME describes the typographic weight of the Font in human readable form (e.g. 'medium', 'semibold', 'demibold', or 'bold'). SLANT is one of the following codes:
r for Roman
i for Italic
o for Oblique
ri for Reverse Italic
ro for Reverse Oblique
ot for Other
SET_WIDTH_NAME describes the proportionate width of the font (e.g. 'normal'). ADD_STYLE_NAME identifies additional typographic style information (e.g. 'serif' or 'sans serif') and is empty in most cases.
The PIXEL_SIZE is the height of the Font on the screen in pixel, while POINT_SIZE is the print size the Font was designed for. RESOLUTION_Y and RESOLUTION_X contain the vertical and horizontal Resolution of the Font. SPACING may be one of the following three codes:
p for Proportional,
m for Monospaced, or
c for CharCell.
The AVERAGE_WIDTH is the mean of the width of each character in Font. The character set encoded in Font is described in CHARSET_REGISTRY and CHARSET_ENCODING (e.g. ISO8859-1).
An example of a valid string for Font would be
'-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1',
which is a 12px medium weighted courier font. As on Windows systems not all fields have to be specified and a * can be used instead:
'-adobe-courier-medium-r-*--12-*-*-*-*-*-*-*'.
Please refer to "X Logical Font Description Conventions" for detailed information on individual parameters.
On OS X environments, the Font is specified by a string with the following components:
FONTNAME[-STYLE][FOUNDRY]-FONT_SIZE.
As it is not possible to use wildcards on OS X, please refer to query_font for available fonts.
The optional STYLE may be one of the following (other values are possible as well):
Bold
BoldItalic, or
Italic.
FOUNDRY (also optional) may be LT, MT, or EF. The FONT_SIZE is the size of the font in pixel.
An example of a valid string for Font would be
'Courier-Bold-14'.
For different machines the available fonts may differ a lot. Therefore it is suggested to use wildcards, tables of fonts and/or the operator query_font.
Window identifier.
Name of new font.
get_system ('operating_system', OS) if (OS{0:2} == 'Win') set_font (WindowHandle, '-Courier New-18-*-*-*-*-1-') else set_font (WindowHandle, '-*-courier-bold-r-normal--22-*-*-*-*-*-iso8859-1') endif
set_font returns 2 (H_MSG_TRUE) if the font name can be resolved. Otherwise an exception is raised.
get_font, query_font, open_textwindow, open_window
Foundation
Operators |