Editor.Assets.Font
ClassFont asset for text rendering.
Index
Properties
Methods
Example
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;
const assetManager = model.project.assetManager;
// Find a Font asset and assign it to a Text component
const fonts = assetManager.assets.filter(a => a.isOfType('Font')) as Editor.Assets.Font[];
if (fonts.length === 0) {
console.log('No Font assets in project');
return;
}
const font = fonts[0];
// Create a scene object with a Text component and assign the font
const obj = scene.createSceneObject('TextObject');
const text = obj.addComponent('Text') as Editor.Components.Text;
text.font = font;
text.text = 'Hello from plugin';
console.log(`Assigned font "${font.name}" to Text on "${obj.name}"`);
Extends
Properties
cacheFile
readonlycacheFile:Path
Path to the cached asset file.
Inherited from
customVariationStyles
customVariationStyles:
CustomVariationStyle[]
Custom variation styles defined on this font. If a style is removed, Text components that used it switch to the font's default named instance.
fileMeta
readonlyfileMeta:AssetImportMetadata
Import metadata for the asset.
Inherited from
id
readonlyid:Uuid
The unique id of the entity.
Inherited from
isVariableFont
readonlyisVariableFont:boolean
Returns true if this font is a variable font.
meta
readonlymeta:Meta
Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.
Inherited from
name
readonlyname:string
The name of the asset.
Inherited from
namedInstances
readonlynamedInstances:NamedInstanceInfo[]
Named instance info for this font. Empty for static fonts. See Editor.Assets.NamedInstanceInfo.
type
readonlytype:string
The entity's type.
Inherited from
variationAxes
readonlyvariationAxes:VariationAxisInfo[]
Variation axes of this font. Empty for static fonts. See Editor.Assets.VariationAxisInfo.
Methods
createVariationStyle()
createVariationStyle(
name):CustomVariationStyle
Create a new Editor.Assets.CustomVariationStyle bound to this font, append it to Font.customVariationStyles, and return it. Returns null if called on a static font. name must be non-empty and must not collide (case-, whitespace-, and hyphen-insensitive) with a Editor.Components.FontStyles constant (e.g. FontStyles.Bold), a named instance on this font, or an existing custom variation style. Returns null when the name is invalid.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
getDirectlyReferencedEntities()
getDirectlyReferencedEntities():
Entity[]
A list of entities which this entity has a reference to.
Returns
Entity[]
Inherited from
Asset.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
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