forked from kiliman/operator-mono-lig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenspacers.js
36 lines (34 loc) · 1 KB
/
genspacers.js
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
const fs = require('fs');
const lig = `<Glyph name="LIG" lsb="0" width="625">
<CharString>
endchar
</CharString>
<Subrs/>
<GlobalSubrs/>
</Glyph>`;
fs.readdirSync('./ligature')
.filter((f) => !!f.match(/^OperatorMono/))
.forEach((f) => {
console.log(f);
fs.readdirSync(`./ligature/${f}/glyphs`)
.filter((g) => !!g.match(/\.liga\.xml$/))
.forEach((g) => {
console.log(g);
g.split('.')
.slice(0, 1)
.forEach((l) => {
l.split('_').forEach((c) => {
const path = `./ligature/${f}/glyphs/${c}.spacer.xml`;
const exists = fs.existsSync(path);
console.log(path, exists);
if (exists) return;
const width = !!f.match(/SSm/) ? 625 : 600;
const spacer = lig
.replace('LIG', `${c}.spacer`)
.replace('625', width);
console.log(f, c, width);
fs.writeFileSync(path, spacer);
});
});
});
});