Class Font
Defines a particular format for text, including font face, size, and style attributes. This class cannot be inherited.
public sealed class Font
- Inheritance
-
Font
- Inherited Members
Constructors
Font(Font, FontStyle)
public Font(Font prototype, FontStyle newStyle)
Parameters
prototype
FontnewStyle
FontStyleThe FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator.
Exceptions
- ArgumentNullException
prototype
is null.
Font(string, float)
Initializes a new Font using a specified size. The character set is set to Default, the graphics unit to Point, the font style to Regular.
public Font(string fontName, float emSize)
Parameters
fontName
stringA string representation of the Font name.
emSize
floatThe em-size, in points, of the new font.
Exceptions
- ArgumentOutOfRangeException
emSize
is less than or equal to 0, evaluates to infinity or is not a valid number.- ArgumentNullException
fontName
is null.
Font(string, float, FontStyle)
Initializes a new Font using a specified size and style. The character set is set to Default, the graphics unit to Point.
public Font(string fontName, float emSize, FontStyle style)
Parameters
fontName
stringA string representation of the Font name.
emSize
floatThe em-size, in points, of the new font.
style
FontStyleThe FontStyle of the new font.
Exceptions
- ArgumentOutOfRangeException
emSize
is less than or equal to 0, evaluates to infinity or is not a valid number.- ArgumentNullException
fontName
is null.
Font(string, float, FontStyle, GraphicsUnit)
Initializes a new Font using a specified size, style, and unit.
public Font(string fontName, float emSize, FontStyle style, GraphicsUnit unit)
Parameters
fontName
stringA string representation of the Font name.
emSize
floatThe em-size of the new font in the units specified by the
unit
parameter.style
FontStyleThe FontStyle of the new font.
unit
GraphicsUnitThe GraphicsUnit of the new font.
Exceptions
- ArgumentOutOfRangeException
emSize
is less than or equal to 0, evaluates to infinity or is not a valid number.- ArgumentNullException
fontName
is null.
Font(string, float, FontStyle, GraphicsUnit, CharacterSet)
Initializes a new Font using a specified size, style, unit, and character set.
public Font(string fontName, float emSize, FontStyle style, GraphicsUnit unit, CharacterSet characterSet)
Parameters
fontName
stringA string representation of the Font name.
emSize
floatThe em-size of the new font in the units specified by the
unit
parameter.style
FontStyleThe FontStyle of the new font.
unit
GraphicsUnitThe GraphicsUnit of the new font.
characterSet
CharacterSetA character set to use for this font.
Exceptions
- ArgumentOutOfRangeException
emSize
is less than or equal to 0, evaluates to infinity or is not a valid number.- ArgumentNullException
fontName
is null.
Font(string, float, GraphicsUnit)
Initializes a new Font using a specified size and unit. The character set is set to Default, the style is set to Regular.
public Font(string fontName, float emSize, GraphicsUnit unit)
Parameters
fontName
stringA string representation of the Font name.
emSize
floatThe em-size of the new font in the units specified by the
unit
parameter.unit
GraphicsUnitThe GraphicsUnit of the new font.
Exceptions
- ArgumentOutOfRangeException
emSize
is less than or equal to 0, evaluates to infinity or is not a valid number.- ArgumentNullException
fontName
is null.
Properties
Bold
Gets a value indicating whether this Font is bold.
public bool Bold { get; }
Property Value
CharacterSet
Gets a byte value that specifies the character set that this Font uses.
public CharacterSet CharacterSet { get; }
Property Value
- CharacterSet
A character set that this Font uses.
Italic
Gets a value indicating whether this Font is italic.
public bool Italic { get; }
Property Value
Name
Gets the face name of this Font.
public string Name { get; }
Property Value
Size
public float Size { get; }
Property Value
Strikeout
Gets a value indicating whether this Font specifies a horizontal line through the font.
public bool Strikeout { get; }
Property Value
Style
Gets style information for this Font.
public FontStyle Style { get; }
Property Value
Underline
Gets a value indicating whether this Font is underlined.
public bool Underline { get; }
Property Value
Unit
Gets the unit of measure for this Font.
public GraphicsUnit Unit { get; }
Property Value
- GraphicsUnit
A GraphicsUnit that represents the unit of measure for this Font.
Methods
DeepClone()
Creates an exact deep copy of this Font.
public Font DeepClone()
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
obj
objectThe object to test.
Returns
- bool
True if the
obj
parameter is a Font and has the same property values as this Font; otherwise, false.
GetHashCode()
Gets the hash code for this Font.
public override int GetHashCode()
Returns
ToString()
Returns a human-readable string representation of this Font.
public override string ToString()