-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ts
50 lines (40 loc) · 987 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import fs from 'fs';
import {
createCSSImportTemplate,
parseUnicodeSet,
createSubset,
parseGlyph,
} from './modules';
import * as config from './config';
const main = () => {
const { unicodes } = parseGlyph(config.Paths.base);
const {
charset,
unicodeRange,
rangesInGoogleFont,
} = parseUnicodeSet(
config.BaseGoogleFont,
unicodes,
);
// create CSS File for import webfont
const cssTemplates: string[] = [];
charset.forEach(async (str, index) => {
cssTemplates[index] = createCSSImportTemplate(
config.FontData,
index,
rangesInGoogleFont[index],
);
await createSubset({
index,
font: config.FontData,
paths: config.Paths,
});
});
const css = cssTemplates.join('');
fs.writeFileSync(`${config.Paths.subset}/${config.FontData.fileName}.css`, css);
fs.writeFileSync(
`./${config.FontData.family}.json`,
JSON.stringify({ charset, unicodeRange }, null, 2),
);
};
main();