| Table of Contents / Graphics / Text | Operators |
set_font — Set the font used for text output.
set_font( : : WindowHandle, Font : )
set_font sets the font for the output window. The font is used by the operators write_string, read_string etc. A default font (which can be set via set_system('default_font',Fontname)) is assigned when a window is opened. The assigned font can be changed with set_font. All available fonts can be queried with query_font. Fonts are not used for file operations.
The syntax for the specification of a font (in Font) differs for UNIX and Windows environments: In Windows 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 beside “FontName” and “Height” are optional, however it is only possible to omit parameters from the end of the string. At the begin and end of the string a minus is required. To use the default setting, a * can be used for the corresponding feature. 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 UNIX 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.
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 is correct. Otherwise an exception is raised.
get_font, query_font, open_textwindow, open_window
Foundation
| Table of Contents / Graphics / Text | Operators |
| HALCON Reference Manual 10.0.2 | Copyright © 1996-2011 MVTec Software GmbH |