Installed Font Name List Using Array

Description: Returns an array of installed font names as strings which could be used in things like drop down combo boxes for seeing and selecting fonts currently installed.
Tested Platform: .NET 4.8, Visual Studio 2022, Windows 10
Language: VB.NET
'List installed font family names using for loop and return array.

Public Function listInstalledFonts() As String()
    Dim InstalledFonts As New System.Drawing.Text.InstalledFontCollection()
    Dim families() As FontFamily = InstalledFonts.Families
    Dim fontNames(families.Length - 1) As String

    For i = 0 To families.Length - 1
        fontNames(i) = families(i).Name

    Return fontNames
End Function

Posted: March 20, 2023

Return to the snippets listing