Function Reference


_WinAPI_GetFontResourceInfo

Retrieves the fontname from the specified font resource file

#include <WinAPIGdi.au3>
_WinAPI_GetFontResourceInfo ( $sFont [, $bForce = False [, $iFlag = Default]] )

Parameters

$sFont String that names a font resource file.
To retrieve a fontname whose information comes from several resource files, they must be separated by a "|" .
For example, abcxxxxx.pfm | abcxxxxx.pfb.
$bForce [optional] Specifies whether adds a file to the font table, valid values:
    True - Forced add the specified file to the system font table and remove it after retrieving the fontname.
    False - Don't add and remove (Default).
$iFlag [optional] An integer value. See _WinAPI_GetFontMemoryResourceInfo() for value definition.

Return Value

Success: The name of the font or Font information according to $iFlag.
Failure: Empty string and sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

Remarks

not documented in MSDN

Example

Example 1

#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $sFileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1)
    Local $aFontList[UBound($sFileList) - 1][2]

    For $i = 1 To $sFileList[0]
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], 1)
    Next

    _ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo')

EndFunc   ;==>Example

Example 2

#include <Array.au3>
#include <File.au3>
#include <WinAPIGdi.au3>
#include <WinAPIShellEx.au3>

Example()

Func Example()
    Local $sFileList = _FileListToArray(_WinAPI_ShellGetSpecialFolderPath($CSIDL_FONTS), '*.ttf', 1)
    Local $aFontList[UBound($sFileList) - 1][2]

    For $i = 1 To $sFileList[0]
        $aFontList[$i - 1][0] = $sFileList[$i]
        $aFontList[$i - 1][1] = _WinAPI_GetFontResourceInfo($sFileList[$i], Default, 1)
    Next

    _ArrayDisplay($aFontList, '_WinAPI_GetFontResourceInfo (Font Family name)')

EndFunc   ;==>Example

Example 3

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

Example()

Func Example()
    Local $sFile = "Extras\SF Square Head Bold.ttf"

    ConsoleWrite(_WinAPI_GetFontResourceInfo($sFile, True) & @CRLF)
    ConsoleWrite(@CRLF)

    FontGetInfoFromFile($sFile, 0, "Copyright")
    FontGetInfoFromFile($sFile, 1, "Font Family name")
    FontGetInfoFromFile($sFile, 2, "Font SubFamily name")
    FontGetInfoFromFile($sFile, 3, "Unique font identifier")
    FontGetInfoFromFile($sFile, 4, "Font full name")
    FontGetInfoFromFile($sFile, 5, "Version string")
    FontGetInfoFromFile($sFile, 6, "Postscript name")
    FontGetInfoFromFile($sFile, 7, "Trademark")
    FontGetInfoFromFile($sFile, 8, "Manufacturer Name")
    FontGetInfoFromFile($sFile, 9, "Designer")
    FontGetInfoFromFile($sFile, 10, "Description")
    FontGetInfoFromFile($sFile, 11, "URL Vendor")
    FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)")
    FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)")
    FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)")
    FontGetInfoFromFile($sFile, 19, "Sample text")
    FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name")

    FontGetInfoFromFile($sFile, 256, "Font-specific names")

EndFunc   ;==>Example

Func FontGetInfoFromFile($sFile, $n, $sElement)
    Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n)
    If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF)
EndFunc   ;==>FontGetInfoFromFile