【发布时间】:2016-10-07 23:14:26
【问题描述】:
我正在使用此代码并且工作正常
Imports System.Drawing.Text
Dim fontInstalled As Boolean = False
Dim fontToSearch As String
Dim fonts As New InstalledFontCollection
fontToSearch = "Verdana"
For Each one As FontFamily In fonts.Families
'If I want to show every installed family name
'MsgBox(one.Name)
If one.Name = fontToSearch Then
fontInstalled = True
MsgBox("Font " & fontToSearch & " IS installed!!!")
Exit For
End If
Next
If fontInstalled = False Then MsgBox("Font " & fontToSearch & " is NOT installed")
但我确信使用 InstalledFontCollection 或其他东西会有一个更清洁的解决方案,但我无法将此代码改编为 VB.NET Test if a Font is installed
var fontsCollection = new InstalledFontCollection();
foreach (var fontFamiliy in fontsCollection.Families)
{
if (fontFamiliy.Name == fontName) ... \\ installed
}
【问题讨论】: