Fonts bestimmen

11/06/2008 - 08:55 von Lothar Geyer | Report spam
Wie kann ich feststellen, welche Fonts auf einem System vorhanden sind
und in welchen Größen (Schriftgrad) ein Font vorhanden ist?

Lothar Geyer

Lesen sie die antworten

#1 Michael Mueller
11/06/2008 - 09:34 | Warnen spam
Hi Lothar,

Wie kann ich feststellen, welche Fonts auf einem System vorhanden sind

Per API EnumFonts.

Auszu aus API-Guide:
"The EnumFonts function enumerates the fonts available on a specified
device. For each font with the specified typeface name, the EnumFonts
function retrieves information about that font and passes it to the
application-defined callback function. This callback function can process
the font information as desired. Enumeration continues until there are no
more fonts or the callback function returns zero."

Hier das Codebeispiel:

'in a form

Private Sub Form_Load()
'KPD-Team 2000
Me.AutoRedraw = True
EnumFonts Me.hDC, vbNullString, AddressOf EnumFontProc, 0
End Sub

'in a module

Private Const LF_FACESIZE = 32
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(LF_FACESIZE) As Byte
End Type
Declare Function EnumFonts Lib "gdi32" Alias "EnumFontsA" _
(ByVal hDC As Long, ByVal lpsz As String, ByVal _
lpFontEnumProc As Long, ByVal lParam As Long) As Long
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Function EnumFontProc(ByVal lplf As Long, ByVal lptm As _
Long, ByVal dwType As Long, ByVal lpData As Long) As Long
Dim LF As LOGFONT, FontName As String, ZeroPos As Long
CopyMemory LF, ByVal lplf, LenB(LF)
FontName = StrConv(LF.lfFaceName, vbUnicode)
ZeroPos = InStr(1, FontName, Chr$(0))
If ZeroPos > 0 Then FontName = Left$(FontName, ZeroPos - 1)
Form1.Print FontName
EnumFontProc = 1
End Function

Vielleicht Hilft Dir da ja schon weiter.


Ähnliche fragen