Editor.Assets.NamedInstanceInfo
ClassRead-only named axis preset from the font's fvar table, for example "Condensed Bold".
Read-only named axis preset from the font's fvar table, for example "Condensed Bold". Returned from Font.namedInstances. Apply one by setting a Text.preferredStyle on a Text component to the instance's name.
Index
Properties
Example
// Label each named instance of a variable font with its axis values, e.g. "Bold (wght 700, wdth 100)".
// Coordinates are listed in the same order as font.variationAxes.
export function describeNamedInstances(font: Editor.Assets.Font): string[] {
const tags = font.variationAxes.map(axis => axis.tag);
return font.namedInstances.map(instance => {
const values = instance.coordinates.map((value, i) => `${tags[i]} ${value}`);
return `${instance.name} (${values.join(', ')})`;
});
}
// Render a Text component with one of the font's named instances.
export function useNamedInstance(
text: Editor.Components.Text,
font: Editor.Assets.Font,
instanceName: string,
): Editor.Assets.NamedInstanceInfo {
const instance = font.namedInstances.find(candidate => candidate.name === instanceName);
if (instance === undefined) {
throw new Error(`${font.name} has no named instance "${instanceName}"`);
}
text.fontSource = font;
text.preferredStyle = instance.name;
return instance;
}
Properties
coordinates
readonlycoordinates:number[]
Axis values for this instance, indexed to match Font.variationAxes.
name
readonlyname:string
Instance name, for example "Condensed Bold".