FontLoader Class
Reads a font file into memory, within the limits of an environment, and creates its faces.
public static class FontLoaderRemarks
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
| Name | Description |
|---|---|
| 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.csReads the faces of a font file from a stream.
public static FontFace[] Load(Stream stream, FontEnvironment environment, bool useEmbeddedBitmaps = false)Parameters
streamStream- The stream of the font file, read to its end.
environmentFontEnvironment- The limits and the storage of the font code.
useEmbeddedBitmapsbool- 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.cspublic static FontFace[] Load(ReadOnlySpan<byte> data, FontEnvironment environment, bool useEmbeddedBitmaps = false)Parameters
dataReadOnlySpan<byte>- The bytes of the font file.
environmentFontEnvironment- The limits and the storage of the font code.
useEmbeddedBitmapsbool- 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.csReads 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
streamStream- The stream of the font file, read to its end.
environmentFontEnvironment- The limits and the storage of the font code.
useEmbeddedBitmapsbool- Whether the bitmaps without colors of the font replace its outlines at the sizes they are made for.
cancellationTokenCancellationToken- 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.