preload fonts

Hunter
Friday, February 6th, 2026 at 12:20 AM

resources/editor.js+4 
resources/font-registry.js+12 

resources/editor.js
  3  import { updatePreview, setupPreviewPane } from './preview-manager.js';
  4  import { navigateSpread, toggleFullscreen, initializeSpreadNav, getIsFullscreen } from './spread-navigation.js';
  5  import { initializeCodeMirror } from './codemirror-config.js';
  6 +import { preloadAllFonts } from './font-registry.js';
  7  import { isMobileDevice, exitMobileKeyboardMode, initializeMobileKeyboard } from './mobile-keyboard.js';
  8  
  9  // Global state

123  
124  // Initialize
125  initializeEditor();
126 +
127 +// Preload fonts in the background so they're ready when needed
128 +preloadAllFonts();
resources/font-registry.js
69  export function getAvailableFontFamilies() {
70  	return [...new Set(FONT_ENTRIES.map(e => e.family))];
71  }
72 +
73 +// Preload all fonts so they're immediately available when used
74 +export function preloadAllFonts() {
75 +	for (const entry of FONT_ENTRIES) {
76 +		const src = formatForCSS(entry.file);
77 +		const font = new FontFace(entry.family, src, {
78 +			weight: String(entry.weight),
79 +			style: entry.style,
80 +		});
81 +		font.load().then(loaded => document.fonts.add(loaded)).catch(() => {});
82 +	}
83 +}