Table of Contents

Class VariationAxis

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

One axis of a variable font, from its fvar table.

public sealed record VariationAxis : IEquatable<VariationAxis>
Inheritance
VariationAxis
Implements
Inherited Members

Examples

// A variable font's axes and named instances, and the face at any position on them.
Typeface flex = Typeface.FromFile(VariableFile);
foreach (VariationAxis axis in flex.VariationAxes)
{
    Console.WriteLine($"{axis.Tag} {axis.Name}: {axis.Min} to {axis.Max}, default {axis.Default}");
}

Typeface semiBold = flex.WithVariations(FontVariation.Weight(600), FontVariation.Width(90));
Typeface black = flex.WithNamedInstance(flex.NamedInstances.Count - 1);

// The optical size follows the font size unless the face sets it (OpticalSizing.None turns that off).
var caption = new Font(semiBold, 11);
Typeface drawn = caption.EffectiveTypeface;

// For a PDF, the subset is a static font at the face's position, which every viewer draws as it is.
FontSubset subset = FontSubsetter.Subset(semiBold, caption.Shape("Static at 600").Glyphs.ToArray());

Constructors

VariationAxis(FontTag, string, float, float, float, bool)

One axis of a variable font, from its fvar table.

public VariationAxis(FontTag Tag, string Name, float Min, float Default, float Max, bool IsHidden)

Parameters

Tag FontTag

The axis tag, such as wght.

Name string

The axis's English name from the name table, such as "Weight", or the tag when the font names none.

Min float

The smallest value.

Default float

The default value, where the font's own outlines are.

Max float

The largest value.

IsHidden bool

Whether the font asks applications not to show the axis (fvar's HIDDEN_AXIS flag).

Examples

// A variable font's axes and named instances, and the face at any position on them.
Typeface flex = Typeface.FromFile(VariableFile);
foreach (VariationAxis axis in flex.VariationAxes)
{
    Console.WriteLine($"{axis.Tag} {axis.Name}: {axis.Min} to {axis.Max}, default {axis.Default}");
}

Typeface semiBold = flex.WithVariations(FontVariation.Weight(600), FontVariation.Width(90));
Typeface black = flex.WithNamedInstance(flex.NamedInstances.Count - 1);

// The optical size follows the font size unless the face sets it (OpticalSizing.None turns that off).
var caption = new Font(semiBold, 11);
Typeface drawn = caption.EffectiveTypeface;

// For a PDF, the subset is a static font at the face's position, which every viewer draws as it is.
FontSubset subset = FontSubsetter.Subset(semiBold, caption.Shape("Static at 600").Glyphs.ToArray());

Properties

Default

The default value, where the font's own outlines are.

public float Default { get; init; }

Property Value

float

IsHidden

Whether the font asks applications not to show the axis (fvar's HIDDEN_AXIS flag).

public bool IsHidden { get; init; }

Property Value

bool

Max

The largest value.

public float Max { get; init; }

Property Value

float

Min

The smallest value.

public float Min { get; init; }

Property Value

float

Name

The axis's English name from the name table, such as "Weight", or the tag when the font names none.

public string Name { get; init; }

Property Value

string

Tag

The axis tag, such as wght.

public FontTag Tag { get; init; }

Property Value

FontTag