Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Apr 27, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

CheckFont - Test whether a font is installed

' Test whether a font name and size is supported
' Returns True if the font is supported, False otherwise
' If the font is supported but the size is not, it returns
' the actual font size in the second argument
' If the font isn't supported, it return the system font
' name and size in the two arguments.

Function CheckFont(fontName As String, Optional fontSize As Integer) As Boolean
    On Error Resume Next
    ' Create a temporary StdFont object
    With New StdFont
        ' Assign the proposed font name
        .Name = fontName
        If fontSize > 0 Then .Size = fontSize
        ' Return true if font assignment succeded
        CheckFont = (StrComp(fontName, .Name, vbTextCompare) = 0)
        ' return actual font name and size through arguments
        fontName = .Name
        fontSize = .Size
    End With
End Function

Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date