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
Defined in
FontManager.ts:21
Properties
fonts
fonts:
Record
<string
,M2Font
> ={}
Defined in
FontManager.ts:15
provider
provider:
TypefaceFontProvider
Defined in
FontManager.ts:16
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
FontManager.ts:186
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
FontManager.ts:168
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
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.
Defined in
FontManager.ts:217
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
FontManager.ts:202
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
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
Defined in
FontManager.ts:48
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
FontManager.ts:111