Skip to main content

Editor.Assets.Font

Class

Font asset for text rendering.

Index

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

readonly cacheFile: Path

Path to the cached asset file.

Inherited from

Asset.cacheFile


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

readonly fileMeta: AssetImportMetadata

Import metadata for the asset.

Inherited from

Asset.fileMeta


id

readonly id: Uuid

The unique id of the entity.

Inherited from

Asset.id


isVariableFont

readonly isVariableFont: boolean

Returns true if this font is a variable font.


meta

readonly meta: Meta

Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.

Inherited from

Asset.meta


name

readonly name: string

The name of the asset.

Inherited from

Asset.name


namedInstances

readonly namedInstances: NamedInstanceInfo[]

Named instance info for this font. Empty for static fonts. See Editor.Assets.NamedInstanceInfo.


type

readonly type: string

The entity's type.

Inherited from

Asset.type


variationAxes

readonly variationAxes: 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

ParameterType
namestring

Returns

CustomVariationStyle


getDirectlyReferencedEntities()

getDirectlyReferencedEntities(): Entity[]

A list of entities which this entity has a reference to.

Returns

Entity[]

Inherited from

Asset.getDirectlyReferencedEntities


getMeta()

static getMeta(): Meta

Returns metadata about this type.

Returns

Meta

Overrides

Asset.getMeta


getOwnedEntities()

getOwnedEntities(): Entity[]

A list of entities which has a reference to this entity.

Returns

Entity[]

Inherited from

Asset.getOwnedEntities


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

Asset.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Asset.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Asset.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Asset.isSame