Private Declare Function CreateScalableFontResource Lib "gdi32" _ Alias "CreateScalableFontResourceA" _ (ByVal fHidden As Long, _ ByVal lpszResourceFile As String, _ ByVal lpszFontFile As String, _ ByVal lpszCurrentPath As String) As Long
Public Function GetFontName(FileNameTTF As String) As String Dim hFile As Integer Dim Buffer As String Dim FontName As String Dim TempName As String Dim iPos As Integer TempName = App.Path & "\~TEMP.FOT"
If CreateScalableFontResource(1, _ TempName, _ FileNameTTF, _ vbNullString) Then hFile = FreeFile
Open TempName For Binary Access Read As hFile
Buffer = Space(LOF(hFile)) Get hFile, , Buffer iPos = InStr(Buffer, "FONTRES:") + 8 FontName = Mid(Buffer, iPos, _ InStr(iPos, Buffer, vbNullChar) - iPos)
Close hFile
Kill TempName End If GetFontName = FontName End Function
Private Sub Form_Load() Dim TTFontFile As String TTFontFile = "c:\WINDOWS\Fonts\ANTQUAB.TTF" Me.caption = GetFontName(TTFontFile) Me.CurrentX = 1000 Me.CurrentY = Me.Height / 2 Me.FontName = GetFontName(TTFontFile) Me.FontSize = 15 Me.FontBold = True Me.Print Me.caption & " Font Demo.." End Sub |