Skip to main content

Class: FontManager

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

Source

FontManager.ts:21

Properties

baseUrls

private baseUrls: GameBaseUrls

Source

FontManager.ts:19


canvasKit

private canvasKit: CanvasKit

Source

FontManager.ts:17


fonts

fonts: Record<string, M2Font> = {}

Source

FontManager.ts:15


game

private game: Game

Source

FontManager.ts:18


provider

provider: TypefaceFontProvider

Source

FontManager.ts:16

Methods

dispose()

Internal

dispose(): void

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.

Source

FontManager.ts:186


fetchFontAsArrayBuffer()

private fetchFontAsArrayBuffer(font): Promise<ArrayBuffer>

Parameters

font: M2Font

Returns

Promise<ArrayBuffer>

Source

FontManager.ts:116


getDefaultFont()

Internal

getDefaultFont(): M2Font

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.

Source

FontManager.ts:168


getFont()

Internal

getFont(fontName): M2Font

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.

Source

FontManager.ts:152


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.

Source

FontManager.ts:217


getTypeface()

Internal

getTypeface(fontName): Typeface

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.

Source

FontManager.ts:202


initializeFonts()

Internal

initializeFonts(fonts): Promise<void>

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.

Source

FontManager.ts:38


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

Source

FontManager.ts:48


prepareDeferredFont()

Internal

prepareDeferredFont(font): Promise<void>

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

Source

FontManager.ts:111


prepareFont()

private prepareFont(font): Promise<void>

Parameters

font: M2Font

Returns

Promise<void>

Source

FontManager.ts:87


registerFont()

private registerFont(arrayBuffer, font): void

Parameters

arrayBuffer: ArrayBuffer

font: M2Font

Returns

void

Source

FontManager.ts:127