FontFamily Class

Definition

Defines a group of type faces having a similar basic design and certain variations in styles. This class cannot be inherited.

public sealed class FontFamily : MarshalByRefObject, IDisposable
Inheritance
Implements

Examples

The following code example shows all the font families in the Families property of the FontFamily class. This example is designed to be used with a Windows Form. To run this example, add a ListBox named listBox1 to a form and call the PopulateListBoxWithFonts method from the form's constructor.

private void PopulateListBoxWithFonts()
{
    listBox1.Width = 200;
    listBox1.Location = new Point(40, 120);
    foreach ( FontFamily oneFontFamily in FontFamily.Families )
    {
        listBox1.Items.Add(oneFontFamily.Name);
    }
}

Remarks

Note

In .NET 6 and later versions, the System.Drawing.Common package, which includes this type, is only supported on Windows operating systems. Use of this type in cross-platform apps causes compile-time warnings and run-time exceptions. For more information, see System.Drawing.Common only supported on Windows.

Constructors

FontFamily(GenericFontFamilies)

Initializes a new FontFamily from the specified generic font family.

FontFamily(String, FontCollection)

Initializes a new FontFamily in the specified FontCollection with the specified name.

FontFamily(String)

Initializes a new FontFamily with the specified name.

Properties

Families

Returns an array that contains all the FontFamily objects associated with the current graphics context.

GenericMonospace

Gets a generic monospace FontFamily.

GenericSansSerif

Gets a generic sans serif FontFamily object.

GenericSerif

Gets a generic serif FontFamily.

Name

Gets the name of this FontFamily.

Methods

CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose()

Releases all resources used by this FontFamily.

Equals(Object)

Indicates whether the specified object is a FontFamily and is identical to this FontFamily.

Finalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

GetCellAscent(FontStyle)

Returns the cell ascent, in design units, of the FontFamily of the specified style.

GetCellDescent(FontStyle)

Returns the cell descent, in design units, of the FontFamily of the specified style.

GetEmHeight(FontStyle)

Gets the height, in font design units, of the em square for the specified style.

GetFamilies(Graphics)
Obsolete.
Obsolete.

Returns an array that contains all the FontFamily objects available for the specified graphics context.

GetHashCode()

Gets a hash code for this FontFamily.

GetLifetimeService()
Obsolete.

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetLineSpacing(FontStyle)

Returns the line spacing, in design units, of the FontFamily of the specified style. The line spacing is the vertical distance between the base lines of two consecutive lines of text.

GetName(Int32)

Returns the name, in the specified language, of this FontFamily.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService()
Obsolete.

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
IsStyleAvailable(FontStyle)

Indicates whether the specified FontStyle enumeration is available.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString()

Converts this FontFamily to a human-readable string representation.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also