Skip to content

Commit 29c557e

Browse files
committed
Merge branch 'dev'
2 parents 1f3ea22 + 38a85b2 commit 29c557e

333 files changed

Lines changed: 181 additions & 189 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"codemetrics.basics.EnabledForJS": false,
3-
"cSpell.enabled": false
3+
"cSpell.enabled": false,
4+
"search.useGlobalIgnoreFiles": true
45
}

make/common/unicode-kind.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ exports.isKorean = c =>
2525
(c >= 0xd7b0 && c <= 0xd7ff);
2626

2727
exports.isWS = function (c) {
28-
return c >= 0x20a0 && c < 0x3000 && !(c >= 0x2e3a && c <= 0x2e3b);
28+
return (
29+
((c >= 0x2000 && c <= 0x200f) || (c >= 0x20a0 && c < 0x3000)) &&
30+
!(c >= 0x2e3a && c <= 0x2e3b)
31+
);
2932
};
3033

3134
exports.isLongDash = function (c, isTerm) {

make/punct/as.js

Lines changed: 53 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,38 @@
22

33
const introFont = require("../common/intro-font");
44
const buildFont = require("../common/build-font");
5-
const {
6-
isIdeograph,
7-
isWestern,
8-
isWS,
9-
isKorean,
10-
isLongDash,
11-
filterUnicodeRange
12-
} = require("../common/unicode-kind");
13-
const { sanitizeSymbols, removeUnusedFeatures, toPWID, removeDashCcmp } = require("./common");
5+
const { isWestern, isWS, isLongDash, filterUnicodeRange } = require("../common/unicode-kind");
146
const gc = require("../common/gc");
15-
const createFinder = require("../common/glyph-finder");
7+
8+
const { sanitizeSymbols, toPWID } = require("./sanitize-symbols");
9+
const { removeUnusedFeatures } = require("./remove-unused-features");
10+
const { transferMonoGeometry, unlinkRefsOfSymbols, populatePwidOfMono } = require("./lgc-handler");
1611

1712
module.exports = async function makeFont(argv) {
18-
const a = await introFont({ from: argv.main, prefix: "a", ignoreHints: true });
19-
const b = await introFont({ from: argv.lgc, prefix: "b", ignoreHints: true });
20-
a.cmap_uvs = null;
13+
const main = await introFont({ from: argv.main, prefix: "a", ignoreHints: true });
14+
const lgc = await introFont({ from: argv.lgc, prefix: "b", ignoreHints: true });
15+
main.cmap_uvs = null;
2116
filterUnicodeRange(
22-
a,
23-
c =>
24-
!isIdeograph(c - 0) &&
25-
!isWestern(c - 0) &&
26-
!isKorean(c - 0) &&
27-
!isLongDash(c - 0, argv.term) &&
28-
!isWS(c - 0)
17+
main,
18+
c => !isWestern(c - 0) && !isLongDash(c - 0, argv.term) && !isWS(c - 0)
2919
);
3020

31-
if (argv.pwid) toPWID(a);
32-
21+
if (argv.pwid) toPWID(main);
3322
if (argv.mono) {
34-
unlinkRefsOfSymbols(b, argv.term);
35-
transferMonoGeometry(a, b);
36-
populatePwidOfMono(a);
23+
unlinkRefsOfSymbols(lgc, argv.term);
24+
transferMonoGeometry(main, lgc);
25+
populatePwidOfMono(main);
3726
}
38-
if (!argv.pwid) sanitizeSymbols(a, argv.goth, !argv.pwid && !argv.term);
39-
if (argv.mono) removeDashCcmp(a, argv.mono);
27+
if (!argv.pwid) sanitizeSymbols(main, argv.goth, !argv.pwid && !argv.term);
28+
if (argv.mono) removeDashCcmp(main, argv.mono);
4029

41-
removeUnusedFeatures(a, "AS", argv.mono);
42-
aliasFeatMap(a, "vert", [[0x2014, 0x2015]]);
43-
gc(a);
30+
removeUnusedFeatures(main, "AS", argv.mono);
31+
aliasFeatMap(main, "vert", [[0x2014, 0x2015]]);
32+
gc(main);
4433

45-
await buildFont(a, { to: argv.o, optimize: true });
34+
await buildFont(main, { to: argv.o, optimize: true });
4635
};
4736

48-
// Monospace punctuation transferring
49-
function unlinkRefsOfSymbols(font, isTerm) {
50-
const find = createFinder(font);
51-
for (let u = 0x2000; u < 0x20a0; u++) {
52-
let gn = find.gname.unicode(u);
53-
if (!gn) continue;
54-
let gnT = gn;
55-
if (!isTerm) gnT = find.gname.subst("WWID", gn);
56-
if (!gnT) continue;
57-
const g = find.glyph(gn);
58-
const g$ = find.glyph$(gnT);
59-
HCopy(g, g$);
60-
}
61-
}
62-
function transferMonoGeometry(main, lgc) {
63-
for (let u = 0x2000; u < 0x20a0; u++) {
64-
let gnSrc = main.cmap[u],
65-
gnDst = lgc.cmap[u];
66-
if (gnSrc && gnDst) {
67-
HCopy(main.glyf[gnSrc], lgc.glyf[gnDst]);
68-
}
69-
}
70-
}
71-
function populatePwidOfMono(font) {
72-
const find = createFinder(font);
73-
for (let u = 0x2000; u < 0x20a0; u++) {
74-
const gn = find.gname.unicode(u);
75-
if (!gn) continue;
76-
const gnPwid = find.gname.subst("pwid", gn);
77-
if (!gnPwid) continue;
78-
const g = find.glyph(gnPwid);
79-
const g$ = find.glyph$(gn);
80-
HCopy(g, g$);
81-
}
82-
}
83-
84-
function HCopy(g, g1) {
85-
g.contours = g1.contours;
86-
g.references = g1.references;
87-
g.advanceWidth = g1.advanceWidth;
88-
}
89-
9037
// Feature mapping
9138
function aliasFeatMap(a, feat, aliases) {
9239
if (!a.GSUB || !a.GSUB.features || !a.GSUB.lookups) return;
@@ -113,3 +60,36 @@ function aliasFeatMap(a, feat, aliases) {
11360
}
11461
}
11562
}
63+
64+
// Dash CCMP removal
65+
function removeDashCcmp(a) {
66+
if (!a.GSUB || !a.GSUB.features || !a.GSUB.lookups) return;
67+
68+
let affectedLookups = new Set();
69+
for (const fid in a.GSUB.features) {
70+
if (fid.slice(0, 4) === "ccmp") {
71+
const feature = a.GSUB.features[fid];
72+
if (!feature) continue;
73+
for (const lid of feature) affectedLookups.add(lid);
74+
}
75+
}
76+
77+
for (const lid of affectedLookups) {
78+
const lookup = a.GSUB.lookups[lid];
79+
removeDashCcmpLookup(lookup, a.cmap);
80+
}
81+
}
82+
function removeDashCcmpLookup(lookup, cmap) {
83+
if (!lookup || lookup.type !== "gsub_ligature") return;
84+
for (const st of lookup.subtables) {
85+
let st1 = [];
86+
for (const subst of st.substitutions) {
87+
let valid = true;
88+
for (const gid of subst.from) {
89+
if (cmap[0x2014] === gid || cmap[0x2015] === gid) valid = false;
90+
}
91+
if (valid) st1.push(subst);
92+
}
93+
st.substitutions = st1;
94+
}
95+
}

