Class Font
Defines a particular format for text, including font face, size, and style attributes.
Inheritance
Namespace: IronSoftware.Drawing
Assembly: IronSoftware.Drawing.Common.dll
Syntax
public class Font : Object
Text rendering across IronSoftware libraries flows through Font, the central record that bundles a typeface name, a point size, and a combination of style flags into a single, reusable object. Any IronSoftware component that draws or measures text accepts a Font, and the class's implicit conversion operators mean it travels freely between the IronDrawing type system, SkiaSharp's SKFont, and the FontTypes enumeration without explicit casting.
Four constructors cover the common setup patterns. The minimal form new Font(string familyName) picks up system defaults for size and style. Adding a float size argument sets the point size explicitly, while the FontStyle overload selects bold, italic, or combined styles. The full four-parameter constructor new Font(string familyName, FontStyle style, float size) fixes every attribute in one call. After construction, FamilyName, Size, and Style expose those choices as read-only properties. The convenience booleans Bold, Italic, Underline, and Strikeout let calling code branch on individual style flags without decomposing the FontStyle value manually.
The implicit operators are a practical time-saver. Assigning a Font to a variable typed as SKFont converts it automatically, so Skia-based rendering pipelines accept IronDrawing fonts without adapter code. The reverse direction works too: an SKFont assigned to a Font variable converts back. The same bidirectional pattern applies to FontTypes, making it straightforward to move between the enumeration-based API and the richer Font object.
using IronSoftware.Drawing;
// Construct with family, style, and size
Font heading = new Font("Arial", FontStyle.Bold, 18f);
Font caption = new Font("Georgia", FontStyle.Italic | FontStyle.Underline, 10f);
Console.WriteLine(heading.FamilyName); // Arial
Console.WriteLine(heading.Bold); // True
Console.WriteLine(caption.Underline); // True
// Implicit conversion to SKFont for Skia rendering pipelines
SkiaSharp.SKFont skFont = heading;Explore the IronDrawing get-started guide for environment setup, the font usage how-to for practical text-rendering patterns, the FontStyle examples for combining style flags, and the IronDrawing docs hub for the full API surface.
Constructors
Font(String)
Initializes a new Font that uses the specified existing FamilyName.
Further Documentation:
Code Example
Declaration
public Font(string familyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | familyName | The FontFamily of the new Font. |
Font(String, FontStyle)
Initializes a new Font that uses the specified existing FamilyName and FontStyle enumeration.
Further Documentation:
Code Example
Declaration
public Font(string familyName, FontStyle style)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | familyName | The FontFamily of the new Font. |
| FontStyle | style | The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator. |
Font(String, FontStyle, Single)
Initializes a new Font that uses the specified existing FamilyName, FontStyle enumeration, FontWeight, Bold, Italic and Size.
Further Documentation:
Code Example
Declaration
public Font(string familyName, FontStyle style, float size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | familyName | The FontFamily of the new Font. |
| FontStyle | style | The FontStyle to apply to the new Font. Multiple values of the FontStyle enumeration can be combined with the OR operator. |
| System.Single | size | The em-size of the new font in the units specified by the unit parameter. |
Font(String, Single)
Initializes a new Font that uses the specified existing FamilyName, FontWeight, Bold, Italic and Size.
Further Documentation:
Code Example
Declaration
public Font(string familyName, float size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | familyName | The FontFamily of the new Font. |
| System.Single | size | The em-size of the new font in the units specified by the unit parameter. |
Properties
Bold
Gets a value that indicates whether this Font is bold.
Declaration
public bool Bold { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
FamilyName
Gets the family name for the typeface.
Declaration
public string FamilyName { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Italic
Gets a value that indicates whether this font has the italic style applied.
Declaration
public bool Italic { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Size
Gets the "em-size of this Font measured in the units specified by the Unit property.
Declaration
public float Size { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Strikeout
Gets a value that indicates whether this Font specifies a horizontal line through the font.
Declaration
public bool Strikeout { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Style
Gets the font style for the typeface.
Declaration
public FontStyle Style { get; }
Property Value
| Type | Description |
|---|---|
| FontStyle |
Underline
Gets a value that indicates whether this Font is underlined.
Declaration
public bool Underline { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Operators
Implicit(Font to FontTypes)
Implicitly casts to IronPdf.Font.FontTypes objects from Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator FontTypes(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | Font is explicitly cast to a IronPdf.Font.FontTypes |
Returns
| Type | Description |
|---|---|
| FontTypes |
Implicit(Font to Font)
Implicitly casts to Microsoft.Maui.Graphics.Font objects from Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | Font is explicitly cast to a Microsoft.Maui.Graphics.Font |
Returns
| Type | Description |
|---|---|
| Microsoft.Maui.Graphics.Font |
Implicit(Font to Font)
Implicitly casts to SixLabors.Fonts.Font objects from Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | Font is explicitly cast to a SixLabors.Fonts.Font |
Returns
| Type | Description |
|---|---|
| SixLabors.Fonts.Font |
Implicit(Font to SKFont)
Implicitly casts to System.Drawing.Font objects from Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator SKFont(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | Font is explicitly cast to a SkiaSharp.SKFont |
Returns
| Type | Description |
|---|---|
| SkiaSharp.SKFont |
Implicit(Font to Font)
Implicitly casts to System.Drawing.Font objects from Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Font | font | Font is explicitly cast to a System.Drawing.Font |
Returns
| Type | Description |
|---|---|
| System.Drawing.Font |
Implicit(FontTypes to Font)
Implicitly casts IronPdf.Font.FontTypes objects to Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(FontTypes fontTypes)
Parameters
| Type | Name | Description |
|---|---|---|
| FontTypes | fontTypes | IronPdf.Font.FontTypes will automatically be casted to Font |
Returns
| Type | Description |
|---|---|
| Font |
Implicit(Font to Font)
Implicitly casts Microsoft.Maui.Graphics.Font objects to Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Maui.Graphics.Font | font | Microsoft.Maui.Graphics.Font will automatically be casted to Font |
Returns
| Type | Description |
|---|---|
| Font |
Implicit(Font to Font)
Implicitly casts SixLabors.Fonts.Font objects to Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| SixLabors.Fonts.Font | font | SixLabors.Fonts.Font will automatically be casted to Font |
Returns
| Type | Description |
|---|---|
| Font |
Implicit(SKFont to Font)
Implicitly casts SkiaSharp.SKFont objects to Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(SKFont font)
Parameters
| Type | Name | Description |
|---|---|---|
| SkiaSharp.SKFont | font | SkiaSharp.SKFont will automatically be casted to Font |
Returns
| Type | Description |
|---|---|
| Font |
Implicit(Font to Font)
Implicitly casts System.Drawing.Font objects to Font.
When your .NET Class methods use Font as parameters or return types, you now automatically support Font as well.
Declaration
public static implicit operator Font(Font font)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.Font | font | System.Drawing.Font will automatically be casted to Font |
Returns
| Type | Description |
|---|---|
| Font |