Further improve colinar handling

This commit is contained in:
be5invis 2021-05-31 01:40:17 -07:00
parent 229d624ebf
commit 9d8fe1c3ed
3 changed files with 27 additions and 24 deletions

View file

@ -4,7 +4,7 @@ const fs = require("fs-extra");
const zlib = require("zlib"); const zlib = require("zlib");
const { encode, decode } = require("@msgpack/msgpack"); const { encode, decode } = require("@msgpack/msgpack");
const Edition = 5; const Edition = 6;
const MAX_AGE = 5; const MAX_AGE = 5;
class GfEntry { class GfEntry {

View file

@ -199,29 +199,32 @@ class FairizedShapeSink {
return c; return c;
} }
removeColinearKnots(c0) { removeColinearKnots(c0) {
const c = c0.slice(0), const c = c0.slice(0);
shouldRemove = []; let lengthBefore = c.length,
for (let i = 0; i < c.length; i++) { lengthAfter = c.length;
const zPrev = c[(i - 1 + c.length) % c.length], do {
zCurr = c[i], lengthBefore = c.length;
zNext = c[(i + 1) % c.length]; const shouldRemove = [];
if ( for (let i = 0; i < c.length; i++) {
zPrev.type === Point.Type.Corner && const zPrev = c[(i - 1 + c.length) % c.length],
zCurr.type === Point.Type.Corner && zCurr = c[i],
zNext.type === Point.Type.Corner zNext = c[(i + 1) % c.length];
) { if (zPrev.type === Point.Type.Corner && zNext.type === Point.Type.Corner) {
if (aligned(zPrev.x, zCurr.x, zNext.x) && between(zPrev.y, zCurr.y, zNext.y)) if (aligned(zPrev.x, zCurr.x, zNext.x) && between(zPrev.y, zCurr.y, zNext.y))
shouldRemove[i] = true; shouldRemove[i] = true;
if (aligned(zPrev.y, zCurr.y, zNext.y) && between(zPrev.x, zCurr.x, zNext.x)) if (aligned(zPrev.y, zCurr.y, zNext.y) && between(zPrev.x, zCurr.x, zNext.x))
shouldRemove[i] = true; shouldRemove[i] = true;
}
} }
} let n = 0;
for (let i = 0; i < c.length; i++) {
if (!shouldRemove[i]) c[n++] = c[i];
}
c.length = n;
lengthAfter = c.length;
} while (lengthAfter < lengthBefore);
const c2 = []; return c;
for (let i = 0; i < c.length; i++) {
if (!shouldRemove[i]) c2.push(c[i]);
}
return c2;
} }
} }
function isOccurrent(zFirst, zLast) { function isOccurrent(zFirst, zLast) {

View file

@ -19,8 +19,8 @@ glyph-block Letter-Cyrillic-De : begin
include : HBarBottom (cutleft - descenderOverflow) (cutright + descenderOverflow) 0 include : HBarBottom (cutleft - descenderOverflow) (cutright + descenderOverflow) 0
include : VBarRight cutright 0 top include : VBarRight cutright 0 top
include : HalfXStrand false false (topleft + Stroke * HVContrast) top (cutleft + HalfStroke * HVContrast * 0.8) HalfStroke 0.1 0.75 0.5 include : HalfXStrand false false (topleft + Stroke * HVContrast) top (cutleft + HalfStroke * HVContrast * 0.8) HalfStroke 0.1 0.75 0.5
include : VBarLeft (cutleft - descenderOverflow) (-LongJut + HalfStroke) 0 include : VBarLeft (cutleft - descenderOverflow) (-LongJut + HalfStroke) 0.1
include : VBarRight (cutright + descenderOverflow) (-LongJut + HalfStroke) 0 include : VBarRight (cutright + descenderOverflow) (-LongJut + HalfStroke) 0.1
if SLAB : then if SLAB : then
include : dispiro include : dispiro