made autoref more strict to fix #241.

This commit is contained in:
belleve 2017-12-23 19:49:01 +08:00
parent f0643152bf
commit 5da7f90a79
6 changed files with 59 additions and 45 deletions

4
.prettierrc.yaml Normal file
View file

@ -0,0 +1,4 @@
# .prettierrc
printWidth: 100
useTabs: true
tabWidth: 4

View file

@ -103,8 +103,12 @@ const font = (function() {
.sort(function(a, b) { .sort(function(a, b) {
var pri1 = a.cmpPriority || 0; var pri1 = a.cmpPriority || 0;
var pri2 = b.cmpPriority || 0; var pri2 = b.cmpPriority || 0;
if (pri1 > pri2) return -1;
if (pri1 < pri2) return 1;
if (a.contours && b.contours && a.contours.length < b.contours.length) return 1; if (a.contours && b.contours && a.contours.length < b.contours.length) return 1;
if (a.contours && b.contours && a.contours.length > b.contours.length) return -1; if (a.contours && b.contours && a.contours.length > b.contours.length) return -1;
if (a.advanceWidth < b.advanceWidth) return -1;
if (a.advanceWidth > b.advanceWidth) return 1;
if ((a.unicode && a.unicode[0] && !b.unicode) || !b.unicode[0]) return -1; if ((a.unicode && a.unicode[0] && !b.unicode) || !b.unicode[0]) return -1;
if ((b.unicode && b.unicode[0] && !a.unicode) || !a.unicode[0]) return +1; if ((b.unicode && b.unicode[0] && !a.unicode) || !a.unicode[0]) return +1;
if ( if (

View file

@ -268,6 +268,7 @@ export : define [apply] : begin
apply-transform : Italify apply-transform : Italify
set currentGlyph.cmpPriority 12 set currentGlyph.cmpPriority 12
refair this refair this
set-width 0
return lg return lg
define [circleDimens dscale w m] : begin define [circleDimens dscale w m] : begin
@ -389,6 +390,7 @@ export : define [apply] : begin
apply-transform : Italify apply-transform : Italify
set currentGlyph.cmpPriority 11 set currentGlyph.cmpPriority 11
refair this refair this
set-width 0
sketch sketch
local s : TANSLANT * parenMid local s : TANSLANT * parenMid

View file

@ -22,35 +22,27 @@ export : define [apply] : begin
save 'brailleBlank' 0x2800 save 'brailleBlank' 0x2800
sketch # braille1 sketch # braille1
include : DotAt (leftMiddle) (parenMid - 3 * offsetY) brailleDotsRadius include : DotAt (leftMiddle) (parenMid - 3 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille1' 0x2801 save 'braille1' 0x2801
sketch # braille2 sketch # braille2
include : DotAt (leftMiddle) (parenMid - 1 * offsetY) brailleDotsRadius include : DotAt (leftMiddle) (parenMid - 1 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille2' 0x2802 save 'braille2' 0x2802
sketch # braille3 sketch # braille3
include : DotAt (leftMiddle) (parenMid + 1 * offsetY) brailleDotsRadius include : DotAt (leftMiddle) (parenMid + 1 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille3' 0x2804 save 'braille3' 0x2804
sketch # braille4 sketch # braille4
include : DotAt (rightMiddle) (parenMid - 3 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille4' 0x2808
sketch # braille5
include : DotAt (rightMiddle) (parenMid - 1 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille5' 0x2810
sketch # braille6
include : DotAt (rightMiddle) (parenMid + 1 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille6' 0x2820
sketch # braille7
include : DotAt (leftMiddle) (parenMid + 3 * offsetY) brailleDotsRadius include : DotAt (leftMiddle) (parenMid + 3 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101) save 'braille4' 0x2840
save 'braille7' 0x2840 sketch # braille5
include : DotAt (rightMiddle) (parenMid - 3 * offsetY) brailleDotsRadius
save 'braille5' 0x2808
sketch # braille6
include : DotAt (rightMiddle) (parenMid - 1 * offsetY) brailleDotsRadius
save 'braille6' 0x2810
sketch # braille7
include : DotAt (rightMiddle) (parenMid + 1 * offsetY) brailleDotsRadius
save 'braille7' 0x2820
sketch # braille8 sketch # braille8
include : DotAt (rightMiddle) (parenMid + 3 * offsetY) brailleDotsRadius include : DotAt (rightMiddle) (parenMid + 3 * offsetY) brailleDotsRadius
set currentGlyph.cmpPriority (-101)
save 'braille8' 0x2880 save 'braille8' 0x2880
### Template ### Template
@ -63,11 +55,18 @@ export : define [apply] : begin
### Inheriting characters ### Inheriting characters
build-braille-patterns braillePatterns build-braille-patterns braillePatterns
set glyphs.braille1237.cmpPriority 104 set glyphs.braille4.cmpPriority 101
set glyphs.braille34.cmpPriority 102
set glyphs.braille3.cmpPriority 101
set glyphs.braille234.cmpPriority 103
set glyphs.braille24.cmpPriority 102
set glyphs.braille23.cmpPriority 102
set glyphs.braille2.cmpPriority 101
set glyphs.braille1234.cmpPriority 104
set glyphs.braille123.cmpPriority 103 set glyphs.braille123.cmpPriority 103
set glyphs.braille127.cmpPriority 103 set glyphs.braille124.cmpPriority 103
set glyphs.braille137.cmpPriority 103 set glyphs.braille134.cmpPriority 103
set glyphs.braille13.cmpPriority 102 set glyphs.braille13.cmpPriority 102
set glyphs.braille12.cmpPriority 102 set glyphs.braille12.cmpPriority 102
set glyphs.braille17.cmpPriority 102 set glyphs.braille14.cmpPriority 102
set glyphs.braille1.cmpPriority 103 set glyphs.braille1.cmpPriority 101

View file

@ -2,13 +2,15 @@
"name": "iosevka", "name": "iosevka",
"version": "1.13.3", "version": "1.13.3",
"main": "./generate.js", "main": "./generate.js",
"engines": { "node" : ">=8.4.0" }, "engines": {
"node": ">=8.4.0"
},
"dependencies": { "dependencies": {
"bezier-js": "^2.2.3", "bezier-js": "^2.2.3",
"caryll-shapeops": "^0.2.1", "caryll-shapeops": "^0.3.1",
"libspiro-js": "^0.3.1", "libspiro-js": "^0.3.1",
"object-assign": "^4.1.1",
"megaminx": "^0.3.3", "megaminx": "^0.3.3",
"object-assign": "^4.1.1",
"pad": "^1.1.0", "pad": "^1.1.0",
"patel": "^0.32.1", "patel": "^0.32.1",
"toml": "^2.3.2", "toml": "^2.3.2",

View file

@ -36,12 +36,17 @@ function match(g1, g2, _n) {
} }
} }
if (found) { if (found) {
const refX = g2.contours[j][0].x - g1.contours[0][0].x || 0;
const refY = g2.contours[j][0].y - g1.contours[0][0].y || 0;
if (Math.abs(refY) > 1 && g1.advanceWidth > 1) {
continue;
}
if (!g2.references) g2.references = []; if (!g2.references) g2.references = [];
g2.references.push({ g2.references.push({
glyph: g1.name, glyph: g1.name,
_n: _n, _n: _n,
x: g2.contours[j][0].x - g1.contours[0][0].x, x: refX,
y: g2.contours[j][0].y - g1.contours[0][0].y, y: refY,
roundToGrid: true // RTG roundToGrid: true // RTG
}); });
g2.contours.splice(j, g1.contours.length); g2.contours.splice(j, g1.contours.length);
@ -78,26 +83,24 @@ function autoref(glyf) {
if (!glyf[j].contours.length || (glyf[j].references && glyf[j].references.length)) continue; if (!glyf[j].contours.length || (glyf[j].references && glyf[j].references.length)) continue;
for (var k = j + 1; k < glyf.length; k++) { for (var k = j + 1; k < glyf.length; k++) {
if (glyf[j].contours.length === glyf[k].contours.length) { if (glyf[j].contours.length === glyf[k].contours.length) {
if (match(glyf[j], glyf[k], j)) { match(glyf[j], glyf[k], j);
// console.log("Refl", glyf[j].name, glyf[j].unicode, "->", glyf[k].name, glyf[k].unicode);
}
} }
} }
} }
// referencify, backward // referencify, backward
for (var j = 0; j < glyf.length; j++) { for (var j = 0; j < glyf.length; j++) {
if (glyf[j].cmpPriority < 0) continue;
if (!glyf[j].contours.length) continue;
if (glyf[j].references && glyf[j].references.length) continue;
for (var k = glyf.length - 1; k >= 0; k--) {
if ( if (
glyf[j].cmpPriority < 0 || glyf[j].contours.length > glyf[k].contours.length ||
!glyf[j].contours.length || (glyf[j].contours.length === glyf[k].contours.length &&
(glyf[j].references && glyf[j].references.length) !(glyf[k].references && glyf[k].references.length))
) )
continue; continue;
for (var k = j - 1; k >= 0; k--) { while (match(glyf[j], glyf[k], j)) "pass";
if (glyf[j].contours.length > glyf[k].contours.length) continue;
while (match(glyf[j], glyf[k], j)) {
// console.log("Part", glyf[j].name, "->", glyf[k].name);
}
} }
} }