# Function Reference

# _WinAPI_CreateFont

Creates a logical font with the specified characteristics

#include <WinAPIGdi.au3>
_WinAPI_CreateFont ( $iHeight, $iWidth [, $iEscape = 0 [, $iOrientn = 0 [, $iWeight = $FW_NORMAL [, $bItalic = False [, $bUnderline = False [, $bStrikeout = False [, $iCharset = $DEFAULT_CHARSET [, $iOutputPrec = $OUT_DEFAULT_PRECIS [, $iClipPrec = $CLIP_DEFAULT_PRECIS [, $iQuality = $DEFAULT_QUALITY [, $iPitch = $FF_DONTCARE [, $sFace = 'Arial']]]]]]]]]]]] )

## Parameters

$iHeight | height of font
$iWidth | average character width
$iEscape | [optional] angle of escapement
$iOrientn | [optional] base-line orientation angle
$iWeight | [optional] font weight, The following values are defined for convenience: $FW_DONTCARE - 0 $FW_THIN - 100 $FW_EXTRALIGHT - 200 $FW_LIGHT - 300 $FW_NORMAL - 400 (Default) $FW_MEDIUM - 500 $FW_SEMIBOLD - 600 $FW_BOLD - 700 $FW_EXTRABOLD - 800 $FW_HEAVY - 900
$bItalic | [optional] italic attribute option
$bUnderline | [optional] underline attribute option
$bStrikeout | [optional] strikeout attribute option
$iCharset | [optional] Specifies the character set. The following values are predefined: $ANSI_CHARSET - 0 $BALTIC_CHARSET - 186 $CHINESEBIG5_CHARSET - 136 $DEFAULT_CHARSET - 1 (Default) $EASTEUROPE_CHARSET - 238 $GB2312_CHARSET - 134 $GREEK_CHARSET - 161 $HANGEUL_CHARSET - 129 $MAC_CHARSET - 77 $OEM_CHARSET - 255 $RUSSIAN_CHARSET - 204 $SHIFTJIS_CHARSET - 128 $SYMBOL_CHARSET - 2 $TURKISH_CHARSET - 162 $VIETNAMESE_CHARSET - 163
$iOutputPrec | [optional] Specifies the output precision, It can be one of the following values: $OUT_CHARACTER_PRECIS - Not used $OUT_DEFAULT_PRECIS - Specifies the default font mapper behavior (Default) $OUT_DEVICE_PRECIS - Instructs the font mapper to choose a Device font when the system contains multiple fonts with the same name $OUT_OUTLINE_PRECIS - This value instructs the font mapper to choose from TrueType and other outline-based fonts $OUT_PS_ONLY_PRECIS - Instructs the font mapper to choose from only PostScript fonts. If there are no PostScript fonts installed in the system, the font mapper returns to default behavior $OUT_RASTER_PRECIS - Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name $OUT_STRING_PRECIS - This value is not used by the font mapper, but it is returned when raster fonts are enumerated $OUT_STROKE_PRECIS - This value is not used by the font mapper, but it is returned when TrueType, other outline-based fonts, and vector fonts are enumerated $OUT_TT_ONLY_PRECIS - Instructs the font mapper to choose from only TrueType fonts. If there are no TrueType fonts installed in the system, the font mapper returns to default behavior $OUT_TT_PRECIS - Instructs the font mapper to choose a TrueType font when the system contains multiple fonts with the same name
$iClipPrec | [optional] Specifies the clipping precision, It can be one or more of the following values: $CLIP_CHARACTER_PRECIS - Not used $CLIP_DEFAULT_PRECIS - Specifies default clipping behavior (Default) $CLIP_EMBEDDED - You must specify this flag to use an embedded read-only font $CLIP_LH_ANGLES - When this value is used, the rotation for all fonts depends on whether the orientation of the coordinate system is left-handed or right-handed. If not used, device fonts always rotate counterclockwise, but the rotation of other fonts is dependent on the orientation of the coordinate system. $CLIP_MASK - Not used $CLIP_STROKE_PRECIS - Not used by the font mapper, but is returned when raster, vector, or TrueType fonts are enumerated For compatibility, this value is always returned when enumerating fonts $CLIP_TT_ALWAYS - Not used
$iQuality | [optional] Specifies the output quality, It can be one of the following values: $ANTIALIASED_QUALITY - Font is antialiased, or smoothed, if the font supports it and the size of the font is not too small or too large. In addition, you must select a TrueType font into a screen DC prior to using it in a DIBSection, otherwise antialiasing does not happen $DEFAULT_QUALITY - Appearance of the font does not matter (Default) $DRAFT_QUALITY - Appearance of the font is less important than when the PROOF_QUALITY value 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 $NONANTIALIASED_QUALITY - Font is never antialiased, that is, font smoothing is not done $PROOF_QUALITY - 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
$iPitch | [optional] Specifies the pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values: $DEFAULT_PITCH, $FIXED_PITCH, $VARIABLE_PITCH The four high-order bits specify the font family and can be one of the following values: $FF_DECORATIVE - Novelty fonts. Old English is an example $FF_DONTCARE - Use default font (Default) $FF_MODERN - Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier New are examples $FF_ROMAN - Fonts with variable stroke width and with serifs. MS Serif is an example $FF_SCRIPT - Fonts designed to look like handwriting. Script and Cursive are examples $FF_SWISS - Fonts with variable stroke width and without serifs. MS Sans Serif is an example
$sFace | [optional] typeface name

## Return Value

Success: | The handle to a logical font
Failure: | 0

## Remarks

When you no longer need the font, call the _WinAPI_DeleteObject() function to delete it
Above constants require #include <FontConstants.au3>

## See Also

Search CreateFont in MSDN Library.

## Example

    #include <FontConstants.au3>
    #include <StructureConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIGdiDC.au3>
    #include <WinAPIHObj.au3>
    #include <WinAPISysWin.au3>

    Global $g_tRECT, $g_hFont, $g_hOldFont, $g_hDC

    HotKeySet("{ESC}", "_Exit")

    $g_tRECT = DllStructCreate($tagRect)
    DllStructSetData($g_tRECT, "Left", 5)
    DllStructSetData($g_tRECT, "Top", 5)
    DllStructSetData($g_tRECT, "Right", 250)
    DllStructSetData($g_tRECT, "Bottom", 50)

    $g_hDC = _WinAPI_GetDC(0)
    $g_hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
            $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
    $g_hOldFont = _WinAPI_SelectObject($g_hDC, $g_hFont)

    _WinAPI_SetTextColor($g_hDC, 0x0000FF)
    _WinAPI_SetBkColor($g_hDC, 0x000000)
    ; comment next line to get black background instead of transparent one
    _WinAPI_SetBkMode($g_hDC, $TRANSPARENT)

    While 1
        _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER)
        Sleep(100)
    WEnd

    Func _Exit()
        _WinAPI_SelectObject($g_hDC, $g_hOldFont)
        _WinAPI_DeleteObject($g_hFont)
        _WinAPI_ReleaseDC(0, $g_hDC)
        _WinAPI_InvalidateRect(0, 0)
        $g_tRECT = 0
        Exit
    EndFunc   ;==>_Exit