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 ref class FontFamily sealed : MarshalByRefObject, IDisposable
public sealed class FontFamily : MarshalByRefObject, IDisposable
type FontFamily = class
    inherit MarshalByRefObject
    interface IDisposable
Public NotInheritable Class FontFamily
Inherits MarshalByRefObject
Implements 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 = Point(40,120);
      System::Collections::IEnumerator^ myEnum = FontFamily::Families->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         FontFamily^ oneFontFamily = safe_cast<FontFamily^>(myEnum->Current);
         listBox1->Items->Add( oneFontFamily->Name );
      }
   }
private void PopulateListBoxWithFonts()
{
    listBox1.Width = 200;
    listBox1.Location = new Point(40, 120);
    foreach ( FontFamily oneFontFamily in FontFamily.Families )
    {
        listBox1.Items.Add(oneFontFamily.Name);
    }
}
Private Sub PopulateListBoxWithFonts()
    listBox1.Width = 200
    listBox1.Location = New Point(40, 120)
    Dim oneFontFamily As FontFamily
    For Each oneFontFamily In FontFamily.Families
        listBox1.Items.Add(oneFontFamily.Name)
    Next
End Sub

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)

Initializes a new FontFamily with the specified name.

FontFamily(String, FontCollection)

Initializes a new FontFamily in the specified FontCollection 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

See also