P
Peter Huang
Hi Sulvain,
First, the font must be installed in the fonts folder for this to work
since that is where the InstalledFontCollection is derived. If the font is
not moved to the Fonts folder to install it, the InstalledFontCollection
will not list it.
So the first question is a known problem. In order to workaround it, we
need to use PInvoke to call EnumFontFamiliesEx to query installed fonts.
For more information on it, please refer to:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=nggF4aSf
BHA.1272%40cpmsftngxa09&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%2
6oe%3DUTF-8%26q%3DGDI%2BInstalledFontCollection
For the second refresh folder question, based on my test, we may need to
modify the
registry key as below so that when we restarts the windows form application
will be able to use the font.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
We may need to add the font information into the registry manually.
Here the code to modify the registry.(Just for test, you may need to change
according to what font you want to add)
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim fonts As RegistryKey = _
Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Fonts", True)
fonts.SetValue("3 of 9 Barcode (TrueType)", "3OF9.TTF")
Dim str As String = fonts.GetValue("3 of 9 Barcode (TrueType)",
"3OF9.TTF")
MsgBox(str)
End Sub
In this way, when we install fonts and then add the value into the
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts registry key. After
restart the windows application we will be able to use the new added font,
we do not need to refresh the C:\windows\Fonts folder.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
First, the font must be installed in the fonts folder for this to work
since that is where the InstalledFontCollection is derived. If the font is
not moved to the Fonts folder to install it, the InstalledFontCollection
will not list it.
So the first question is a known problem. In order to workaround it, we
need to use PInvoke to call EnumFontFamiliesEx to query installed fonts.
For more information on it, please refer to:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=nggF4aSf
BHA.1272%40cpmsftngxa09&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%2
6oe%3DUTF-8%26q%3DGDI%2BInstalledFontCollection
For the second refresh folder question, based on my test, we may need to
modify the
registry key as below so that when we restarts the windows form application
will be able to use the font.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
We may need to add the font information into the registry manually.
Here the code to modify the registry.(Just for test, you may need to change
according to what font you want to add)
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim fonts As RegistryKey = _
Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Fonts", True)
fonts.SetValue("3 of 9 Barcode (TrueType)", "3OF9.TTF")
Dim str As String = fonts.GetValue("3 of 9 Barcode (TrueType)",
"3OF9.TTF")
MsgBox(str)
End Sub
In this way, when we install fonts and then add the value into the
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts registry key. After
restart the windows application we will be able to use the new added font,
we do not need to refresh the C:\windows\Fonts folder.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.