ClassesClassesClassesClasses | | | | Operators

set_fontset_fontSetFontset_fontSetFontSetFont (Operator)


set_fontset_fontSetFontset_fontSetFontSetFont — Set the font used for text output.


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 SetFont(const HTuple& WindowHandle, const HTuple& Font)

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

void HWindow::SetFont(const char* 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)


set_fontset_fontSetFontset_fontSetFontSetFont sets the font for the output window. The font is used by the operators write_stringwrite_stringWriteStringwrite_stringWriteStringWriteString, read_stringread_stringReadStringread_stringReadStringReadString etc. A default font (which can be set via set_system('default_font',Fontname)set_system("default_font",Fontname)SetSystem("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_fontSetFontset_fontSetFontSetFont. All available fonts can be queried with query_fontquery_fontQueryFontquery_fontQueryFontQueryFont. Fonts are not used for file operations.

The syntax for the specification of a font (in FontFontFontFontFontfont) differs for Linux, Windows, and OS X environments:

Windows environments

On Windows environments, a string with the following components is used:


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


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

Linux environments

On Linux environments the FontFontFontFontFontfont is specified by a string with the following components:


where FOUNDRY identifies the organisation that supplied the FontFontFontFontFontfont. The actual name of FontFontFontFontFontfont is given in FAMILY_NAME (e.g. 'courier'). WEIGHT_NAME describes the typographic weight of the FontFontFontFontFontfont 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 FontFontFontFontFontfont on the screen in pixel, while POINT_SIZE is the print size the FontFontFontFontFontfont was designed for. RESOLUTION_Y and RESOLUTION_X contain the vertical and horizontal Resolution of the FontFontFontFontFontfont. SPACING may be one of the following three codes:

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

An example of a valid string for FontFontFontFontFontfont would be


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:


Please refer to "X Logical Font Description Conventions" for detailed information on individual parameters.

OS X environments

On OS X environments, the FontFontFontFontFontfont is specified by a string with the following components:


As it is not possible to use wildcards on Mac OS X, please refer to query_fontquery_fontQueryFontquery_fontQueryFontQueryFont for available fonts.

The optional STYLE may be one of the following (other values are possible as well):

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 FontFontFontFontFontfont would be



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



WindowHandleWindowHandleWindowHandleWindowHandleWindowHandlewindowHandle (input_control)  window HWindow, HTupleHTupleHTupleHWindowX, VARIANTHtuple (integer) (IntPtr) (Hlong) (Hlong) (Hlong) (Hlong)

Window identifier.

FontFontFontFontFontfont (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (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-')
  set_font (WindowHandle, '-*-courier-bold-r-normal--22-*-*-*-*-*-iso8859-1')


set_fontset_fontSetFontset_fontSetFontSetFont returns 2 (H_MSG_TRUE) if the font name can be resolved. Otherwise an exception is raised.

Possible Predecessors

open_windowopen_windowOpenWindowopen_windowOpenWindowOpenWindow, open_textwindowopen_textwindowOpenTextwindowopen_textwindowOpenTextwindowOpenTextwindow

Possible Successors


See also

get_fontget_fontGetFontget_fontGetFontGetFont, query_fontquery_fontQueryFontquery_fontQueryFontQueryFont, open_textwindowopen_textwindowOpenTextwindowopen_textwindowOpenTextwindowOpenTextwindow, open_windowopen_windowOpenWindowopen_windowOpenWindowOpenWindow



ClassesClassesClassesClasses | | | | Operators