Installing Fonts

Wise solutions Wise package studio 4.0
November 5, 2009 at 21:49:49
Specs: Windows XP
Here is the deal.
I have create a MSI to install a massive
amount of fonts, this will be deployed over a
network to 9000 machines.

Problem im having is that the fonts will not
appear in MS word until you either reboot the
PC or open the fonts folder.

if anyone knows a way to open the fonts folder
and have it closed again in some programming
language i could have this run after the
installation.
OR
someone may know why the fonts are not
enumerating in word after a MSI has pushed
the fonts into the fonts folder?


See More: Installing Fonts

Report •


#1
November 6, 2009 at 01:11:27
Pushing the fonts into the fonts folder doesn't actually install them. Windows Explorer installs them when you open the folder and realises there are new fonts. That's just one way of installing them - in this case, that's an indirect way, i.e. asking another process to do it for you. Google for other ways, e.g.:

http://msdn.microsoft.com/en-us/lib...


Report •

#2
November 8, 2009 at 16:23:06
Well that helped out a fair bit. gave me a really good direction
to go. now im still having an issue.

i have written code to add the font to windows as a temporary
resource however.... i still cannot see the font in word after i
have run it. can someone please look over the code and see if
i have done something wrong.

Public Class TourNTInstallFonts

    Private Declare Function AddFontResource Lib "gdi32" 
Alias "AddFontResourceA" (ByVal lpFileName As String) As 
Long
    Private Declare Function RemoveFontResource Lib "gdi32" 
Alias "RemoveFontResourceA" (ByVal lpFileName As String) 
As Long
    Dim AppPath As String
    Private Sub TourNTInstallFonts_Load(ByVal sender As 
System.Object, ByVal e As System.EventArgs) Handles 
MyBase.Load
        Me.Text = "Written By Rusty Long"
        'Add the font to the Windows Font Table
        'THIS CODE IS ITELLECTUAL PROPERTY OF CSG 
AND MUST NOT BE TAMPERED WITH IN ANY WAY'
        If FileExists("c:\windows\fonts\IntBd.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntBd.pfm")
        If FileExists("c:\windows\fonts\IntBdI.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntBdI.pfm")
        If FileExists("c:\windows\fonts\IntEL.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntEL.pfm")
        If FileExists("c:\windows\fonts\IntEL.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntELI.pfm")
        If FileExists("c:\windows\fonts\IntL.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntL.pfm")
        If FileExists("c:\windows\fonts\IntLI.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntLI.pfm")
        If FileExists("c:\windows\fonts\IntR.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntR.pfm")
        If FileExists("c:\windows\fonts\IntRI.pfm") = True Then 
AddFontResource("c:\windows\fonts\IntRI.pfm")
        If FileExists("c:\windows\fonts\SHAROSP_.pfm") = True 
Then AddFontResource("c:\windows\fonts\SHAROSP_.pfm")
        If FileExists("c:\windows\fonts\Letterpress_font.otf") = 
True Then 
AddFontResource("c:\windows\fonts\Letterpress_font.otf")

        'Me.Close()'
    End Sub

    Private Function FileExists(ByVal strPath As String) As 
Boolean
        If Dir$(strPath) <> "" Then FileExists = True Else 
FileExists = False
    End Function
End Class


Report •

#3
November 8, 2009 at 16:41:25
Found that the above code will not return properly.
Code Changed.

Public Class TourNTInstallFonts

Private Declare Function AddFontResource Lib "gdi32"
Alias "AddFontResourceA" (ByVal lpFileName As String) As
Long
Private Declare Function RemoveFontResource Lib "gdi32"
Alias "RemoveFontResourceA" (ByVal lpFileName As String)
As Long
Dim AppPath As String
Private Sub TourNTInstallFonts_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.Text = "Build 3 Written By Rusty Long"
'Add the font to the Windows Font Table
'THIS CODE IS ITELLECTUAL PROPERTY OF CSG
AND MUST NOT BE TAMPERED WITH IN ANY WAY'

'Creating File System as FSO
Dim fso
fso = CreateObject("Scripting.FileSystemObject")

