Getting Windows installed fonts using .NET

You are currently viewing Getting Windows installed fonts using .NET

.NET Framework 2.0 namespaces System.Drawing and System.Drawing.Text contains many useful classes related to Drawing manipulation. These classes deals with fonts, fonts families, colors, images and bitmaps and can be used to add drawing related features in your .NET applications. One of the common task developers needs to perform in day to day .NET applications is to get the list of installed fonts in Windows operating system.

Following tutorial demonstrates how you can achieve this by using .NET built in classes.

VB.NET
Dim fontsCollection As New InstalledFontCollection()
Dim fontFamilies As FontFamily() = fontsCollection.Families
Dim count As Integer = fontFamilies.Length

Me.Text = "Number of fonts:" + count

For Each font As FontFamily In fontFamilies
   listBox1.Items.Add(font.Name)
Next
C#
InstalledFontCollection fontsCollection = new InstalledFontCollection();
FontFamily[] fontFamilies = fontsCollection.Families;
int count = fontFamilies.Length;

this.Text = "Number of fonts:" + count;

foreach (FontFamily font in fontFamilies)
{
   listBox1.Items.Add(font.Name);
}
READ ALSO:  Overview of .NET Framework Specialized Collections

This Post Has 3 Comments

  1. SHAHBAZ

    I want to join this amazing group

  2. Imran Ali

    nice article but this code is for showing installed font in DDL also give example of setting font to controls.

  3. raj

    its very nice information ….thank you

Leave a Reply