FontLoader Class

Reads a font file into memory, within the limits of an environment, and creates its faces.

public static class FontLoader

Remarks

The whole file is read: the tables of a font are a graph of offsets, and the font keeps its bytes to read them in place. The bytes read are bounded by FontResourceLimits.MaxEncodedBytes, and the bytes the font keeps by FontResourceLimits.MaxFontBytes, and the faces of a collection by FontResourceLimits.MaxCollectionFaces.

Methods

NameDescription
Load(Stream, FontEnvironment, bool)Reads the faces of a font file from a stream.
Load(ReadOnlySpan<byte>, FontEnvironment, bool)
LoadAsync(Stream, FontEnvironment, bool, CancellationToken)Reads the faces of a font file from a stream, asynchronously.

Load overloads

Load(Stream, FontEnvironment, bool)

FontLoader.cs

Reads the faces of a font file from a stream.

public static FontFace[] Load(Stream stream, FontEnvironment environment, bool useEmbeddedBitmaps = false)
Parameters
stream Stream
The stream of the font file, read to its end.
environment FontEnvironment
The limits and the storage of the font code.
useEmbeddedBitmaps bool
Whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.
Returns

FontFace[] The faces of the file: one for a font, one per font of a collection.

Load(ReadOnlySpan<byte>, FontEnvironment, bool)

FontLoader.cs
public static FontFace[] Load(ReadOnlySpan<byte> data, FontEnvironment environment, bool useEmbeddedBitmaps = false)
Parameters
data ReadOnlySpan<byte>
The bytes of the font file.
environment FontEnvironment
The limits and the storage of the font code.
useEmbeddedBitmaps bool
Whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.
Returns

FontFace[]

LoadAsync(Stream, FontEnvironment, bool, CancellationToken)

FontLoader.cs

Reads the faces of a font file from a stream, asynchronously.

net10.0

public static Task<FontFace[]> LoadAsync(Stream stream, FontEnvironment environment, bool useEmbeddedBitmaps, CancellationToken cancellationToken)

net11.0

public static Task<FontFace[]> LoadAsync(Stream stream, FontEnvironment environment, bool useEmbeddedBitmaps, CancellationToken cancellationToken)

Parameters

stream Stream
The stream of the font file, read to its end.
environment FontEnvironment
The limits and the storage of the font code.
useEmbeddedBitmaps bool
Whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.
cancellationToken CancellationToken
The token to monitor for cancellation requests.

Returns

Task<FontFace[]> The faces of the file: one for a font, one per font of a collection.