MCPcopy Create free account
hub / github.com/galacean/engine / load

Method load

packages/loader/src/SourceFontLoader.ts:13–26  ·  view source on GitHub ↗
(item: LoadItem, resourceManager: ResourceManager)

Source from the content-addressed store, hash-verified

11@resourceLoader(AssetType.SourceFont, ["ttf", "otf", "woff"], false)
12class SourceFontLoader extends Loader<Font> {
13 load(item: LoadItem, resourceManager: ResourceManager): AssetPromise<Font> {
14 return new AssetPromise((resolve, reject) => {
15 // @ts-ignore
16 const url = resourceManager._getRemoteUrl(item.url);
17 this._registerFont(url, url)
18 .then(() => {
19 const font = new Font(resourceManager.engine, url);
20 resolve(font);
21 })
22 .catch((e) => {
23 reject(`load font ${url} fail`);
24 });
25 });
26 }
27
28 private async _registerFont(fontName: string, fontUrl: string): Promise<void> {
29 const fontFace = new FontFace(fontName, `url(${fontUrl})`);

Callers 1

_registerFontMethod · 0.45

Calls 4

_registerFontMethod · 0.95
_getRemoteUrlMethod · 0.80
catchMethod · 0.80
thenMethod · 0.80

Tested by

no test coverage detected