FontData Class

The bytes of a font file, kept for the lifetime of the fonts created from it and shared by the faces of a collection.

public sealed class FontData

Remarks

The tables are read in place, never copied. The array is an exact garbage-collected array, bounded by FontResourceLimits.MaxFontBytes when it is created: a font is an immutable object without owner or lifetime, so its bytes cannot be rented from a pool.

Properties

NameDescription
BytesGets the bytes of the font, in the sfnt format: a compressed container is expanded.
EnvironmentGets the environment the font was loaded with.
LimitsGets the limits of the environment the font was loaded with: they bound the work of decoding a glyph and the size of a text.
UseEmbeddedBitmapsGets a value indicating whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.

Gets the bytes of the font, in the sfnt format: a compressed container is expanded.

public ReadOnlyMemory<byte> Bytes { get; }

Property value

ReadOnlyMemory<byte>

Environment

FontData.cs

Gets the environment the font was loaded with.

public FontEnvironment Environment { get; }

Property value

FontEnvironment

Gets the limits of the environment the font was loaded with: they bound the work of decoding a glyph and the size of a text.

public FontResourceLimits Limits { get; }

Property value

FontResourceLimits

UseEmbeddedBitmaps

FontData.cs

Gets a value indicating whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.

public bool UseEmbeddedBitmaps { get; }

Property value

bool

Methods

NameDescription
GetWoffMetadata()Gets the extended metadata of the WOFF or WOFF2 file the font was read from.
GetWoffPrivateData()Gets the private data block of the WOFF or WOFF2 file the font was read from.

GetWoffMetadata()

FontData.cs

Gets the extended metadata of the WOFF or WOFF2 file the font was read from.

public string? GetWoffMetadata()

Returns

string? The XML document of the metadata block, or null when the font was not read from a WOFF or WOFF2 file or when the file has no metadata block. The document is not parsed nor validated.

Exceptions

InvalidFontException
The metadata block lies outside the file or its compressed data is malformed.
FontResourceLimitException
The document is longer than FontResourceLimits.MaxFontBytes or than the temporary buffers of the environment can hold.

Remarks

The block is kept compressed with the font and expanded at each call, in a buffer rented from FontData.Environment.

GetWoffPrivateData()

FontData.cs

Gets the private data block of the WOFF or WOFF2 file the font was read from.

public ReadOnlyMemory<byte> GetWoffPrivateData()

Returns

ReadOnlyMemory<byte> The bytes of the block, which only the font vendor can interpret, or an empty value when the font was not read from a WOFF or WOFF2 file or when the file has no private data block.

Exceptions

InvalidFontException
The private data block lies outside the file.