commit c019a757881ba04cb3f183a174226fa8e8c57ee7
parent 0938e3c2bb7138cf35c850e7a582569e3620957c
Author: Hunter
Date: Fri, 6 Feb 2026 00:20:36 -0500
preload fonts
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/resources/editor.js b/resources/editor.js
@@ -3,6 +3,7 @@ import { saveFile, loadFile } from './file-operations.js';
import { updatePreview, setupPreviewPane } from './preview-manager.js';
import { navigateSpread, toggleFullscreen, initializeSpreadNav, getIsFullscreen } from './spread-navigation.js';
import { initializeCodeMirror } from './codemirror-config.js';
+import { preloadAllFonts } from './font-registry.js';
import { isMobileDevice, exitMobileKeyboardMode, initializeMobileKeyboard } from './mobile-keyboard.js';
// Global state
@@ -122,3 +123,6 @@ async function initializeEditor() {
// Initialize
initializeEditor();
+
+// Preload fonts in the background so they're ready when needed
+preloadAllFonts();
diff --git a/resources/font-registry.js b/resources/font-registry.js
@@ -69,3 +69,15 @@ export function generateFontFaceCSS() {
export function getAvailableFontFamilies() {
return [...new Set(FONT_ENTRIES.map(e => e.family))];
}
+
+// Preload all fonts so they're immediately available when used
+export function preloadAllFonts() {
+ for (const entry of FONT_ENTRIES) {
+ const src = formatForCSS(entry.file);
+ const font = new FontFace(entry.family, src, {
+ weight: String(entry.weight),
+ style: entry.style,
+ });
+ font.load().then(loaded => document.fonts.add(loaded)).catch(() => {});
+ }
+}