chore(web): Merge branch 'fix/web/keyboard-documentation-font-sizing' into feat/web/font-load-key-scale-test

This commit is contained in:
Joshua A. Horton 2024-01-29 16:02:48 +07:00
commit aec212b079
2 changed files with 11 additions and 6 deletions

View file

@ -29,6 +29,10 @@ export class StylesheetManager {
}
linkStylesheet(sheet: HTMLStyleElement) {
if(!(sheet instanceof HTMLLinkElement) && !sheet.innerHTML) {
return;
}
this.linkedSheets.push(sheet);
this.linkNode.appendChild(sheet);
}
@ -51,6 +55,7 @@ export class StylesheetManager {
} else {
const promise = new ManagedPromise<void>();
sheetElem.addEventListener('load', () => promise.resolve());
sheetElem.addEventListener('error', () => promise.reject());
promises.push(promise.corePromise);
}
}
@ -174,12 +179,10 @@ export class StylesheetManager {
* For now, we're using this solely to detect when the font has been succesfully loaded.
*/
const fontFace = new FontFace(fd.family, source);
const loadPromise = fontFace.load();
this.fontPromises.push(loadPromise);
const clearPromise = () => this.fontPromises = this.fontPromises.filter((entry) => entry != loadPromise);
loadPromise.then(clearPromise);
loadPromise.catch(clearPromise);
const loadPromise = fontFace.load().then(clearPromise).catch(clearPromise);
this.fontPromises.push(loadPromise);
this.linkStylesheet(sheet);

View file

@ -1360,8 +1360,10 @@ export default class VisualKeyboard extends EventEmitter<EventMap> implements Ke
if (activeKeyboard != null && typeof (activeKeyboard.oskStyling) == 'string') // KMEW-129
customStyle = customStyle + activeKeyboard.oskStyling;
this.styleSheet = createStyleSheet(customStyle); //Build 360
this.styleSheetManager.linkStylesheet(this.styleSheet);
if(customStyle) {
this.styleSheet = createStyleSheet(customStyle); //Build 360
this.styleSheetManager.linkStylesheet(this.styleSheet);
}
// Once any related fonts are loaded, we can re-adjust key-cap scaling.
this.styleSheetManager.allLoadedPromise().then(() => this.refreshLayout());