FontVariationSettings Class
Definition
An immutable, order-independent set of user-space variation axis values that
configures variable fonts (fonts with an fvar table) for rendering.
public class FontVariationSettings
Remarks
Values are expressed in the font's user coordinate space (wght = 700), the
same space CSS font-variation-settings, DirectWrite and HarfBuzz use.
Normalization to the OpenType [-1, 1] range — including the avar
mapping — happens per font when the settings are applied, so one settings value is
meaningful across fonts: each font clamps to its own axis ranges and ignores axes
it does not declare.
Instances have structural equality with a cached hash code and are usable as cache
keys. Variations are stored sorted by axis tag, so equality is order-independent;
when the same tag is given more than once, the last value wins (CSS behavior).
null and Avalonia.Media.FontVariationSettings.Empty both mean "design defaults".
The string form accepted by Avalonia.Media.FontVariationSettings.Parse(string) (and produced by
Avalonia.Media.FontVariationSettings.ToString) is a comma-separated list of tag=value pairs, e.g.
"wght=700, wdth=85", usable directly in XAML.
Constructors
| Name | Description |
|---|---|
| FontVariationSettings | No summary available. |
FontVariationSettings Constructor
public FontVariationSettings(System.Collections.Generic.IEnumerable<Avalonia.Media.FontVariation> variations)
Parameters
variations System.Collections.Generic.IEnumerable<Avalonia.Media.FontVariation>
Methods
| Name | Description |
|---|---|
| Equals (2 overloads) | No summary available. |
| GetHashCode | No summary available. |
| Interpolate | Interpolates between two settings values, for animation. |
| Parse | Parses a comma-separated list of tag=value pairs, e.g. "wght=700, wdth=85". Whitespace around pairs, tags and values is ignored; an empty string yields Avalonia.Media.FontVariationSettings.Empty; duplicate tags collapse to the last value. |
| ToString | Returns the parseable string form, e.g. wght=700,wdth=85. |
| TryGetValue | No summary available. |
Equals overloads
Equals Method
public bool Equals(Avalonia.Media.FontVariationSettings other)
Parameters
other Avalonia.Media.FontVariationSettings
Returns
bool
Equals Method
public bool Equals(object obj)
Parameters
obj object
Returns
bool
GetHashCode Method
public int GetHashCode()
Returns
int
Interpolate Method
Interpolates between two settings values, for animation.
public Avalonia.Media.FontVariationSettings Interpolate(Avalonia.Media.FontVariationSettings from, Avalonia.Media.FontVariationSettings to, double progress)
Parameters
from Avalonia.Media.FontVariationSettings
to Avalonia.Media.FontVariationSettings
progress double
Returns
Avalonia.Media.FontVariationSettings
Remarks
Matches CSS font-variation-settings interpolation: when both endpoints
set exactly the same axes, each axis value is interpolated linearly (easing
overshoot extrapolates); otherwise the result is discrete — from
below the midpoint, to at and above it. Discrete is the only
sound fallback because a missing axis means "the font's default", a value that
is not knowable in user space. null and Avalonia.Media.FontVariationSettings.Empty both mean
"no axes set".
Parse Method
Parses a comma-separated list of tag=value pairs, e.g.
"wght=700, wdth=85". Whitespace around pairs, tags and values is
ignored; an empty string yields Avalonia.Media.FontVariationSettings.Empty; duplicate tags collapse
to the last value.
public Avalonia.Media.FontVariationSettings Parse(string s)
Parameters
s string
Returns
Avalonia.Media.FontVariationSettings
Exceptions
ToString Method
Returns the parseable string form, e.g. wght=700,wdth=85.
public string ToString()
Returns
string
TryGetValue Method
public bool TryGetValue(Avalonia.Media.Fonts.OpenTypeTag tag, double& value)
Parameters
tag Avalonia.Media.Fonts.OpenTypeTag
value double&
Returns
bool
Properties
| Name | Description |
|---|---|
| Empty | Gets the empty settings — the font's design defaults. |
| IsEmpty | Gets a value indicating whether no axis is set. |
| Variations | Gets the variations, sorted by axis tag ascending. Duplicate tags passed at construction have already been collapsed to their last value. |
Empty Property
Gets the empty settings — the font's design defaults.
public Avalonia.Media.FontVariationSettings Empty { get; set; }
IsEmpty Property
Gets a value indicating whether no axis is set.
public bool IsEmpty { get; set; }
Variations Property
Gets the variations, sorted by axis tag ascending. Duplicate tags passed at construction have already been collapsed to their last value.
public System.Collections.Immutable.ImmutableArray<Avalonia.Media.FontVariation> Variations { get; set; }