In This Article

FontData Class

Stores data about a font.

public class FontData : DisposableObjectBase, IDisposable
Inheritance:
object DisposableObjectBase object
Implements:
IDisposable

Constructors

FontData(string, float, FontStyle)

Initializes an instance of the class.

public FontData(string fontFamilyName, float fontSize, FontStyle fontStyle)
Parameter Type Description
fontFamilyName string

The font family name.

fontSize float

The font size.

fontStyle FontStyle

The font style.

Properties

Ascent

The ascent (also known as baseline) distance.

public float Ascent { get; }

Property Value

float

Descent

The descent distance.

public float Descent { get; }

Property Value

float

ExternalLeading

The external leading distance.

public float ExternalLeading { get; }

Property Value

float

Font

The Font.

public Font Font { get; }

Property Value

Font

HFont

The hFont handle.

public nint HFont { get; }

Property Value

nint

Height

The font height.

public int Height { get; }

Property Value

int

InternalLeading

The internal leading distance.

public float InternalLeading { get; }

Property Value

float

ScriptCache

A handle to the script cache for this font.

public nint ScriptCache { get; set; }

Property Value

nint

SystemDeviceDpi

The DPI of the system device.

public int SystemDeviceDpi { get; }

Property Value

int

VerticalAlignmentOffset

An additional offset value for vertically aligning certain fonts in GDI.

public float VerticalAlignmentOffset { get; }

Property Value

float

Methods

Dispose(bool)

Releases the unmanaged resources used by the object and optionally releases the managed resources.

protected override void Dispose(bool disposing)
Parameter Type Description
disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

This method is called by the public Dispose() method and the Finalize method. Dispose invokes this method with the disposing parameter set to true. Finalize invokes this method with disposing set to false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current object.

Returns

bool:

true if the specified object is equal to the current object; otherwise, false.

FitToHeight(float)

Ensures the returned FontData fits within the specified height.

public FontData FitToHeight(float maxHeight)
Parameter Type Description
maxHeight float

The maximum height.

Returns

FontData:

The FontData instance to use.

Remarks

If the current FontData instance fits within the specified height, it is returned. Otherwise, this instance is disposed and a new instance is returned that does fit.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int:

A hash code for the current object.

Inherited Members

Extension Methods