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.

Windows Installed Fonts

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);
}

 

 

About author


User avatar

Waqas Anwar

Founder of EzzyLearning.com, Senior Consultant, Microsoft .NET and Web Technologies

Comments 3

user
raj
  • 23 February 2009

its very nice information ....thank you

user
Imran Ali
  • 20 April 2009

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

user
SHAHBAZ
  • 22 April 2009

I want to join this amazing group

Add Comment