Skip to main content

Font

Namespace: System.Drawing

Assembly: System.Drawing.Managed (4.0.0.0)

Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.

public class Font : MarshalByRefObject, ICloneable, IDisposable, ISerializable

Constructors

Instance member Font(familyName, emSize)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(familyName, emSize, style)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(familyName, emSize, unit)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
unitGraphicsUnitThe GraphicsUnit of the new font.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(familyName, emSize, style, unit)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(familyName, emSize, style, unit, gdiCharSet)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.
gdiCharSetByteA Byte that specifies a GDI character set to use for this font.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(familyName, emSize, style, unit, gdiCharSet, gdiVerticalFont)

Initializes a new instance of the Font class.

NameTypeDescription
familyNameStringA string representation of the FontFamily for the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.
gdiCharSetByteA Byte that specifies a GDI character set to use for this font.
gdiVerticalFontBooleanA Boolean value indicating whether the new font is derived from a GDI vertical font.

Throws:

  • ArgumentNullException emSize is less than or equal to 0, evaluates to infinity, or is not a valid number.

Instance member Font(prototype, newStyle)

Initializes a new instance of the Font class that uses the specified existing Font and FontStyle enumeration.

NameTypeDescription
prototypeFontThe existing Font from which to create the new Font.
newStyleFontStyleThe FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.

Instance member Font(family, emSize)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.

Throws:

Instance member Font(family, emSize, style)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.

Throws:

Instance member Font(family, emSize, unit)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
unitGraphicsUnitThe GraphicsUnit of the new font.

Throws:

Instance member Font(family, emSize, style, unit)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.

Throws:

Instance member Font(family, emSize, style, unit, gdiCharSet)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.
gdiCharSetByteA Byte that specifies a GDI character set to use for this font.

Throws:

Instance member Font(family, emSize, style, unit, gdiCharSet, gdiVerticalFont)

Initializes a new instance of the Font class.

NameTypeDescription
familyFontFamilyThe FontFamily of the new Font.
emSizeSingleThe em-size of the new font in the units specified by the unit parameter.
styleFontStyleThe FontStyle of the new font.
unitGraphicsUnitThe GraphicsUnit of the new font.
gdiCharSetByteA Byte that specifies a GDI character set to use for this font.
gdiVerticalFontBooleanA Boolean value indicating whether the new font is derived from a GDI vertical font.

Throws:

Properties

Instance member Bold

Boolean: Gets a value indicating whether this Font is bold.

Instance member FontFamily

FontFamily: Gets the FontFamily associated with this Font.

Instance member GdiCharSet

Byte: Gets a byte value that specifies the GDI character set that this Font uses.

This property returns 1, unless a different character set is specified in the Font(String, Single, FontStyle, GraphicsUnit, Byte) constructor. This property takes a value from the list defined in the Windows SDK header file WinGDI.h. The character sets and byte values are listed in the following table. system.drawing.font

Instance member GdiVerticalFont

Boolean: Gets a value indicating whether this Font is derived from a GDI vertical font.

Use this property to determine if a font is compatible with native Win32 controls on non-Unicode platforms. GdiVerticalFont only returns true if this font was created from a classic GDI font definition, like a LOGFONT or HFONT.

Instance member Height

Int32: Gets the line spacing of this font.

Instance member IsSystemFont

Boolean: Gets a value indicating whether the font is a member of SystemFonts.

Instance member Italic

Boolean: Gets a value indicating whether this Font is italic.

Instance member Name

String: Gets the face name of this Font.

Instance member OriginalFontName

String: Gets the name of the font originally specified.

The actual font name and original font name can be different. System requirements may cause the use of a font other than the font originally specified.

Instance member Size

Single: Gets the em-size of this Font measured in the units specified by the Unit property.

Instance member SizeInPoints

Single: Gets the em-size, in points, of this Font.

Instance member Strikeout

Boolean: Gets a value indicating whether this Font specifies a horizontal line through the font.

Instance member Style

FontStyle: Gets style information for this Font.

Instance member SystemFontName

String: Gets the name of the system font if the IsSystemFont property returns true.

Instance member Underline

Boolean: Gets a value indicating whether this Font is underlined.

Instance member Unit

GraphicsUnit: Gets the unit of measure for this Font.

Methods

Instance member Clone()

Returns: Object.

Instance member Dispose()

Protected member Finalize()

Finalizes an instance of the Font class.

Instance member GetHeight()

Returns the line spacing of this font.

Returns: Single. The line spacing, in pixels, of this font.

Instance member GetHeight(graphics)

Returns the line spacing, in the current unit of a specified Graphics, of this font.

ParameterTypeDescription
graphicsGraphicsA Graphics that holds the vertical resolution, in dots per inch, of the display device as well as settings for page unit and page scale.

Returns: Single. The line spacing, in the graphics unit, of this font.

Instance member GetHeight(dpi)

Returns the height, in pixels, of this Font when drawn to a device with the specified vertical resolution.

ParameterTypeDescription
dpiSingleThe vertical resolution, in dots per inch, used to calculate the height of the font.

Returns: Single. The height, in pixels, of this Font.