Table of Contents

Struct FontVariation

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

A position on one axis of a variable font, in the axis's own units, such as weight 650.

public readonly record struct FontVariation : IEquatable<FontVariation>
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

FontVariation(FontTag, float)

A position on one axis of a variable font, in the axis's own units, such as weight 650.

public FontVariation(FontTag Axis, float Value)

Parameters

Axis FontTag

The axis tag, such as wght.

Value float

The value in the axis's user units (wght 1 to 1000, wdth in percent, slnt in degrees, opsz in points).

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());

FontVariation(string, float)

Initializes a position from the axis tag's text, such as new FontVariation("wght", 650).

public FontVariation(string axis, float value)

Parameters

axis string

One to four characters.

value float

The value in the axis's user units.

Properties

Axis

The axis tag, such as wght.

public FontTag Axis { get; init; }

Property Value

FontTag

ItalicAxis

Gets the tag of the registered italic axis, ital (0 upright, 1 italic).

public static FontTag ItalicAxis { get; }

Property Value

FontTag

OpticalSizeAxis

Gets the tag of the registered optical size axis, opsz (the text size in points the design is for).

public static FontTag OpticalSizeAxis { get; }

Property Value

FontTag

SlantAxis

Gets the tag of the registered slant axis, slnt (degrees counter-clockwise, negative for text leaning right).

public static FontTag SlantAxis { get; }

Property Value

FontTag

Value

The value in the axis's user units (wght 1 to 1000, wdth in percent, slnt in degrees, opsz in points).

public float Value { get; init; }

Property Value

float

WeightAxis

Gets the tag of the registered weight axis, wght (1 to 1000).

public static FontTag WeightAxis { get; }

Property Value

FontTag

WidthAxis

Gets the tag of the registered width axis, wdth (percent of normal).

public static FontTag WidthAxis { get; }

Property Value

FontTag

Methods

Italic(float)

Returns an italic position.

public static FontVariation Italic(float value)

Parameters

value float

0 for upright, 1 for italic.

Returns

FontVariation

The position.

OpticalSize(float)

Returns an optical size position.

public static FontVariation OpticalSize(float points)

Parameters

points float

The text size the design is for.

Returns

FontVariation

The position.

Slant(float)

Returns a slant position.

public static FontVariation Slant(float degrees)

Parameters

degrees float

The slant in degrees counter-clockwise from upright; negative values lean right.

Returns

FontVariation

The position.

Weight(float)

Returns a weight position.

public static FontVariation Weight(float value)

Parameters

value float

The weight, 1 to 1000; 400 is normal and 700 bold.

Returns

FontVariation

The position.

Width(float)

Returns a width position.

public static FontVariation Width(float percent)

Parameters

percent float

The width in percent of normal: 100 normal, 75 condensed, 125 expanded.

Returns

FontVariation

The position.