各要素で検索しないように機能を改善できますか?
#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
同じ質問があります: 2 番目の方法で改善するのが最善ですか、それとももっと改善できますか?