Skip to main content

Editor.Assets.FontFamilyEntry

Class

Maps a single Font asset to a specific style (weight and italic flag) within a FontFamily.

Index

Example

// Build a font family from separate regular and bold font files, then list the styles it covers.
// Each style slot set on the family is stored as a FontFamilyEntry.
export function createFontFamily(
assetManager: Editor.Model.AssetManager,
name: string,
regular: Editor.Assets.Font,
bold: Editor.Assets.Font,
): Editor.Assets.FontFamily {
const destination = new Editor.Model.SourcePath(new Editor.Path(''), Editor.Model.SourceRootDirectory.Assets);
const family = assetManager.createNativeAsset('FontFamily', name, destination) as Editor.Assets.FontFamily;
family.regular = regular;
family.bold = bold;
return family;
}

// For example ["400: Docs Regular", "700: Docs Bold"].
export function listFamilyStyles(family: Editor.Assets.FontFamily): string[] {
return family.entries.map(entry => `${entry.weight}${entry.italic ? ' italic' : ''}: ${entry.font.name}`);
}

Extends

Properties

font

font: Font

Font asset assigned to this style entry.


id

readonly id: Uuid

The unique id of the entity.

Inherited from

EntityStructure.id


italic

italic: boolean

Whether this entry represents the italic variant of its weight.


meta

readonly meta: Meta

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

Inherited from

EntityStructure.meta


type

readonly type: string

The entity's type.

Inherited from

EntityStructure.type


weight

weight: number

Numeric font weight (e.g. 400 for regular, 700 for bold) represented by this entry.

Methods

getDirectlyReferencedEntities()

getDirectlyReferencedEntities(): Entity[]

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

Returns

Entity[]

Inherited from

EntityStructure.getDirectlyReferencedEntities


getMeta()

static getMeta(): Meta

Returns metadata about this type.

Returns

Meta

Overrides

EntityStructure.getMeta


getOwnedEntities()

getOwnedEntities(): Entity[]

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

Returns

Entity[]

Inherited from

EntityStructure.getOwnedEntities


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

EntityStructure.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

EntityStructure.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

EntityStructure.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

EntityStructure.isSame