make/punct/lgc-handler.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"use strict";
2+
3+
const createFinder = require("../common/glyph-finder");
4+
5+
// LGC transferring
6+
exports.unlinkRefsOfSymbols = function (font, isTerm) {
7+
const find = createFinder(font);
8+
for (let u = 0x2000; u < 0x20a0; u++) {
9+
let gn = find.gname.unicode(u);
10+
if (!gn) continue;
11+
let gnT = gn;
12+
if (!isTerm) gnT = find.gname.subst("WWID", gn);
13+
if (!gnT) continue;
14+
const g = find.glyph(gn);
15+
const g$ = find.glyph$(gnT);
16+
HCopy(g, g$);
17+
}
18+
};
19+
20+
exports.transferMonoGeometry = function (main, lgc) {
21+
for (let u = 0x2000; u < 0x20a0; u++) {
22+
let gnSrc = main.cmap[u],
23+
gnDst = lgc.cmap[u];
24+
if (gnSrc && gnDst) {
25+
HCopy(main.glyf[gnSrc], lgc.glyf[gnDst]);
26+
}
27+
}
28+
};
29+
30+
exports.populatePwidOfMono = function (font) {
31+
const find = createFinder(font);
32+
for (let u = 0x2000; u < 0x20a0; u++) {
33+
const gn = find.gname.unicode(u);
34+
if (!gn) continue;
35+
const gnPwid = find.gname.subst("pwid", gn);
36+
if (!gnPwid) continue;
37+
const g = find.glyph(gnPwid);
38+
const g$ = find.glyph$(gn);
39+
HCopy(g, g$);
40+
}
41+
};
42+
43+
function HCopy(g, g1) {
44+
g.contours = g1.contours;
45+
g.references = g1.references;
46+
g.advanceWidth = g1.advanceWidth;
47+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
exports.removeUnusedFeatures = function (a, kind, mono) {
4+
removeUnusedFeature(a.GSUB, "aalt");
5+
removeUnusedFeature(a.GSUB, "pwid");
6+
removeUnusedFeature(a.GSUB, "fwid");
7+
removeUnusedFeature(a.GSUB, "hwid");
8+
removeUnusedFeature(a.GSUB, "twid");
9+
removeUnusedFeature(a.GSUB, "qwid");
10+
11+
if (mono) {
12+
removeUnusedFeature(a.GSUB, "locl");
13+
removeUnusedFeature(a.GPOS, "kern");
14+
removeUnusedFeature(a.GPOS, "vkrn");
15+
removeUnusedFeature(a.GPOS, "palt");
16+
removeUnusedFeature(a.GPOS, "vpal");
17+
}
18+
19+
if (mono && kind === "WS") {
20+
removeUnusedFeature(a.GSUB, "ccmp");
21+
}
22+
};
23+
24+
function removeUnusedFeature(table, tag) {
25+
if (!table) return;
26+
for (let f in table.features) {
27+
if (f.slice(0, 4) === tag) {
28+
table.features[f] = null;
29+
}
30+
}
31+
}
Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -109,68 +109,6 @@ exports.sanitizeSymbols = function sanitizeSymbols(font, isGothic, isType) {
109109
}
110110
};
111111

