Skip to main content

FontVariationInstance Struct

Definition​

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia

Describes a named variation instance declared by a variable font's fvar table.

public struct FontVariationInstance

Inheritance: ValueType -> FontVariationInstance

Implements: IEquatable<FontVariationInstance>

Remarks​

Named instances are pre-defined points in variation space the font designer has labeled — for example "Regular" at wght=400, or "Light Condensed" at wght=300, wdth=75. They give applications a curated set of preset combinations without having to invent their own.

Coordinates are in user-space (the same values the font designer chose to expose) — the same space Avalonia.Media.FontVariationSettings speaks, so an instance's coordinates translate directly into settings values. Normalization to the font's internal coordinate space happens when the settings are applied.

Methods​

NameDescription
Equals (2 overloads)Two instances are equal when they describe the same preset on the same font — i.e. they have the same name, index, and PostScript name ID. Coordinates are not compared because the dictionary type doesn't support value equality; within a font, Avalonia.Media.FontVariationInstance.Index already uniquely identifies an instance.
GetHashCodeNo summary available.

Equals overloads​

Equals Method​

Two instances are equal when they describe the same preset on the same font — i.e. they have the same name, index, and PostScript name ID. Coordinates are not compared because the dictionary type doesn't support value equality; within a font, Avalonia.Media.FontVariationInstance.Index already uniquely identifies an instance.

public bool Equals(Avalonia.Media.FontVariationInstance other)
Parameters​

other Avalonia.Media.FontVariationInstance

Returns​

bool

Equals Method​

public bool Equals(object obj)
Parameters​

obj object

Returns​

bool

GetHashCode Method​

public int GetHashCode()

Returns​

int

Properties​

NameDescription
CoordinatesGets the user-space axis coordinates that define this instance, keyed by axis tag (e.g. { wght: 700, wdth: 100 } for a Bold). Always non-null; empty when the instance has no axis values declared (a malformed font).
IndexGets the zero-based position of this instance in the font's fvar instance array. Use this with the instanceIndex parameter on GlyphTypeface.CreateNormalizedPosition as a shorthand for "give me the position of this preset".
NameGets the human-readable instance name resolved from the font's name table (e.g. "Regular", "SemiBold", "Light Condensed"). Empty when the font omits the name record for this instance.
PostScriptNameIdGets the optional name-ID of a PostScript name record for this instance, when the font declares one. null when not present.

Coordinates Property​

Gets the user-space axis coordinates that define this instance, keyed by axis tag (e.g. { wght: 700, wdth: 100 } for a Bold). Always non-null; empty when the instance has no axis values declared (a malformed font).

public System.Collections.Generic.IReadOnlyDictionary<Avalonia.Media.Fonts.OpenTypeTag, float> Coordinates { get; set; }

Index Property​

Gets the zero-based position of this instance in the font's fvar instance array. Use this with the instanceIndex parameter on GlyphTypeface.CreateNormalizedPosition as a shorthand for "give me the position of this preset".

public int Index { get; set; }

Name Property​

Gets the human-readable instance name resolved from the font's name table (e.g. "Regular", "SemiBold", "Light Condensed"). Empty when the font omits the name record for this instance.

public string Name { get; set; }

PostScriptNameId Property​

Gets the optional name-ID of a PostScript name record for this instance, when the font declares one. null when not present.

public Nullable<int> PostScriptNameId { get; set; }