Skip to main content

Editor.Assets.VariationAxisInfo

Class

Read-only metadata describing one OpenType variation axis on a variable font.

Read-only metadata describing one OpenType variation axis on a variable font. Returned from Font.variationAxes.

Index

Example

// Keep a requested value inside the range a variable font supports for one axis.
export function clampToAxis(font: Editor.Assets.Font, tag: string, value: number): number {
const axis = font.variationAxes.find(candidate => candidate.tag === tag);
if (axis === undefined) {
throw new Error(`${font.name} has no "${tag}" axis`);
}
return Math.min(axis.maxValue, Math.max(axis.minValue, value));
}

// Set a custom style's weight from a slider or user input.
export function setStyleWeight(
font: Editor.Assets.Font,
style: Editor.Assets.CustomVariationStyle,
weight: number,
): void {
style.weight = clampToAxis(font, 'wght', weight);
}

Properties

defaultValue

readonly defaultValue: number

Value the axis takes when no override is applied.


maxValue

readonly maxValue: number

Highest value the axis accepts.


minValue

readonly minValue: number

Lowest value the axis accepts.


name

readonly name: string

Human-readable axis name from the font, for example "Weight".


tag

readonly tag: string

Four-character OpenType axis tag, for example "wght" for weight.