Merge branch 'fonts-preloading' into 'master'

Fonts preloading

See merge request dungeonslayers/ds4!160
This commit is contained in:
Johannes Loher 2021-11-30 18:06:12 +00:00
commit 49cce13033
2 changed files with 13 additions and 3 deletions

View file

@ -2,8 +2,18 @@
//
// SPDX-License-Identifier: MIT
const fonts = ["Lora", "Wood Stamp"];
const basicFonts = ["Wood Stamp"];
const variantFonts = ["Lora"];
export async function preloadFonts(): Promise<FontFace[][]> {
return Promise.all(fonts.map((font) => document.fonts.load(`1rem ${font}`)));
const fonts = [
...basicFonts.map((font) => `1rem ${font}`),
...variantFonts.flatMap((font) => [
`1rem ${font}`,
`bold 1rem ${font}`,
`italic 1rem ${font}`,
`bold italic 1rem ${font}`,
]),
];
return Promise.all(fonts.map((font) => document.fonts.load(font)));
}

View file

@ -3,7 +3,7 @@
// SPDX-License-Identifier: MIT
export default function registerHandlebarsHelpers(): void {
Object.entries(helpers).forEach(([key, helper]) => Handlebars.registerHelper(key, helper));
Handlebars.registerHelper(helpers);
}
const helpers = {