3 var cdn = require('gitter-web-cdn');
5 const katexFolder = 'repo/katex/fonts-0.10.0';
6 const getKatexSuffix = (weight, style) => {
8 'normal,normal': 'Regular',
9 'normal,italic': 'Italic',
10 'bold,normal': 'Bold',
11 'bold,italic': 'BoldItalic'
13 return suffixMap[`${weight},${style}`];
15 const generateKatexFont = (family, weight, style) => ({
16 fontPath: cdn(`${katexFolder}/KaTeX_${family}-${getKatexSuffix(weight, style)}`),
17 // All modern browsers except IE support woff2 https://caniuse.com/#feat=woff2
18 // IE is going to fall back on Times New Roman, 0.82% of users are using IE as of 07/2019
19 formats: ['woff', 'woff2'],
21 family: `KaTeX_${family}`,
27 fontPath: cdn('fonts/sourcesans/SourceSansPro-Regular.otf'),
30 family: 'source-sans-pro',
34 fontPath: cdn('fonts/sourcesans/SourceSansPro-It.otf'),
37 family: 'source-sans-pro',
41 fontPath: cdn('fonts/sourcesans/SourceSansPro-Bold.otf'),
44 family: 'source-sans-pro',
48 fontPath: cdn('fonts/sourcesans/SourceSansPro-Semibold.otf'),
51 family: 'source-sans-pro',
55 fontPath: cdn('fonts/sourcesans/SourceSansPro-BoldIt.otf'),
58 family: 'source-sans-pro',
62 fontPath: cdn('fonts/sourcesans/SourceSansPro-Light.otf'),
65 family: 'source-sans-pro',
69 fontPath: cdn('fonts/sourcesans/SourceSansPro-ExtraLight.otf'),
72 family: 'source-sans-pro',
77 generateKatexFont('AMS', 'normal', 'normal'),
78 generateKatexFont('Caligraphic', 'bold', 'normal'),
79 generateKatexFont('Caligraphic', 'normal', 'normal'),
80 generateKatexFont('Fraktur', 'bold', 'normal'),
81 generateKatexFont('Fraktur', 'normal', 'normal'),
82 generateKatexFont('Main', 'bold', 'normal'),
83 generateKatexFont('Main', 'bold', 'italic'),
84 generateKatexFont('Main', 'normal', 'italic'),
85 generateKatexFont('Main', 'normal', 'normal'),
86 //generateKatexFont('Math', 'bold', 'normal'),
87 generateKatexFont('Math', 'bold', 'italic'),
88 generateKatexFont('Math', 'normal', 'italic'),
89 //generateKatexFont('Math', 'normal', 'normal'),
90 generateKatexFont('SansSerif', 'bold', 'normal'),
91 generateKatexFont('SansSerif', 'normal', 'italic'),
92 generateKatexFont('SansSerif', 'normal', 'normal'),
93 generateKatexFont('Script', 'normal', 'normal'),
94 generateKatexFont('Size1', 'normal', 'normal'),
95 generateKatexFont('Size2', 'normal', 'normal'),
96 generateKatexFont('Size3', 'normal', 'normal'),
97 generateKatexFont('Size4', 'normal', 'normal'),
98 generateKatexFont('Typewriter', 'normal', 'normal')
101 { name: 'SourceSansPro-Bold', weight: 'bold', style: 'normal' },
102 { name: 'SourceSansPro-BoldIt', weight: 'bold', style: 'italic' },
103 { name: 'SourceSansPro-ExtraLight', weight: 200, style: 'normal' },
104 { name: 'SourceSansPro-It', weight: 'normal', style: 'italic' },
105 { name: 'SourceSansPro-Light', weight: 300, style: 'normal' },
106 { name: 'SourceSansPro-Regular', weight: 'normal', style: 'normal' },
107 { name: 'SourceSansPro-Semibold', weight: 600, style: 'normal' }
110 function getFonts() {
111 return { local: LOCAL_FONTS, cdnFonts: [...FONTS, ...KATEX] };
114 function hasCachedFonts(cookies) {
115 return (cookies.webfontsLoaded || '') === 'true';
120 hasCachedFonts: hasCachedFonts