FontConverter Class
Converts Font objects from one data type to another.
Assembly: System.Drawing (in System.Drawing.dll)
A type converter is used to convert values between data types. A type converter also supports property configuration at design time by providing text-to-value conversion or a list of values that users can select from. Access the FontConverter class through the TypeDescriptor class by calling the GetConverter method.
The following code example demonstrates how to use the FontConverter to convert a Font to and from a string. This example is designed to be used with Windows Forms. Paste this code into a form and call the ShowFontStringConversion method when handling the form's Paint event, passing e as PaintEventArgs.
Private Sub ShowFontStringConversion(ByVal e As PaintEventArgs) ' Create the FontConverter. Dim converter As System.ComponentModel.TypeConverter = _ System.ComponentModel.TypeDescriptor.GetConverter(GetType(Font)) Dim font1 As Font = _ CType(converter.ConvertFromString("Arial, 12pt"), Font) Dim fontName1 As String = _ converter.ConvertToInvariantString(font1) Dim fontName2 As String = converter.ConvertToString(font1) e.Graphics.DrawString(fontName1, font1, Brushes.Red, 10, 10) e.Graphics.DrawString(fontName2, font1, Brushes.Blue, 10, 30) End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.