logo search
CSharp_Graphics

Компиляция кода

How to: Enumerate Installed Fonts

The InstalledFontCollection class inherits from the FontCollection abstract base class. You can use an InstalledFontCollection object to enumerate the fonts installed on the computer. The Families property of an InstalledFontCollection object is an array of FontFamily objects.

Example

The following example lists the names of all the font families installed on the computer. The code retrieves the Name property of each FontFamily object in the array returned by the Families property. As the family names are retrieved, they are concatenated to form a comma-separated list. Then the DrawString method of the Graphics class draws the comma-separated list in a rectangle.

If you run the example code, the output will be similar to that shown in the following illustration.