font-registry.js (7.7 KB)
1 const FONT_ENTRIES = [ 2 { family: 'Baskervville', file: 'resources/fonts/baskervvile/Baskervville-Regular.ttf', weight: 400, style: 'normal' }, 3 { family: 'Baskervville', file: 'resources/fonts/baskervvile/Baskervville-Italic.ttf', weight: 400, style: 'italic' }, 4 { family: 'Baskervville', file: 'resources/fonts/baskervvile/Baskervville-Bold.ttf', weight: 700, style: 'normal' }, 5 { family: 'Baskervville', file: 'resources/fonts/baskervvile/Baskervville-BoldItalic.ttf', weight: 700, style: 'italic' }, 6 { family: 'Baskervville SemiBold', file: 'resources/fonts/baskervvile/Baskervville-SemiBold.ttf', weight: 600, style: 'normal' }, 7 { family: 'Baskervville SemiBold', file: 'resources/fonts/baskervvile/Baskervville-SemiBoldItalic.ttf', weight: 600, style: 'italic' }, 8 { family: 'Basteleur Bold', file: 'resources/fonts/basteleur-master/Basteleur-Bold.ttf', weight: 700, style: 'normal' }, 9 { family: 'Basteleur Moonlight', file: 'resources/fonts/basteleur-master/Basteleur-Moonlight.ttf', weight: 400, style: 'normal' }, 10 { family: 'Avara', file: 'resources/fonts/Avara-master/Avara-Bold.otf', weight: 700, style: 'normal' }, 11 { family: 'Avara', file: 'resources/fonts/Avara-master/Avara-BoldItalic.otf', weight: 700, style: 'italic' }, 12 { family: 'Avara Black', file: 'resources/fonts/Avara-master/Avara-Black.otf', weight: 900, style: 'normal' }, 13 { family: 'Ballet', file: 'resources/fonts/Ballet/Ballet_28pt-Regular.ttf', weight: 400, style: 'normal' }, 14 { family: 'Bitcount Single', file: 'resources/fonts/Bitcount_Single/BitcountSingle-Regular.ttf', weight: 400, style: 'normal' }, 15 { family: 'Cut Me Out 2', file: 'resources/fonts/CutMeOut/CutMeOut2.ttf', weight: 400, style: 'normal' }, 16 { family: 'Elb-Tunnel', file: 'resources/fonts/ElbtunnelTT/Elb-Tunnel.ttf', weight: 400, style: 'normal' }, 17 { family: 'Elb-Tunnel Schatten', file: 'resources/fonts/ElbtunnelTT/Elb-Tunnel Schatten.ttf', weight: 400, style: 'normal' }, 18 { family: 'Eagle Lake', file: 'resources/fonts/Eagle_Lake/EagleLake-Regular.ttf', weight: 400, style: 'normal' }, 19 { family: 'Eureka', file: 'resources/fonts/Eureka/Eureka.ttf', weight: 400, style: 'normal' }, 20 { family: 'Feroniapi', file: 'resources/fonts/feroniapi-main/Feroniapi-MediumItalic.otf', weight: 500, style: 'italic' }, 21 { family: 'Geostar Fill', file: 'resources/fonts/Geostar_Fill/GeostarFill-Regular.ttf', weight: 400, style: 'normal' }, 22 { family: 'Hyper Scrypt', file: 'resources/fonts/Hyper-Scrypt-master/HyperScrypt.otf', weight: 400, style: 'normal' }, 23 { family: 'IBM Plex Serif', file: 'resources/fonts/IBM_Plex_Serif/IBMPlexSerif-Regular.ttf', weight: 400, style: 'normal' }, 24 { family: 'IBM Plex Serif', file: 'resources/fonts/IBM_Plex_Serif/IBMPlexSerif-Italic.ttf', weight: 400, style: 'italic' }, 25 { family: 'IBM Plex Serif', file: 'resources/fonts/IBM_Plex_Serif/IBMPlexSerif-Bold.ttf', weight: 700, style: 'normal' }, 26 { family: 'IBM Plex Serif', file: 'resources/fonts/IBM_Plex_Serif/IBMPlexSerif-BoldItalic.ttf', weight: 700, style: 'italic' }, 27 { family: 'Indira K', file: 'resources/fonts/Indira_K/Indira_K.ttf', weight: 400, style: 'normal' }, 28 { family: 'Instrument Serif', file: 'resources/fonts/Instrument_Serif/InstrumentSerif-Regular.ttf', weight: 400, style: 'normal' }, 29 { family: 'Instrument Serif', file: 'resources/fonts/Instrument_Serif/InstrumentSerif-Italic.ttf', weight: 400, style: 'italic' }, 30 { family: 'Jacquard 12', file: 'resources/fonts/Jacquard_12/Jacquard12-Regular.ttf', weight: 400, style: 'normal' }, 31 { family: 'Jacquarda Bastarda 9', file: 'resources/fonts/Jacquarda_Bastarda_9/JacquardaBastarda9-Regular.ttf', weight: 400, style: 'normal' }, 32 { family: 'Jgs Font', file: 'resources/fonts/jgs-main/jgs_Font.ttf', weight: 400, style: 'normal' }, 33 { family: 'Jgs 5', file: 'resources/fonts/jgs-main/jgs5.ttf', weight: 400, style: 'normal' }, 34 { family: 'Jgs 7', file: 'resources/fonts/jgs-main/jgs7.ttf', weight: 400, style: 'normal' }, 35 { family: 'Jgs 9', file: 'resources/fonts/jgs-main/jgs9.ttf', weight: 400, style: 'normal' }, 36 { family: 'Kaeru Kaeru', file: 'resources/fonts/kaerukaeru-master/kaerukaeru-Regular.otf', weight: 400, style: 'normal' }, 37 { family: 'Kanalisirung', file: 'resources/fonts/Kanalisirung/Kanalisirung.otf', weight: 400, style: 'normal' }, 38 { family: 'Karrik', file: 'resources/fonts/karrik_fonts-main/Karrik-Regular.ttf', weight: 400, style: 'normal' }, 39 { family: 'Karrik', file: 'resources/fonts/karrik_fonts-main/Karrik-Italic.ttf', weight: 400, style: 'italic' }, 40 { family: 'Kings', file: 'resources/fonts/Kings/Kings-Regular.ttf', weight: 400, style: 'normal' }, 41 { family: 'Matemasie', file: 'resources/fonts/Matemasie/Matemasie-Regular.ttf', weight: 400, style: 'normal' }, 42 { family: 'Mess', file: 'resources/fonts/Mess-master/Mess.otf', weight: 300, style: 'normal' }, 43 { family: 'Mon Hugo', file: 'resources/fonts/Mon_Hugo_freefont/MonHugo-in.ttf', weight: 400, style: 'normal' }, 44 { family: 'Mon Hugo Out', file: 'resources/fonts/Mon_Hugo_freefont/MonHugo-out.ttf', weight: 400, style: 'normal' }, 45 { family: 'Murrx', file: 'resources/fonts/Murrx/Murrx.ttf', weight: 400, style: 'normal' }, 46 { family: 'Neo-castel', file: 'resources/fonts/Neo-castel/webfont/Neo-castel.woff2', weight: 400, style: 'normal' }, 47 { family: 'Ouest', file: 'resources/fonts/OUEST/Ouest-Regular.ttf', weight: 400, style: 'normal' }, 48 { family: 'Princess Sofia', file: 'resources/fonts/Princess_Sofia/PrincessSofia-Regular.ttf', weight: 400, style: 'normal' }, 49 { family: 'Resistance', file: 'resources/fonts/resistance-generale-master/Resistance-generale.otf', weight: 400, style: 'normal' }, 50 { family: 'Snowburst One', file: 'resources/fonts/Snowburst_One/SnowburstOne-Regular.ttf', weight: 400, style: 'normal' }, 51 { family: 'Special Elite', file: 'resources/fonts/Special_Elite/SpecialElite-Regular.ttf', weight: 400, style: 'normal' }, 52 { family: 'Special Gothic Expanded One', file: 'resources/fonts/Special_Gothic_Expanded_One/SpecialGothicExpandedOne-Regular.ttf', weight: 400, style: 'normal' }, 53 { family: 'Steps Mono', file: 'resources/fonts/steps-mono-main/Steps-Mono.otf', weight: 400, style: 'normal' }, 54 { family: 'Steps Mono Thin', file: 'resources/fonts/steps-mono-main/Steps-Mono-Thin.otf', weight: 100, style: 'normal' }, 55 { family: 'Terminal Grotesque', file: 'resources/fonts/Terminal-Grotesque-master/terminal-grotesque.ttf', weight: 400, style: 'normal' }, 56 { family: 'Terminal Grotesque Open', file: 'resources/fonts/Terminal-Grotesque-master/terminal-grotesque_open.otf', weight: 400, style: 'normal' }, 57 { family: 'Tiny5', file: 'resources/fonts/Tiny5/Tiny5-Regular.ttf', weight: 400, style: 'normal' }, 58 { family: 'Trickster', file: 'resources/fonts/Trickster-master/Trickster-Reg.otf', weight: 400, style: 'normal' }, 59 ]; 60 61 function formatForCSS(file) { 62 if (file.endsWith('.woff2')) return `url('${file}') format('woff2')`; 63 if (file.endsWith('.woff')) return `url('${file}') format('woff')`; 64 if (file.endsWith('.otf')) return `url('${file}') format('opentype')`; 65 return `url('${file}') format('truetype')`; 66 } 67 68 // Generate @font-face CSS for all registered fonts 69 export function generateFontFaceCSS() { 70 return FONT_ENTRIES.map(entry => 71 `@font-face { 72 font-family: '${entry.family}'; 73 src: ${formatForCSS(entry.file)}; 74 font-weight: ${entry.weight}; 75 font-style: ${entry.style}; 76 font-display: swap; 77 }` 78 ).join('\n'); 79 } 80 81 // Get list of available font family names (deduplicated) 82 export function getAvailableFontFamilies() { 83 return [...new Set(FONT_ENTRIES.map(e => e.family))]; 84 } 85 86 // Preload all fonts so they're immediately available when used 87 export function preloadAllFonts() { 88 for (const entry of FONT_ENTRIES) { 89 const src = formatForCSS(entry.file); 90 const font = new FontFace(entry.family, src, { 91 weight: String(entry.weight), 92 style: entry.style, 93 }); 94 font.load().then(loaded => document.fonts.add(loaded)).catch(() => {}); 95 } 96 }