SceneFontFace Class

A face of a font file (TrueType, OpenType, WOFF, WOFF2 or a collection), for the texts of a scene. Add it to a SceneFontCollection: the layout measures the texts with it and every renderer draws them with it.

public sealed class SceneFontFace

Remarks

A face keeps the bytes of its file, so that each renderer reads the same font: the image renderer loads it with its own font engine, and the SVG renderer can embed it (SvgRenderOptions.EmbedFonts). A face is immutable and can be used by several threads at the same time.

Properties

NameDescription
DataGets the bytes of the font file the face was loaded from.
FamilyNameGets the name of the family of the face, such as Liberation Sans; empty when the font has no name.
IndexGets the index of the face in its file: 0, except for the faces of a font collection (.ttc, .otc).
IsItalicGets a value indicating whether the face is italic or oblique.
StrikeoutPositionGets the top of the strikethrough, in em, above the baseline. The value of the font, or 0.3 when it has none.
StrikeoutThicknessGets the thickness of the strikethrough, in em. The value of the font, or 0.05 when it has none.
UnderlinePositionGets the top of the underline, in em, above the baseline: negative below it. The value of the font, or -0.075 when it has none.
UnderlineThicknessGets the thickness of the underline, in em. The value of the font, or 0.05 when it has none.
WeightGets the weight of the face, from 1 to 1000: 400 is regular, 700 is bold.

Gets the bytes of the font file the face was loaded from.

public ReadOnlyMemory<byte> Data { get; }

Property value

ReadOnlyMemory<byte>

Gets the name of the family of the face, such as Liberation Sans; empty when the font has no name.

public string FamilyName { get; }

Property value

string

Gets the index of the face in its file: 0, except for the faces of a font collection (.ttc, .otc).

public int Index { get; }

Property value

int

Gets a value indicating whether the face is italic or oblique.

public bool IsItalic { get; }

Property value

bool

StrikeoutPosition

SceneFontFace.cs

Gets the top of the strikethrough, in em, above the baseline. The value of the font, or 0.3 when it has none.

public double StrikeoutPosition { get; }

Property value

double

StrikeoutThickness

SceneFontFace.cs

Gets the thickness of the strikethrough, in em. The value of the font, or 0.05 when it has none.

public double StrikeoutThickness { get; }

Property value

double

UnderlinePosition

SceneFontFace.cs

Gets the top of the underline, in em, above the baseline: negative below it. The value of the font, or -0.075 when it has none.

public double UnderlinePosition { get; }

Property value

double

UnderlineThickness

SceneFontFace.cs

Gets the thickness of the underline, in em. The value of the font, or 0.05 when it has none.

public double UnderlineThickness { get; }

Property value

double

Gets the weight of the face, from 1 to 1000: 400 is regular, 700 is bold.

public int Weight { get; }

Property value

int

Methods

NameDescription
Load(Stream)Loads every face of a font file from a stream, read from its current position to its end.
Load(ReadOnlySpan<byte>)Loads every face of a font file.
Load(string)Loads every face of a font file.
ToString()Returns a string that represents the current object.

Load overloads

Load(Stream)

SceneFontFace.cs

Loads every face of a font file from a stream, read from its current position to its end.

public static IReadOnlyList<SceneFontFace> Load(Stream stream)
Parameters
stream Stream
The stream. It is left open.
Returns

IReadOnlyList<SceneFontFace> The faces of the file: one for a font, one per font of a collection.

Exceptions
FontException
The data is not a font, or the font is malformed, uses a feature that is not supported, or exceeds a limit.
IOException
An I/O error occurred.

Load(ReadOnlySpan<byte>)

SceneFontFace.cs

Loads every face of a font file.

public static IReadOnlyList<SceneFontFace> Load(ReadOnlySpan<byte> data)
Parameters
data ReadOnlySpan<byte>
The bytes of the file. They are copied.
Returns

IReadOnlyList<SceneFontFace> The faces of the file: one for a font, one per font of a collection.

Exceptions
FontException
The data is not a font, or the font is malformed, uses a feature that is not supported, or exceeds a limit.

Load(string)

SceneFontFace.cs

Loads every face of a font file.

public static IReadOnlyList<SceneFontFace> Load(string path)
Parameters
path string
The path of the file.
Returns

IReadOnlyList<SceneFontFace> The faces of the file: one for a font, one per font of a collection.

Exceptions
FontException
The file is not a font, or the font is malformed, uses a feature that is not supported, or exceeds a limit.
IOException
An I/O error occurred.

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.