From 0bbfdaf381af163f848c68ce05b234297bc95f38 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 30 Nov 2021 19:03:26 +0100 Subject: [PATCH] fix: properly preload bold and italic font variants --- src/module/fonts.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/module/fonts.ts b/src/module/fonts.ts index 75c52bdc..ec0e72e1 100644 --- a/src/module/fonts.ts +++ b/src/module/fonts.ts @@ -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 { - 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))); }