Editor.Assets.CustomVariationStyle
ClassA user-defined named style on a variable Editor.Assets.Font.
A user-defined named style on a variable Editor.Assets.Font. Holds the standard variation axis values (weight, width, slant, italic, opticalSize) plus any custom axes the font exposes (e.g. GRAD, YOPQ). Create one with Font.createVariationStyle() and apply it by setting preferredStyle on a Text component to its name.
Index
Properties
Methods
Example
// Add a heavy, narrow headline style to a variable font and use it on a Text component.
// Only the axes the font defines take effect.
export function applyHeadlineStyle(
font: Editor.Assets.Font,
text: Editor.Components.Text,
name: string,
): Editor.Assets.CustomVariationStyle {
if (!font.isVariableFont) {
throw new Error(`${font.name} is not a variable font`);
}
const style = font.createVariationStyle(name);
if (Editor.isNull(style)) {
throw new Error(`"${name}" is already a style name on ${font.name}`);
}
style.weight = 850;
style.width = 85;
text.fontSource = font;
text.preferredStyle = style.name;
console.log(`Text now uses ${font.name} ${style.name}`);
return style;
}
Extends
Properties
id
readonlyid:Uuid
The unique id of the entity.
Inherited from
italic
italic:
boolean
Italic axis value (ital). If the font has no ital axis, the slant axis (slnt) changes instead.
meta
readonlymeta:Meta
Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.
Inherited from
name
readonlyname:string
Name of the custom variation style. Assign it to Text.preferredStyle to change to this style.
opticalSize
opticalSize:
number
Optical size axis value (opsz).
slant
slant:
number
Slant axis value (slnt), in degrees.
type
readonlytype:string
The entity's type.
Inherited from
weight
weight:
number
Weight axis value (wght).
width
width:
number
Width axis value (wdth).
Methods
getDirectlyReferencedEntities()
getDirectlyReferencedEntities():
Entity[]
A list of entities which this entity has a reference to.
Returns
Entity[]
Inherited from
EntityStructure.getDirectlyReferencedEntities
getMeta()
staticgetMeta():Meta
Returns metadata about this type.
Returns
Overrides
getOwnedEntities()
getOwnedEntities():
Entity[]
A list of entities which has a reference to this entity.
Returns
Entity[]
Inherited from
EntityStructure.getOwnedEntities
getTypeName()
staticgetTypeName():string
Returns the type name of this class.
Returns
string
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object is of the specified type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object refers to the same instance as the given object.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean