Skip to content

Commit 0fc1f04

Browse files
committed
Merge branch 'dev'
2 parents af7135f + e96db79 commit 0fc1f04

331 files changed

Lines changed: 120 additions & 73 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.

config.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"familyOrder": ["gothic", "ui", "mono", "mono-slab", "term", "term-slab", "fixed", "fixed-slab"],
44
"families": {
55
"gothic": {
6-
"isMono": false,
76
"isTNUM": true,
7+
"isGothic": true,
88
"latinGroup": "Inter",
99
"naming": {
1010
"en_US": "Sarasa Gothic",
@@ -16,9 +16,8 @@
1616
}
1717
},
1818
"ui": {
19-
"isPWID": true,
2019
"isTNUM": true,
21-
"isMono": false,
20+
"isPWID": true,
2221
"latinGroup": "Inter",
2322
"naming": {
2423
"en_US": "Sarasa UI",
@@ -31,7 +30,6 @@
3130
},
3231
"mono": {
3332
"isMono": true,
34-
"isType": true,
3533
"latinGroup": "iosevka",
3634
"naming": {
3735
"en_US": "Sarasa Mono",
@@ -44,8 +42,8 @@
4442
},
4543
"term": {
4644
"isMono": true,
47-
"latinGroup": "iosevka-term",
4845
"isTerm": true,
46+
"latinGroup": "iosevka-term",
4947
"naming": {
5048
"en_US": "Sarasa Term",
5149
"zh_CN": "Sarasa Term",
@@ -57,8 +55,8 @@
5755
},
5856
"fixed": {
5957
"isMono": true,
60-
"latinGroup": "iosevka-fixed",
6158
"isTerm": true,
59+
"latinGroup": "iosevka-fixed",
6260
"naming": {
6361
"en_US": "Sarasa Fixed",
6462
"zh_CN": "Sarasa Fixed",

make/common/unicode-kind.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ exports.isKorean = c =>
2424
(c >= 0xa960 && c <= 0xa97f) ||
2525
(c >= 0xd7b0 && c <= 0xd7ff);
2626

27-
exports.isWS = function (c, _isType = false, isTerm = false) {
28-
return c >= (isTerm ? 0x2000 : 0x20a0) && c < 0x3000 && !(c >= 0x2e3a && c <= 0x2e3b);
27+
exports.isWS = function (c) {
28+
return c >= 0x20a0 && c < 0x3000 && !(c >= 0x2e3a && c <= 0x2e3b);
2929
};
3030

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

make/punct/as.js

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,12 @@ const {
99
isLongDash,
1010
filterUnicodeRange
1111
} = require("../common/unicode-kind");
12-
const {
13-
sanitizeSymbols,
14-
removeUnusedFeatures,
15-
toPWID,
16-
removeDashCcmp,
17-
aliasFeatMap
18-
} = require("./common");
12+
const { sanitizeSymbols, removeUnusedFeatures, toPWID, removeDashCcmp } = require("./common");
1913
const gc = require("../common/gc");
2014

2115
module.exports = async function makeFont(ctx, config, argv) {
22-
const a = await ctx.run(introduce, "a", {
23-
from: argv.main,
24-
prefix: "a",
25-
ignoreHints: true
26-
});
16+
const a = await ctx.run(introduce, "a", { from: argv.main, prefix: "a", ignoreHints: true });
17+
const b = await ctx.run(introduce, "b", { from: argv.lgc, prefix: "b", ignoreHints: true });
2718
a.cmap_uvs = null;
2819
filterUnicodeRange(
2920
a,
@@ -32,14 +23,21 @@ module.exports = async function makeFont(ctx, config, argv) {
3223
!isWestern(c - 0) &&
3324
!isKorean(c - 0) &&
3425
!isLongDash(c - 0, argv.term) &&
35-
!isWS(c - 0, argv.type, argv.term)
26+
!isWS(c - 0)
3627
);
3728

3829
if (argv.pwid) {
3930
await ctx.run(manip.glyph, "a", toPWID);
4031
}
4132
if (argv.mono) {
42-
await ctx.run(manip.glyph, "a", sanitizeSymbols, argv.type);
33+
await ctx.run(manip.glyph, "b", unlinkRefsOfSymbols, argv.term);
34+
transferMonoGeometry(ctx.items.a, ctx.items.b);
35+
await ctx.run(manip.glyph, "a", populatePwidOfMono);
36+
}
37+
if (!argv.pwid) {
38+
await ctx.run(manip.glyph, "a", sanitizeSymbols, argv.goth, !argv.pwid && !argv.term);
39+
}
40+
if (argv.mono) {
4341
removeDashCcmp(ctx.items.a, argv.mono);
4442
}
4543
removeUnusedFeatures(ctx.items.a, "AS", argv.mono);
@@ -49,3 +47,70 @@ module.exports = async function makeFont(ctx, config, argv) {
4947
await ctx.run(build, "a", { to: argv.o, optimize: true });
5048
ctx.remove("a");
5149
};
50+
51+
// Monospace punctuation transferring
52+
function unlinkRefsOfSymbols(isTerm) {
53+
for (let u = 0x2000; u < 0x20a0; u++) {
54+
let gn = this.find.gname.unicode(u);
55+
if (!gn) continue;
56+
let gnT = gn;
57+
if (!isTerm) gnT = this.find.gname.subst("WWID", gn);
58+
if (!gnT) continue;
59+
const g = this.find.glyph(gn);
60+
const g$ = this.find.glyph$(gnT);
61+
HCopy(g, g$);
62+
}
63+
}
64+
function transferMonoGeometry(main, lgc) {
65+
for (let u = 0x2000; u < 0x20a0; u++) {
66+
let gnSrc = main.cmap[u],
67+
gnDst = lgc.cmap[u];
68+
if (gnSrc && gnDst) {
69+
HCopy(main.glyf[gnSrc], lgc.glyf[gnDst]);
70+
}
71+
}
72+
}
73+
function populatePwidOfMono() {
74+
for (let u = 0x2000; u < 0x20a0; u++) {
75+
const gn = this.find.gname.unicode(u);
76+
if (!gn) continue;
77+
const gnPwid = this.find.gname.subst("pwid", gn);
78+
if (!gnPwid) continue;
79+
const g = this.find.glyph(gnPwid);
80+
const g$ = this.find.glyph$(gn);
81+
HCopy(g, g$);
82+
}
83+
}
84+
85+
function HCopy(g, g1) {
86+
g.contours = g1.contours;
87+
g.references = g1.references;
88+
g.advanceWidth = g1.advanceWidth;
89+
}
90+
91+
// Feature mapping
92+
function aliasFeatMap(a, feat, aliases) {
93+
if (!a.GSUB || !a.GSUB.features || !a.GSUB.lookups) return;
94+
for (const [uFrom, uTo] of aliases) {
95+
const gidFrom = a.cmap[uFrom],
96+
gidTo = a.cmap[uTo];
97+
if (!gidFrom || !gidTo) continue;
98+
99+
let affectedLookups = new Set();
100+
for (const fid in a.GSUB.features) {
101+
if (fid.slice(0, 4) === feat) {
102+
const feature = a.GSUB.features[fid];
103+
if (!feature) continue;
104+
for (const lid of feature) affectedLookups.add(lid);
105+
}
106+
}
107+
108+
for (const lid of affectedLookups) {
109+
const lookup = a.GSUB.lookups[lid];
110+
if (lookup.type !== "gsub_single") continue;
111+
for (const subtable of lookup.subtables) {
112+
subtable[gidFrom] = subtable[gidTo];
113+
}
114+
}
115+
}
116+
}

make/punct/common.js

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,33 @@ sanitizers.half = function (glyph) {
3232
glyph.advanceWidth = targetW;
3333
return glyph;
3434
};
35-
sanitizers.halfLeft = function (glyph, gid) {
35+
sanitizers.halfLeft = function (glyph, gid, isGothic) {
3636
const g1 = sanitizers.half.call(this, this.find.glyph$(this.find.gname.subst("pwid", gid)));
3737
Object.assign(glyph, g1);
3838
deleteGPOS(this.font, gid);
39+
if (isGothic) glyph.advanceWidth = this.em;
3940
return glyph;
4041
};
41-
sanitizers.halfRight = function (glyph, gid) {
42+
sanitizers.halfRight = function (glyph, gid, isGothic) {
4243
const g1 = sanitizers.half.call(this, this.find.glyph$(this.find.gname.subst("pwid", gid)));
4344
Object.assign(glyph, g1);
4445
deleteGPOS(this.font, gid);
46+
if (isGothic) {
47+
glyph.advanceWidth = this.em;
48+
for (let c of glyph.contours) for (let z of c) z.x += this.em / 2;
49+
}
4550
return glyph;
4651
};
4752

4853
function HalfCompN(n, forceFullWidth, forceHalfWidth) {
49-
return function (glyph, gid, isType = false) {
54+
return function (glyph, gid, isGothic, isType) {
5055
const g1 = this.find.glyph$(this.find.gname.subst("fwid", gid));
5156
Object.assign(glyph, g1);
5257
const targetW = Math.min(
5358
this.em * n,
5459
Math.ceil(glyph.advanceWidth / this.em) *
55-
(this.em * (forceHalfWidth ? 1 / 2 : isType || forceFullWidth ? 1 : 1 / 2))
60+
(this.em *
61+
(forceHalfWidth ? 1 / 2 : isGothic || isType || forceFullWidth ? 1 : 1 / 2))
5662
);
5763
if (glyph.contours) {
5864
for (let c of glyph.contours) for (let z of c) z.x *= targetW / glyph.advanceWidth;
@@ -83,7 +89,7 @@ const sanitizerTypes = {
8389
"\u2e3b": "halfComp3"
8490
};
8591

86-
exports.sanitizeSymbols = async function sanitizeSymbols(isType) {
92+
exports.sanitizeSymbols = async function sanitizeSymbols(isGothic, isType) {
8793
let san = new Map();
8894
for (let c in this.font.cmap) {
8995
if (!this.font.cmap[c]) continue;
@@ -94,7 +100,7 @@ exports.sanitizeSymbols = async function sanitizeSymbols(isType) {
94100
let sanitizer = sanitizers[san.has(g) ? san.get(g) : "auto"];
95101
const glyph = this.font.glyf[g];
96102
if (!glyph) continue;
97-
sanitizer.call(this, glyph, g, isType);
103+
sanitizer.call(this, glyph, g, isGothic, isType);
98104
}
99105
};
100106

@@ -168,29 +174,3 @@ exports.toPWID = async function () {
168174
font.cmap[c] = this.find.gname.subst("pwid", font.cmap[c]);
169175
}
170176
};
171-
172-
exports.aliasFeatMap = function (a, feat, aliases) {
173-
if (!a.GSUB || !a.GSUB.features || !a.GSUB.lookups) return;
174-
for (const [uFrom, uTo] of aliases) {
175-
const gidFrom = a.cmap[uFrom],
176-
gidTo = a.cmap[uTo];
177-
if (!gidFrom || !gidTo) continue;
178-
179-
let affectedLookups = new Set();
180-
for (const fid in a.GSUB.features) {
181-
if (fid.slice(0, 4) === feat) {
182-
const feature = a.GSUB.features[fid];
183-
if (!feature) continue;
184-
for (const lid of feature) affectedLookups.add(lid);
185-
}
186-
}
187-
188-
for (const lid of affectedLookups) {
189-
const lookup = a.GSUB.lookups[lid];
190-
if (lookup.type !== "gsub_single") continue;
191-
for (const subtable of lookup.subtables) {
192-
subtable[gidFrom] = subtable[gidTo];
193-
}
194-
}
195-
}
196-
};

make/punct/ws.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ module.exports = async function makeFont(ctx, config, argv) {
2626
!isWestern(c - 0) &&
2727
!isKorean(c - 0) &&
2828
!isLongDash(c - 0, argv.term) &&
29-
isWS(c - 0, argv.type, argv.term)
29+
isWS(c - 0)
3030
);
3131

3232
if (argv.pwid) {
3333
await ctx.run(manip.glyph, "a", toPWID);
3434
}
3535
if (argv.mono) {
36-
await ctx.run(manip.glyph, "a", sanitizeSymbols, argv.type);
36+
await ctx.run(manip.glyph, "a", sanitizeSymbols, argv.goth, !argv.pwid && !argv.term);
3737
}
3838
removeUnusedFeatures(ctx.items.a, "WS", argv.mono);
3939
gc(ctx.items.a);

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.15.3",
3+
"version": "0.15.4",
44
"main": "./run",
55
"dependencies": {
66
"@chlorophytum/cli": "^0.20.0",

0 commit comments

Comments
 (0)