112-
function removeUnusedFeature(table, tag) {
113-
if (!table) return;
114-
for (let f in table.features) {
115-
if (f.slice(0, 4) === tag) {
116-
table.features[f] = null;
117-
}
118-
}
119-
}
120-
121-
exports.removeUnusedFeatures = function (a, kind, mono) {
122-
removeUnusedFeature(a.GSUB, "aalt");
123-
removeUnusedFeature(a.GSUB, "pwid");
124-
removeUnusedFeature(a.GSUB, "fwid");
125-
removeUnusedFeature(a.GSUB, "hwid");
126-
removeUnusedFeature(a.GSUB, "twid");
127-
removeUnusedFeature(a.GSUB, "qwid");
128-
129-
if (mono) {
130-
removeUnusedFeature(a.GSUB, "locl");
131-
removeUnusedFeature(a.GPOS, "kern");
132-
removeUnusedFeature(a.GPOS, "vkrn");
133-
removeUnusedFeature(a.GPOS, "palt");
134-
removeUnusedFeature(a.GPOS, "vpal");
135-
}
136-
137-
if (mono && kind === "WS") {
138-
removeUnusedFeature(a.GSUB, "ccmp");
139-
}
140-
};
141-
142-
exports.removeDashCcmp = function (a) {
143-
if (!a.GSUB || !a.GSUB.features || !a.GSUB.lookups) return;
144-
145-
let affectedLookups = new Set();
146-
for (const fid in a.GSUB.features) {
147-
if (fid.slice(0, 4) === "ccmp") {
148-
const feature = a.GSUB.features[fid];
149-
if (!feature) continue;
150-
for (const lid of feature) affectedLookups.add(lid);
151-
}
152-
}
153-
154-
for (const lid of affectedLookups) {
155-
const lookup = a.GSUB.lookups[lid];
156-
removeDashCcmpLookup(lookup, a.cmap);
157-
}
158-
};
159-
function removeDashCcmpLookup(lookup, cmap) {
160-
if (!lookup || lookup.type !== "gsub_ligature") return;
161-
for (const st of lookup.subtables) {
162-
let st1 = [];
163-
for (const subst of st.substitutions) {
164-
let valid = true;
165-
for (const gid of subst.from) {
166-
if (cmap[0x2014] === gid || cmap[0x2015] === gid) valid = false;
167-
}
168-
if (valid) st1.push(subst);
169-
}
170-
st.substitutions = st1;
171-
}
172-
}
173-
174112
exports.toPWID = function (font) {
175113
const find = createFinder(font);
176114
for (let c in font.cmap) {

make/punct/ws.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22

33
const introFont = require("../common/intro-font");
44
const buildFont = require("../common/build-font");
5-
const {
6-
isIdeograph,
7-
isWestern,
8-
isWS,
9-
isKorean,
10-
isLongDash,
11-
filterUnicodeRange
12-
} = require("../common/unicode-kind");
13-
const { sanitizeSymbols, removeUnusedFeatures, toPWID } = require("./common");
5+
const { isWestern, isWS, isLongDash, filterUnicodeRange } = require("../common/unicode-kind");
146
const gc = require("../common/gc");
157

8+
const { sanitizeSymbols, toPWID } = require("./sanitize-symbols");
9+
const { removeUnusedFeatures } = require("./remove-unused-features");
10+
const { transferMonoGeometry, unlinkRefsOfSymbols, populatePwidOfMono } = require("./lgc-handler");
11+
1612
module.exports = async function makeFont(argv) {
17-
const a = await introFont({ from: argv.main, prefix: "a", ignoreHints: true });
18-
a.cmap_uvs = null;
13+
const main = await introFont({ from: argv.main, prefix: "a", ignoreHints: true });
14+
const lgc = await introFont({ from: argv.lgc, prefix: "b", ignoreHints: true });
15+
16+
main.cmap_uvs = null;
1917
filterUnicodeRange(
20-
a,
21-
c =>
22-
!isIdeograph(c - 0) &&
23-
!isWestern(c - 0) &&
24-
!isKorean(c - 0) &&
25-
!isLongDash(c - 0, argv.term) &&
26-
isWS(c - 0)
18+
main,
19+
c => !isWestern(c - 0) && !isLongDash(c - 0, argv.term) && isWS(c - 0)
2720
);
2821

29-
if (argv.pwid) toPWID(a);
30-
if (argv.mono) sanitizeSymbols(a, argv.goth, !argv.pwid && !argv.term);
22+
if (argv.pwid) toPWID(main);
23+
if (argv.mono) {
24+
unlinkRefsOfSymbols(lgc, argv.term);
25+
transferMonoGeometry(main, lgc);
26+
populatePwidOfMono(main);
27+
}
28+
if (!argv.pwid) {
29+
sanitizeSymbols(main, argv.goth, !argv.pwid && !argv.term);
30+
}
3131

32-
removeUnusedFeatures(a, "WS", argv.mono);
33-
gc(a);
32+
removeUnusedFeatures(main, "WS", argv.mono);
33+
gc(main);
3434

35-
await buildFont(a, { to: argv.o, optimize: true });
35+
await buildFont(main, { to: argv.o, optimize: true });
3636
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sarasa-gothic",
3-
"version": "0.16.2",
3+
"version": "0.16.3",
44
"main": "./run",
55
"scripts": {
66
"build": "verda -f verdafile.js",

0 commit comments

Comments
 (0)