Class: FontFaceObserverFontManager

FontFaceObserverFontManager

new gdjs.FontFaceObserverFontManager(resources)

FontFaceObserverFontManager loads fonts (using fontfaceobserver library) from the game resources (see loadFonts), and allow to access to the font families of the loaded fonts during the game (see getFontFamily).

"@font-face" declarations must be have been added separately in the index.html (or any CSS file).

Name Type Description
resources Object

The resources data of the game.

Methods

Return the font family associated to the specified font resource name. The font resource must have been loaded before. If that's not the case, a font family will be returned but without guarantee of it being loaded (to keep compatibility with GDevelop 5.0-beta56 and previous).

Name Type Description
resourceName string

The name of the resource to get.

Returns:
Type Description
string The font family to be used for this font resource, or "Arial" if resourceName is empty.

Return the font file associated to the specified font resource name. The font resource must have been loaded before. If that's not the case, the resource name will be returned (to keep compatibility with GDevelop 5.0-beta56 and previous).

Should only be useful for renderers running on a non HTML5/non browser environment.

Name Type Description
resourceName string

The name of the resource to get.

Returns:
Type Description
string The file of the font resource.

loadFonts(onProgress, onComplete, resources)

Load the specified resources, so that fonts are loaded and can then be used by using the font family returned by getFontFamily.

Name Type Description
onProgress

Callback called each time a new file is loaded.

onComplete

Callback called when loading is done.

resources

The resources to be loaded. If not specified, will load the resources specified in the FontFaceObserverFontManager constructor.