If fso.FileExists("c:\windows\fonts\IntBd.pfm") Then
AddFontResource("c:\windows\fonts\IntBd.pfm")
MsgBox("Installation Successfull")
End If
If fso.FileExists("c:\windows\fonts\IntBdI.pfm") Then
AddFontResource("c:\windows\fonts\IntBdI.pfm")
If fso.FileExists("c:\windows\fonts\IntEL.pfm") Then
AddFontResource("c:\windows\fonts\IntEL.pfm")
If fso.FileExists("c:\windows\fonts\IntEL.pfm") Then
AddFontResource("c:\windows\fonts\IntELI.pfm")
If fso.FileExists("c:\windows\fonts\IntL.pfm") Then
AddFontResource("c:\windows\fonts\IntL.pfm")
If fso.FileExists("c:\windows\fonts\IntLI.pfm") Then
AddFontResource("c:\windows\fonts\IntLI.pfm")
If fso.FileExists("c:\windows\fonts\IntR.pfm") Then
AddFontResource("c:\windows\fonts\IntR.pfm")
If fso.FileExists("c:\windows\fonts\IntRI.pfm") Then
AddFontResource("c:\windows\fonts\IntRI.pfm")
If fso.FileExists("c:\windows\fonts\SHAROSP_.pfm")
Then AddFontResource("c:\windows\fonts\SHAROSP_.pfm")
If fso.FileExists("c:\windows\fonts\Letterpress_font.otf")
Then
AddFontResource("c:\windows\fonts\Letterpress_font.otf")

'Me.Close()'
End Sub

End Class


Report •

Related Solutions

#4
November 9, 2009 at 04:47:10
I'm not an expert on fonts, but my guess is that you are installing Adobe Postscript fonts and that this format may not be readable by Windows but may usable only by a specific Adobe application. This may not be correct, so if anyone reads this and knows better, please correct me.

Report •

#5
November 9, 2009 at 14:48:30
This was the resolution so it is possible to do.

Public Class TourNTInstallFonts


Private Declare Function AddFontResource Lib "gdi32"
Alias "AddFontResourceA" (ByVal lpFileName As String) As
Long
Public Shared Function SendMessage(ByVal hWnd As
Integer, ByVal Msg As UInteger, ByVal wParam As Integer,
ByVal lParam As Integer) As Integer
End Function
Dim AppPath As String
Private Sub TourNTInstallFonts_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.Text = "Build 4 Written By Rusty Long"
'Add the font to the Windows Font Table
'THIS CODE IS ITELLECTUAL PROPERTY OF CSG
AND MUST NOT BE TAMPERED WITH IN ANY WAY

'Setting Varibles
Dim fso
Dim res As Long 'NO NOT CHANGE TO INTERGER!
this is not a funny outcome no matter who you are.

'This is for broadcasting new fonts to the system
Const WM_FONTCHANGE As Integer = &H1D
Const HWND_BROADCAST As Integer = &HFFFF&
fso = CreateObject("Scripting.FileSystemObject")
'Creating File System Objects Varible

If fso.FileExists("c:\windows\fonts\IntBd.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntBd.pfm|c:\windows\fon
ts\IntBd.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntBdI.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntBdI.pfm|c:\windows\fo
nts\IntBdI.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntEL.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntEL.pfm|c:\windows\fon
ts\IntEL.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntEL.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntELI.pfm|c:\windows\fo
nts\IntELI.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntL.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntL.pfm|c:\windows\fonts
\IntL.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntLI.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntLI.pfm|c:\windows\font
s\IntLI.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntR.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntR.pfm|c:\windows\font
s\IntR.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\IntRI.pfm") Then
res =
AddFontResource("c:\windows\fonts\IntRI.pfm|c:\windows\font
s\IntRI.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\SHAROSP_.pfm")
Then
res =
AddFontResource("c:\windows\fonts\SHAROSP_.pfm|c:\wind
ows\fonts\SHAROSP_.pfb")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If
If fso.FileExists("c:\windows\fonts\Letterpress_font.otf")
Then
res =
AddFontResource("c:\windows\fonts\Letterpress_font.otf")
If res > 0 Then SendMessage(New
System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE,
0, Nothing)
End If

Me.Close()
End Sub


End Class


Report •

#6
November 10, 2009 at 01:52:18
Thanks for sharing this. Now that I've looked at the MSDN documentation of AddFontResource, I can see why it works.

Report •


Ask Question