【发布时间】:2013-03-31 15:31:47
【问题描述】:
我可以改进我的功能以不按每个元素进行搜索?
#Region " Font Is Installed? Function "
' [ Font Is Installed? Function ]
'
' Examples :
' MsgBox(Font_Is_Installed("Lucida Console"))
Private Function Font_Is_Installed(ByVal FontName As String) As Boolean
Dim AllFonts As New Drawing.Text.InstalledFontCollection
For Each Font As FontFamily In AllFonts.Families
If Font.Name.ToLower = FontName.ToLower Then Return True
Next
Return False
End Function
#End Region
更新:
好的,现在我看到了“.tolist”函数,现在我的代码是这样的:
Private Function Font_Is_Installed(ByVal FontName As String) As Boolean
Dim AllFonts As New Drawing.Text.InstalledFontCollection
Dim FontFamily As New FontFamily(FontName)
If AllFonts.Families.ToList().Contains(FontFamily) Then Return True Else Return False
End Function
我也有同样的问题:是第二种方式改进最好,还是我可以改进得更好?
【问题讨论】:
标签: vb.net visual-studio visual-studio-2012 fonts font-family