|
-
Jul 1st, 2001, 05:29 AM
#1
Thread Starter
Member
How do I install fonts automatically?
In this moment I'm simply extracting the required font files to the Windows\FONTS -folder, and then my program opens the FONTS -folder for the user to see if the fonts are there.
Is there a way to install the fonts so that they work right away and absolutely 100% sure? Is it possible to run the "Install new font" -program with the chosen font automatically?
The method I'm using now usually works, but sometimes it doesn't. The font types are TrueType and "normal", and the number of fonts is 4 (unless my memory has been erased ).
-
Jul 1st, 2001, 11:09 AM
#2
Fanatic Member
Use the AddFontResource API call, all you have to do is simply pass it the filename of the font you want to add, the return value is the number of fonts added to the system (or 0 if an error occurred), you also need to alert all the top level windows that you have a added a font using SendMessage and the WM_FONTCHANGE message....
Code:
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 Const HWND_BROADCAST = &HFFFF&
Private Const WM_FONTCHANGE = &H1D
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
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Jul 3rd, 2001, 02:25 PM
#3
Thread Starter
Member
-
Jul 3rd, 2001, 02:55 PM
#4
Frenzied Member
I just use my Wise installer to install the program and any related fonts. Works much easier.
~Peter

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
|