Editor.Assets.VariationAxisInfo
ClassRead-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
Properties
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
readonlydefaultValue:number
Value the axis takes when no override is applied.
maxValue
readonlymaxValue:number
Highest value the axis accepts.
minValue
readonlyminValue:number
Lowest value the axis accepts.
name
readonlyname:string
Human-readable axis name from the font, for example "Weight".
tag
readonlytag:string
Four-character OpenType axis tag, for example "wght" for weight.