HALCON Reference Manual 10.0.2
Table of Contents / Graphics / Text ClassesClassesClasses | | | Operators

set_fontset_fontset_fontSetFontSetFont (Operator)

Name

set_fontset_fontset_fontSetFontSetFont — Set the font used for text output.

Signature

set_font( : : WindowHandle, Font : )

Herror set_font(const Hlong WindowHandle, const char* Font)

Herror T_set_font(const Htuple WindowHandle, const Htuple Font)

Herror set_font(const HTuple& WindowHandle, const HTuple& Font)

void HWindow::SetFont(const HTuple& Font) const

void HOperatorSetX.SetFont(
[in] VARIANT WindowHandle, [in] VARIANT Font)

void HWindowX.SetFont([in] BSTR Font)

static void HOperatorSet.SetFont(HTuple windowHandle, HTuple font)

void HWindow.SetFont(string font)

Description

set_fontset_fontset_fontSetFontSetFont sets the font for the output window. The font is used by the operators write_stringwrite_stringwrite_stringWriteStringWriteString, read_stringread_stringread_stringReadStringReadString etc. A default font (which can be set via set_system('default_font',Fontname)set_system("default_font",Fontname)set_system("default_font",Fontname)SetSystem("default_font",Fontname)SetSystem("default_font",Fontname)) is assigned when a window is opened. The assigned font can be changed with set_fontset_fontset_fontSetFontSetFont. All available fonts can be queried with query_fontquery_fontquery_fontQueryFontQueryFont. Fonts are not used for file operations.

The syntax for the specification of a font (in FontFontFontFontfont) 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:

Please refer to the Windows documentation (Fonts and Text in the MSDN) for a detailed discussion.

On UNIX environments the FontFontFontFontfont 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 FontFontFontFontfont. The actual name of FontFontFontFontfont is given in FAMILY_NAME (e.g. 'courier'). WEIGHT_NAME describes the typographic weight of the FontFontFontFontfont in human readable form (e.g. 'medium', 'semibold', 'demibold', or 'bold'). SLANT is one of the following codes:

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 FontFontFontFontfont on the screen in pixel, while POINT_SIZE is the print size the FontFontFontFontfont was designed for. RESOLUTION_Y and RESOLUTION_X contain the vertical and horizontal Resolution of the FontFontFontFontfont. SPACING may be one of the following three codes:

The AVERAGE_WIDTH is the mean of the width of each character in FontFontFontFontfont. The character set encoded in FontFontFontFontfont is described in CHARSET_REGISTRY and CHARSET_ENCODING (e.g. ISO8859-1).

An example of a valid string for FontFontFontFontfont 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.

Attention

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_fontquery_fontquery_fontQueryFontQueryFont.

Parallelization

Parameters

WindowHandleWindowHandleWindowHandleWindowHandlewindowHandle (input_control)  window HWindow, HTupleHTupleHWindowX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong)

Window identifier.

FontFontFontFontfont (input_control)  string HTupleHTupleVARIANTHtuple (string) (string) (char*) (BSTR) (char*)

Name of new font.

Example (HDevelop)

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

Result

set_fontset_fontset_fontSetFontSetFont returns 2 (H_MSG_TRUE) if the font name is correct. Otherwise an exception is raised.

Possible Predecessors

open_windowopen_windowopen_windowOpenWindowOpenWindow, open_textwindowopen_textwindowopen_textwindowOpenTextwindowOpenTextwindow

Possible Successors

query_fontquery_fontquery_fontQueryFontQueryFont

See also

get_fontget_fontget_fontGetFontGetFont, query_fontquery_fontquery_fontQueryFontQueryFont, open_textwindowopen_textwindowopen_textwindowOpenTextwindowOpenTextwindow, open_windowopen_windowopen_windowOpenWindowOpenWindow

Module

Foundation


Table of Contents / Graphics / Text ClassesClassesClasses | | | Operators
HALCON Reference Manual 10.0.2 Copyright © 1996-2011 MVTec Software GmbH