Function Reference


_GDIPlus_FontCreate

Create a Font object

#include <GDIPlus.au3>
_GDIPlus_FontCreate ( $hFamily, $fSize [, $iStyle = 0 [, $iUnit = 3]] )

Parameters

$hFamily Handle to a Font Family object
$fSize The size of the font measured in the units specified in the $iUnit parameter
$iStyle [optional] The style of the typeface. Can be a combination of the following:
    0 - Normal weight or thickness of the typeface
    1 - Bold typeface
    2 - Italic typeface
    4 - Underline
    8 - Strikethrough
$iUnit [optional] Unit of measurement for the font size:
    0 - World coordinates, a nonphysical unit
    1 - Display units
    2 - A unit is 1 pixel
    3 - A unit is 1 point or 1/72 inch
    4 - A unit is 1 inch
    5 - A unit is 1/300 inch
    6 - A unit is 1 millimeter

Return Value

Success: a handle to a Font object.
Failure: 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPID_ERR*).

Remarks

When you are done with the Font object, call _GDIPlus_FontDispose() to release the resources.

Related

_GDIPlus_FontDispose

See Also

Search GdipCreateFont in MSDN Library.

Example

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout

    ; Create GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Draw a string
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Clean up resources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example