UDF > GDIPlus > FontPrivate >


_GDIPlus_FontPrivateCollectionDispose

Libère l'objet PrivateFontCollection spécifié

#include <GDIPlus.au3>
_GDIPlus_FontPrivateCollectionDispose ( $hFontCollection )

Paramètres

$hFontCollection  Le handle de l'objet 'collection de polices' à supprimer

Valeur de retour

Succès: Retourne True
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

En relation

_GDIPlus_FontPrivateCreateCollection, _GDIPlus_FontFamilyCreateFromCollection, _GDIPlus_FontPrivateAddFont

Voir aussi

Consultez GdipDeletePrivateFontCollection 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