10.1. Find All Installed Fonts

Problem

You need to retrieve a list of all the fonts installed on the current computer.

Solution

Create a new instance of the System.Drawing.Text.InstalledFontCollection class, which contains a collection of FontFamily objects representing all the installed fonts.

How It Works

The InstalledFontCollection class allows you to retrieve information about currently installed fonts, via the Families property. The Families property is provided by the MustInherit FontCollection class which InstalledFontCollection derives from.

The Code

The following code shows a form that iterates through the font collection when it is first created. Every time it finds a font, it creates a new Label control that will display the font ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.