Previous  Next

TextSetFont

The function sets the font for displaying the text using drawing methods and returns the result of that operation. Arial font with the size -120 (12 pt) is used by default.

bool  TextSetFont(
   const string  name,            // font name or path to font file on the disk
   int           size,            // font size
   uint          flags,           // combination of flags
   int           orientation=0    // text slope angle
   );

Parameters

name

[in]  Font name in the system or the name of the resource containing the font or the path to font file on the disk.

size

[in]  The font size that can be set using positive and negative values. In case of positive values, the size of a displayed text does not depend on the operating system's font size settings. In case of negative values, the value is set in tenths of a point and the text size depends on the operating system settings ("standard scale" or "large scale"). See the Note below for more information about the differences between the modes.

flags

[in]  Combination of flags describing font style.

orientation

[in]  Text's horizontal inclination to X axis, the unit of measurement is 0.1 degrees. It means that orientation=450 stands for inclination equal to 45 degrees.

Return Value

Returns true if the current font is successfully installed, otherwise false. Possible code errors:

Note

If "::" is used in font name, the font is downloaded from EX5 resource. If name font name is specified with an extension, the font is downloaded from the file, if the path starts from "\" or "/", the file is searched relative to MQL5 directory. Otherwise, it is searched relative to the path of EX5 file which called TextSetFont() function.

The font size is set using positive or negative values. This fact defines the dependence of the text size from the operating system settings (size scale).

The flags can be used as the combination of style flags with one of the flags specifying the font width. Flag names are shown below.

Flags for specifying font style

Flag

Description

FONT_ITALIC

Italic

FONT_UNDERLINE

Underline

FONT_STRIKEOUT

Strikeout

 

Flags for specifying font width

Flag

FW_DONTCARE

FW_THIN

FW_EXTRALIGHT

FW_ULTRALIGHT

FW_LIGHT

FW_NORMAL

FW_REGULAR

FW_MEDIUM

FW_SEMIBOLD

FW_DEMIBOLD

FW_BOLD

FW_EXTRABOLD

FW_ULTRABOLD

FW_HEAVY

FW_BLACK

See also

Resources, ResourceCreate(), ResourceSave(), TextOut()