Results 1 to 4 of 4

Thread: Installing a font?

  1. #1
    Cheeko
    Guest

    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

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can install it with API
    VB Code:
    1. Private Const HWND_BROADCAST = &HFFFF&
    2. Private Const WM_FONTCHANGE = &H1D
    3. Private Declare Function AddFontResource Lib "gdi32" Alias "AddFontResourceA" (ByVal lpFileName As String) As Long
    4. 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
    5. Private Sub Form_Load()
    6.     Dim res As Long
    7.     ' add the font
    8.     res = AddFontResource("C:\Fonts\Nordic__.ttf")
    9.     If res > 0 Then
    10.         ' alert all windows that a font was added
    11.         SendMessage HWND_BROADCAST, WM_FONTCHANGE, 0, 0
    12.         MsgBox res & " fonts were added!"
    13.     End If
    14. End Sub

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    To check if it exists
    VB Code:
    1. Public Function IsFontInstalled(strFontName As String) As Boolean
    2.  
    3. Dim i As Long
    4.  
    5. For i = 1 To Screen.FontCount
    6.     If UCase(Screen.Fonts(i)) = UCase(strFontName) Then
    7.         'found
    8.         IsFontInstalled = True
    9.         Exit Function
    10.     End If
    11. Next i
    12.  
    13. IsFontInstalled = False
    14.  
    15. End Function
    16.  
    17.  
    18. Private Sub Command1_Click()
    19.  
    20. MsgBox IsFontInstalled("Times New Roman")
    21.  
    22. End Sub

  4. #4
    Cheeko
    Guest

    Thumbs up

    Cheers!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width