Attribute VB_Name = "hlp_IsFontInstaller"
Option Explicit
Option Base 0

Private Declare Function EnumFontsA Lib "gdi32" (ByVal hdc As Long, lpsz As Any, ByVal lpFontEnumProc As Long, ByVal lParam As Long) As Long

Private Type LOGFONT
  lfHeight As Long
  lfWidth As Long
  lfEscapement As Long
  lfOrientation As Long
  lfWeight As Long
  lfItalic As Byte
  lfUnderline As Byte
  lfStrikeOut As Byte
  lfCharSet As Byte
  lfOutPrecision As Byte
  lfClipPrecision As Byte
  lfQuality As Byte
  lfPitchAndFamily As Byte
  lfFaceName(32) As Byte
  'lfFaceName As String * 32
  End Type

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long

Private DesiredFont As String
Private DesiredFontInstalled As Boolean

Public Function IsFontInstalled(ByVal FontName As String) As Boolean
  Dim xLong1 As Long
  
  xLong1 = GetDC(0&)
  'Stop
  If Not xLong1 = 0& Then
    DesiredFont = FontName
    Call EnumFontsA(xLong1, ByVal 0&, AddressOf IsFontInstalled_CallbackProc, 0&)
'    Stop
    IsFontInstalled = DesiredFontInstalled
    Call ReleaseDC(0&, xLong1)
    End If
  End Function

Public Function IsFontInstalled_CallbackProc(ByRef lplf As LOGFONT, ByVal lptm As Long, dwType As Long, ByVal lpData As Long) As Long
  If GetApiCharA(VarPtr(lplf.lfFaceName(0))) = DesiredFont Then
    DesiredFontInstalled = True
'    Stop
    Else
    Debug.Print GetApiCharA(VarPtr(lplf.lfFaceName(0)))
    IsFontInstalled_CallbackProc = 1&
    End If
  End Function
