fix: properly preload bold and italic font variants

This commit is contained in:
Johannes Loher 2021-11-30 19:03:26 +01:00
parent 43385299c4
commit 0bbfdaf381

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)));
}