If I wanted to use a font in my app, this isnt definatly installed on everyones system, how do I check if its installed, and then if it isnt installed install it?
The font is called: brooklyn.ttf
Printable View
If I wanted to use a font in my app, this isnt definatly installed on everyones system, how do I check if its installed, and then if it isnt installed install it?
The font is called: brooklyn.ttf
You can install it with APIVB Code:
Private Const HWND_BROADCAST = &HFFFF& Private Const WM_FONTCHANGE = &H1D Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub Form_Load() Dim res As Long ' add the font res = AddFontResource("C:\Fonts\Nordic__.ttf") If res > 0 Then ' alert all windows that a font was added SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, 0 MsgBox res & " fonts were added!" End If End Sub
To check if it exists
VB Code:
Public Function IsFontInstalled(strFontName As String) As Boolean Dim i As Long For i = 1 To Screen.FontCount If UCase(Screen.Fonts(i)) = UCase(strFontName) Then 'found IsFontInstalled = True Exit Function End If Next i IsFontInstalled = False End Function Private Sub Command1_Click() MsgBox IsFontInstalled("Times New Roman") End Sub
Cheers!!