我想了解已安装字体的信息,我试过这样:
Private Function Get_Installed_Fonts() As Array
Dim AllFonts As New Drawing.Text.InstalledFontCollection ' Get the installed fonts collection.
Dim FontFamilies() As FontFamily = AllFonts.Families() ' Get an array of the system's font familiies.
Return FontFamilies ' Return the array
End Function
然后我可以......:
For Each Font As FontFamily In Get_Installed_Fonts()
MsgBox(Font.Name)
Next
但是我找不到这样做的方法:
For Each Font As FontFamily In Get_Installed_Fonts()
MsgBox(Font.IsSystemFont)
MsgBox(Font.OriginalFontName)
MsgBox(Font.SizeInPoints)
Next
我在那里缺少什么?
这将是我将获得的东西,我还需要一种方法来搜索是否安装了字体,例如:
If FontsArray.contains("FontName") Then...
答案 0 :(得分:1)
问题是.IsSystemFont,.OriginalFontName和.SizeInPoints属性是Font类的成员,而不是FontFamily。 FontFamily用于创建字体,然后您可以使用上述语言来获取信息。
所以,你可以......
For Each FontFam As FontFamily In Get_Installed_Fonts()
Dim tFont as new Font(FontFam.Name, 8)
MsgBox(tFont.IsSystemFont)
MsgBox(tFont.OriginalFontName)
MsgBox(tFont.SizeInPoints)
'tFont = nothing
Next
答案 1 :(得分:1)
Private Function Get_Installed_Fonts() As FontFamily()
Using AllFonts As New Drawing.Text.InstalledFontCollection
Return AllFonts.Families
End Using
End Function