|
-
Oct 1st, 2001, 11:18 AM
#1
Installing a font?
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
-
Oct 1st, 2001, 11:28 AM
#2
PowerPoster
You can install it with API
VB 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
-
Oct 1st, 2001, 11:35 AM
#3
PowerPoster
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
-
Oct 1st, 2001, 11:47 AM
#4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|