Skip to main content

Class: FontManager

Internal

Fetches, loads, and provides fonts to the game.

For m2c2kit library use only

Constructors​

new FontManager()​

new FontManager(game, baseUrls): FontManager

Parameters​

• game: Game

• baseUrls: GameBaseUrls

Returns​

FontManager

Defined in​

m2c2kit/packages/core/src/FontManager.ts:22

Properties​

fonts​

fonts: Record<string, M2Font> = {}

Defined in​

m2c2kit/packages/core/src/FontManager.ts:16


provider​

provider: TypefaceFontProvider

Defined in​

m2c2kit/packages/core/src/FontManager.ts:17

Methods​

dispose()​

dispose(): void

Internal

Frees up resources allocated by the FontManager.

For m2c2kit library use only

Returns​

void

Remarks​

This will be done automatically by the m2c2kit library; the end-user must not call this.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:187


getDefaultFont()​

getDefaultFont(): M2Font

Internal

Returns the m2c2kit default font (M2Font) that has been loaded by the FontManager.

For m2c2kit library use only

Returns​

M2Font

a m2c2kit font

Remarks​

Typically, a user won't need to call this because font initialization and processing is handled by the framework.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:169


getFont()​

getFont(fontName): M2Font

Internal

Returns a m2c2kit font (M2Font) that has been loaded by the FontManager.

For m2c2kit library use only

Parameters​

• fontName: string

font's name as defined in the game's font assets

Returns​

M2Font

a m2c2kit font

Remarks​

Typically, a user won't need to call this because font initialization and processing is handled by the framework.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:153


getFontNames()​

getFontNames(): string[]

Gets names of fonts loaded.

Returns​

string[]

array of font names loaded from the game's font assets and converted into M2Font objects. The names are the names as defined in the game's font assets.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:219


getTypeface()​

getTypeface(fontName): Typeface

Internal

Gets a CanvasKit Typeface that has been loaded.

For m2c2kit library use only

Parameters​

• fontName: string

name as defined in the game's font assets

Returns​

Typeface

the requested Typeface

Remarks​

Typically, a user won't need to call this because font initialization and processing is handled by the framework.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:204


initializeFonts()​

initializeFonts(fonts): Promise<void>

Internal

Loads font assets and makes them ready to use during the game initialization.

For m2c2kit library use only

Parameters​

• fonts: undefined | FontAsset[]

array of FontAsset objects (name and url)

Returns​

Promise<void>

Remarks​

Typically, a user won't call this because the m2c2kit framework will call this automatically.

Defined in​

m2c2kit/packages/core/src/FontManager.ts:39


loadFonts()​

loadFonts(fonts): Promise<void>

Loads an array of fonts and makes them ready for the game.

Parameters​

• fonts: FontAsset[]

an array of FontAsset

Returns​

Promise<void>

A promise that completes when all fonts have loaded

Defined in​

m2c2kit/packages/core/src/FontManager.ts:49


prepareDeferredFont()​

prepareDeferredFont(font): Promise<void>

Internal

Makes ready to the game a m2c2kit font (M2Font) that was previously loaded, but whose processing was deferred.

For m2c2kit library use only

Parameters​

• font: M2Font

M2Font to make ready

Returns​

Promise<void>

A promise that completes when the font is ready

Defined in​

m2c2kit/packages/core/src/FontManager.ts:112