Skip to content

Commit 655edeb

Browse files
authored
Return promise in setCustomFonts (TurboWarp#29)
related to TurboWarp/packager#999 TurboWarp/packager#1078
1 parent 430b44f commit 655edeb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎src/RenderWebGL.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,6 +2386,7 @@ class RenderWebGL extends EventEmitter {
23862386
* SEURITY CONSIDERATIONS: It is the caller's responsibility to ensure that the @font-face
23872387
* statements do not contain malicious styles.
23882388
* @param {Record<string, string>} customFonts Maps full font families (with fallbacks) to @font-face statements.
2389+
* @returns {Promise<unknown>} Resolves when the fonts are ready to use. Never rejects.
23892390
*/
23902391
setCustomFonts (customFonts) {
23912392
this.customFonts = customFonts;
@@ -2412,10 +2413,9 @@ class RenderWebGL extends EventEmitter {
24122413
typeof document.fonts.load === 'function'
24132414
) {
24142415
const families = Object.keys(customFonts);
2415-
for (const family of families) {
2416-
document.fonts.load(`12px ${family}`);
2417-
}
2416+
return Promise.all(families.map(family => document.fonts.load(`12px ${family}`).catch(() => {})));
24182417
}
2418+
return Promise.resolve();
24192419
}
24202420
}
24212421

0 commit comments

Comments
 (0)