Skip to main content

Class: FontAtlasCache

Defined in: text/font-atlas/font-atlas-cache.ts:12

Loads and caches FontAtlases: a metrics JSON file plus its atlas image, keyed by the JSON file's path (e.g. getOrLoad('assets/fonts/my-font.json') loads that file, which in turn points at its own atlas image, resolved relative to the JSON file).

Implements​

Constructors​

Constructor​

new FontAtlasCache(imageCache?): FontAtlasCache

Defined in: text/font-atlas/font-atlas-cache.ts:17

Parameters​

imageCache?​

ImageCache = ...

Returns​

FontAtlasCache

Properties​

assets​

assets: Map<string, FontAtlas>

Defined in: text/font-atlas/font-atlas-cache.ts:13

A map of asset keys to their corresponding assets.

Implementation of​

AssetCache.assets

Methods​

get()​

get(key): FontAtlas

Defined in: text/font-atlas/font-atlas-cache.ts:27

Retrieves a font atlas from the cache.

Parameters​

key​

string

The path of the font atlas's JSON file.

Returns​

FontAtlas

The cached font atlas.

Throws​

Will throw an error if the font atlas is not found in the cache.

Implementation of​

AssetCache.get


getOrLoad()​

getOrLoad(key): Promise<FontAtlas>

Defined in: text/font-atlas/font-atlas-cache.ts:69

Retrieves a font atlas from the cache if it exists, otherwise loads and caches it.

Parameters​

key​

string

The key of the font atlas to retrieve or load.

Returns​

Promise<FontAtlas>

A promise that resolves to the font atlas.

Implementation of​

AssetCache.getOrLoad


load()​

load(key): Promise<void>

Defined in: text/font-atlas/font-atlas-cache.ts:45

Loads a font atlas's JSON metrics and image from the specified key and caches it.

Parameters​

key​

string

The path of the font atlas's JSON file.

Returns​

Promise<void>

A promise that resolves when the font atlas is loaded and cached.

Throws​

Will throw an error if the JSON fails to fetch, is malformed, or is an unsupported/incompatible atlas format.

Implementation of​

AssetCache.load