Display All Fonts Installed in Your Computer Using C# Windows Forms

Introduction

In this article I show how to see all the fonts installed in your computer through C# programming. It is very simple to see all the fonts using the "InstalledFontCollection" class which is part of the "System.Drawing.Text" namespace. One other important thing about this class is that it is non-inheritable (just like a sealed class) and contains all the functionality of the fonts installed in your system.

Use the following procedure to implement it.

Step 1

  • Open Visual Studio 2010
  • "File" -> "New" -> "Project..."
  • Choose "Template" -> "Visual C#" -> "Windows Form Application "

Step 2

Insert a Listbox and a button control on the form from the toolbox.

Step 3

Write some simple C# code for the button click event; see:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Drawing.Text;

namespace list_of_all_font

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            InstalledFontCollection fonts = new InstalledFontCollection();

            FontFamily[] font = fonts.Families.ToArray();

            for (int i = 0; i < font.Length; i++)

            {

                listBox1.Items.Add(font[i].Name);

            }          

        }

    }

}

 

 Step 4

Now run your application and click on the button.

font-in-csharp.jpg