FontInstance Class

An instance of a variable font: a value for each axis, and what only depends on these values.

public sealed class FontInstance

Remarks

The scalars of the regions of each variation store are computed once, when the instance is created.

Properties

NameDescription
CoordinatesGets the normalized value of each axis, from -1 to 1, as 2.14 fixed-point numbers: the form of the variation tables.
UserCoordinatesGets the value of each axis, in the units of the axis, as 16.16 fixed-point numbers.

Coordinates

FontInstance.cs

Gets the normalized value of each axis, from -1 to 1, as 2.14 fixed-point numbers: the form of the variation tables.

public ReadOnlySpan<int> Coordinates { get; }

Property value

ReadOnlySpan<int>

UserCoordinates

FontInstance.cs

Gets the value of each axis, in the units of the axis, as 16.16 fixed-point numbers.

public ReadOnlySpan<int> UserCoordinates { get; }

Property value

ReadOnlySpan<int>

Methods

NameDescription
Normalize(FontAxisRecord, int)Normalizes the value of an axis: -1 at its minimum, 0 at its default, 1 at its maximum. OpenType specification, "Coordinate scales and normalization".
ToTableValue(int)Converts a normalized 16.16 number to the 2.14 number of the variation tables, as the specification says: by adding 2 and dropping two bits.

Normalize(FontAxisRecord, int)

FontInstance.cs

Normalizes the value of an axis: -1 at its minimum, 0 at its default, 1 at its maximum. OpenType specification, "Coordinate scales and normalization".

public static int Normalize(in FontAxisRecord axis, int value)

Parameters

axis FontAxisRecord
The axis.
value int
The value, as a 16.16 fixed-point number, within the range of the axis.

Returns

int The normalized value, as a 16.16 fixed-point number: the avar table of the font maps it with this precision, and FontInstance.ToTableValue then gives the 2.14 number the variation tables are compared with.

ToTableValue(int)

FontInstance.cs

Converts a normalized 16.16 number to the 2.14 number of the variation tables, as the specification says: by adding 2 and dropping two bits.

public static int ToTableValue(int value)

Parameters

value int

Returns

int

Constants

NameDescription
TableOneThe value 1 as a 2.14 fixed-point number: the largest normalized value of an axis.
TableShiftThe number of bits between a 2.14 number and a 16.16 number.

TableOne

The value 1 as a 2.14 fixed-point number: the largest normalized value of an axis.

public const int TableOne = 16384

TableShift

The number of bits between a 2.14 number and a 16.16 number.

public const int TableShift = 2