Function Reference


GUISetFont

Sets the default font for a GUI window.

GUISetFont ( size [, weight [, attribute [, fontname [, winhandle [, quality]]]]] )

Parameters

size Fontsize (default is 8.5).
weight [optional] The weight of the font in the range 0 through 1000. For example, 400 is normal and 700 is bold. If this value is zero, a default weight is used.
The following values are defined for convenience.
    $FW_DONTCARE = 0 (Use the default font weight)
    $FW_THIN = 100
    $FW_EXTRALIGHT = 200
    $FW_LIGHT = 300
    $FW_NORMAL = 400
    $FW_MEDIUM = 500
    $FW_SEMIBOLD = 600
    $FW_BOLD = 700
    $FW_EXTRABOLD = 800
    $FW_HEAVY = 900

Constants are defined in FontConstants.au3.
attribute [optional] Font attributes, which can be a combination of the following added together:
    $GUI_FONTNORMAL (0) = Normal (Default)
    $GUI_FONTITALIC (2) = Italic
    $GUI_FONTUNDER (4) = Underlined
    $GUI_FONTSTRIKE (8) = Strike

Constants are defined in GUIConstantsEx.au3.
fontname [optional] Font to use. (OS default GUI font is used if the font is "" or is not found).
winhandle [optional] Windows handle as returned by GUICreate() (default is the previously used window).
quality [optional] Font quality to select. The following qualities are accepted:
    $DEFAULT_QUALITY (0) = Appearance of the font does not matter (Default).
    $DRAFT_QUALITY (1) = Appearance of the font is less important than when $PROOF_QUALITY is used. For GDI raster fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
    $PROOF_QUALITY (2) = (default) Character quality of the font is more important than exact matching of the logical-font attributes. For GDI raster fonts, scaling is disabled and the font closest in size is chosen. Although the chosen font size may not be mapped exactly when $PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance. Bold, italic, underline, and strikeout fonts are synthesized if necessary.
    $NONANTIALIASED_QUALITY (3) = Font is never anti aliased.
    $ANTIALIASED_QUALITY (4) = Font is always anti aliased if the font supports it and the size of the font is not too small or too large.
    $CLEARTYPE_QUALITY (5) = If set, text is rendered (when possible) using ClearType anti aliasing method. See the remarks on the MSDN page for LOGFONT for details about when ClearType is not available.
If neither $ANTIALIASED_QUALITY nor $NONANTIALIASED_QUALITY is selected, the font is anti aliased only if the user chooses smooth screen fonts in Control Panel.
Constants are defined in FontConstants.au3

Return Value

Success: 1.
Failure: 0.

Remarks

See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

Size can contain a decimal as in 8.5.

For some control as label ones the default can be 8.5 instead of 9 according to Windows Theme Values.

For Quality parameter check MSDN, some Windows XP installation need CLEARTYPE_QUALITY=5

Related

GUICtrlSetFont

Example

#include <GUIConstantsEx.au3>
#include <FontConstants.au3>

Example()

Func Example()
    GUICreate("My GUI default font") ; will create a dialog box that when displayed is centered

    Local $sFont = "Comic Sans MS"
    GUISetFont(9,  $FW_NORMAL, $GUI_FONTUNDER, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("underlined label", 10, 20)

    GUISetFont(9,  $FW_NORMAL, $GUI_FONTITALIC, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("italic label", 10, 40)

    GUISetFont(9,  $FW_NORMAL, $GUI_FONTSTRIKE, $sFont) ; will display underlined characters
    GUICtrlCreateLabel("strike label", 10, 60)

    GUISetState(@SW_SHOW)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete()
EndFunc   ;==>Example