# Function Reference

# GUICtrlSetFont

Sets the font for a control.

GUICtrlSetFont ( controlID, size [, weight [, attribute [, fontname [, quality]]]] )

## Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate...() function, or -1 for the last created control.
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 $GUI_FONTITALIC (2) = Italic $GUI_FONTUNDER (4) = Underlined $GUI_FONTSTRIKE (8) = Strike Constants are defined in GUIConstantsEx.au3.
fontname | [optional] Name of the font to use. (OS default GUI font is used if the font is "" or is not found).
quality | [optional] Font quality to select. The following qualities are accepted: $DEFAULT_QUALITY (0) = Appearance of the font does not matter. $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 antialiased. $ANTIALIASED_QUALITY (4) = Font is always antialiased 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 antialiasing 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 antialiased only if the user chooses smooth screen fonts in Control Panel. Constants are defined in FontConstants.au3

## Return Value

Success: | 1.
Failure: | 0.

## Remarks

By default, controls use the font set by GUISetFont().
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 controls such as labels, the default size 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

GUICtrlCreate..., GUISetFont

## Example

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

    Example()

    Func Example()
        ; Font type to be used for setting the font of the controls.
        Local Const $sFont = "Comic Sans Ms"

        ; Create a GUI with various controls.
        Local $hGUI = GUICreate("Example", 300, 200)

        ; Create label controls.
        GUICtrlCreateLabel("A string of text underlined", 10, 10, 185, 17)
        GUICtrlSetFont(-1, 9, $FW_NORMAL, $GUI_FONTUNDER, $sFont) ; Set the font of the previous control.

        Local $idLabel2 = GUICtrlCreateLabel("A string of italic text", 10, 30, 185, 17)
        GUICtrlSetFont($idLabel2, 9, $FW_NORMAL, $GUI_FONTITALIC, $sFont)  ; Set the font of the controlID stored in $iLabel2.

        Local $idLabel3 = GUICtrlCreateLabel("A string of text with a strike through", 10, 50, 290, 17)
        GUICtrlSetFont($idLabel3, 9, $FW_NORMAL, $GUI_FONTSTRIKE, $sFont) ; Set the font of the controlID stored in $iLabel3.

        Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)

        ; Display the GUI.
        GUISetState(@SW_SHOW, $hGUI)

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

            EndSwitch
        WEnd

        ; Delete the previous GUI and all controls.
        GUIDelete($hGUI)
    EndFunc   ;==>Example