UDF > GDIPlus > FontPrivate >


_GDIPlus_FontPrivateCreateCollection

Cr�e un objet PrivateFontCollection

#include <GDIPlus.au3>
_GDIPlus_FontPrivateCreateCollection ( )

Valeur de retour

Succ�s: Retourne le handle de l'objet PrivateFontCollection
�chec: Retourne 0 et d�finit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Remarque

Les objets FontFamily appartiennent � la collection, ils ne devraient pas �tre d�truits.
Apr�s en avoir termin� avec l'objet, appelez _GDIPlus_FontPrivateCollectionDispose() pour lib�rer les ressources de l'objet

En relation

_GDIPlus_FontPrivateCollectionDispose, _GDIPlus_FontPrivateAddFont, _GDIPlus_FontFamilyCreateFromCollection

Voir aussi

Consultez GdipNewPrivateFontCollection dans la librairie MSDN.

Exemple

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

Example()

Func Example()
    Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $sFontInternalName, $hCollection, $sFontFile = @WindowsDir & "\Fonts\Times.ttf"

    If _WinAPI_DwmIsCompositionEnabled() Then
        If Not @Compiled Then
            $sFontFile = StringRegExpReplace(@AutoItExe, "(.*)\\.*", "$1")
        Else
            $sFontFile = StringRegExpReplace(RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\AutoItv3", "DisplayIcon"), "(.*)\\.*", "$1")
        EndIf
        If $sFontFile = "" Then Exit MsgBox(BitOR($MB_ICONERROR, $MB_TOPMOST), "Error", "Unable to locate SF Square Head Bold.ttf in AutoIt sub dir!")
        $sFontFile &= "\Examples\Helpfile\Extras\SF Square Head Bold.ttf"
    EndIf

    $sFontInternalName = _WinAPI_GetFontResourceInfo($sFontFile, Default, 1)

    $hGUI = GUICreate("GDI+", 720, 235)
    GUISetState()

    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; D�finit l'objet graphics avec la qualit� de rendu anti aliasing
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, $GDIP_TEXTRENDERINGHINT_ANTIALIASGRIDFIT) ; Active l'anti aliasing pour les polices

    $hCollection = _GDIPlus_FontPrivateCreateCollection() ; Cr�e un objet PrivateFontCollection pour y ajouter apr�s, la polices
    _GDIPlus_FontPrivateAddFont($hCollection, $sFontFile) ; Ajoute la police � la collection de police
    $hFormat = _GDIPlus_StringFormatCreate() ; Cr�e un objet format de cha�ne
    $hFamily = _GDIPlus_FontFamilyCreateFromCollection($sFontInternalName, $hCollection) ; Cr�e un objet FontFamily
    $hFont = _GDIPlus_FontCreate($hFamily, 72) ; Cr�e un objet police
    $tLayout = _GDIPlus_RectFCreate(0, 0, 720, 235) ; Cr�e une structure $tagGDIPRECTF pour sauver la position x, y du texte
    _GDIPlus_StringFormatSetAlign($hFormat, 1) ; Centre le textehorizontalement
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ; Centre le texte verticalement
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F) ; Cr�e un pinceau avec une couleur pour le texte
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt" & @LF & "forever", $hFont, $tLayout, $hFormat, $hBrush) ; Dessine la cha�ne

    ; Boucle jusqu'� ce que l'utilisateur quitte
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Lib�re les ressources
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontPrivateCollectionDispose($hCollection)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example