This documentation is archived and is not being maintained.

PrivateFontCollection.AddFontFile Method

Adds a font from the specified file to this PrivateFontCollection.

Namespace:  System.Drawing.Text
Assembly:  System.Drawing (in System.Drawing.dll)

public void AddFontFile(
	string filename


Type: System.String
A String that contains the file name of the font to add.


The specified font is not supported or the font file cannot be found.

Windows Forms applications support TrueType fonts and have limited support for OpenType fonts. If you try to use a font that is not supported, such as an unsupported OpenType font or a Bitmap font, an exception will occur. The AddFontFile is not supported on operating systems before Windows 2000. When using a private font on operating systems before Windows 2000, the default font, typically Microsoft Sans Serif, will be substituted.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.