In This Article

FontData Class

Stores data about a font.

public class FontData : DisposableObject, IDisposable
Inheritance:
object MarshalByRefObject DisposableObject object
Implements:
IDisposable

Constructors

FontData(string, float, FontStyle)

Initializes an instance of the FontData 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

Gets the ascent (also known as baseline) distance.

public float Ascent { get; }

Property Value

float:

The ascent distance.

Descent

Gets the descent distance.

public float Descent { get; }

Property Value

float:

The descent distance.

ExternalLeading

Gets the external leading distance.

public float ExternalLeading { get; }

Property Value

float:

The external leading distance.

Font

Gets the Font.

public Font Font { get; }

Property Value

Font:

The Font.

HFont

Gets the hFont handle.

public nint HFont { get; }

Property Value

nint:

The hFont handle.

Height

Gets the font height.

public int Height { get; }

Property Value

int:

The font height.

InternalLeading

Gets the internal leading distance.

public float InternalLeading { get; }

Property Value

float:

The internal leading distance.

ScriptCache

Gets a handle to the script cache for this font.

public nint ScriptCache { get; set; }

Property Value

nint:

A handle to the script cache for this font.

SystemDeviceDpi

Gets the DPI of the system device.

public int SystemDeviceDpi { get; }

Property Value

int:

The DPI of the system device.

VerticalAlignmentOffset

Gets an additional offset value for vertically aligning certain fonts in GDI.

public float VerticalAlignmentOffset { get; }

Property Value

float:

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

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 to 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()

Returns a hash code for this object.

public override int GetHashCode()

Returns

int:

An integer value that specifies a hash value for this object.

Fields

AdditionalAscent

Additional ascent added to match other UI frameworks.

public const int AdditionalAscent = 1

Inherited Members