const NERD_FONT_CANDIDATES = [ "JetBrainsMono Nerd Font", "JetBrainsMono Nerd Font Mono", "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "FiraCode Nerd Font Mono", "MesloLGS NF", "MesloLGM Nerd Font", "Hack Nerd Font", "Hack Nerd Font Mono", "CaskaydiaCove Nerd Font", "CaskaydiaMono Nerd Font", "Iosevka Nerd Font", "Iosevka Term Nerd Font", "SauceCodePro Nerd Font", "Hasklug Nerd Font", ]; const FALLBACK_CHAIN = '"JetBrains Mono", SFMono-Regular, Menlo, monospace'; let detected: string | null = null; export function detectMonoFontFamily(): string { if (detected) return detected; if (typeof document === "undefined" || !document.fonts) { detected = FALLBACK_CHAIN; return detected; } for (const f of NERD_FONT_CANDIDATES) { try { if (document.fonts.check(`12px "${f}"`)) { detected = `"${f}", ${FALLBACK_CHAIN}`; return detected; } } catch { // Some browsers throw on invalid font shorthand; ignore. } } detected = FALLBACK_CHAIN; return detected; }