From 6a307b5973c1a3e7f5b90bc0465ea1402bc4b639 Mon Sep 17 00:00:00 2001 From: be5invis Date: Sat, 25 Feb 2023 05:20:24 -0800 Subject: [PATCH] Cleanup --- changes/{19.0.2md => 19.0.2.md} | 0 font-src/gen/finalize/glyphs.mjs | 46 ++++++++++++------------ font-src/glyphs/letter/latin-ext/ezh.ptl | 5 ++- 3 files changed, 25 insertions(+), 26 deletions(-) rename changes/{19.0.2md => 19.0.2.md} (100%) diff --git a/changes/19.0.2md b/changes/19.0.2.md similarity index 100% rename from changes/19.0.2md rename to changes/19.0.2.md diff --git a/font-src/gen/finalize/glyphs.mjs b/font-src/gen/finalize/glyphs.mjs index 9cb90fb2d..5d2618647 100644 --- a/font-src/gen/finalize/glyphs.mjs +++ b/font-src/gen/finalize/glyphs.mjs @@ -145,7 +145,6 @@ class QuadifySink { let c = this.lastContour; c = this.alignHVKnots(c); c = this.cleanupOccurrentKnots1(c); - c = this.cleanupOccurrentKnots2(c); c = this.removeColinearKnots(c); this.contours.push(c); } @@ -189,28 +188,27 @@ class QuadifySink { alignY.apply(); return c; } + + // Occurrent cleanup -- corner-corner cleanupOccurrentKnots1(c0) { - const c = [c0[0]]; - for (let i = 1; i < c0.length; i++) { + let drops = []; + for (let i = 0; i < c0.length; i++) drops[i] = false; + for (let i = 0; i < c0.length; i++) { + const iPost = (i + 1) % c0.length; + const pre = c0[i], + post = c0[iPost]; if ( - !( - c0[i].type === Point.Type.Corner && - c0[i - 1].type === Point.Type.Corner && - isOccurrent(c0[i], c0[i - 1]) - ) + pre.type === Point.Type.Corner && + post.type === Point.Type.Corner && + isOccurrent(pre, post) ) { - c.push(c0[i]); + drops[iPost] = true; } } - return c; - } - cleanupOccurrentKnots2(c0) { - const c = c0.slice(0); - const zFirst = c[0], - zLast = c[c.length - 1]; - if (isOccurrent(zFirst, zLast)) c.pop(); - return c; + + return dropBy(c0, drops); } + removeColinearKnots(c0) { const c = c0.slice(0); let lengthBefore = c.length, @@ -288,12 +286,7 @@ const GetY = z => z.y; const SetY = (z, y) => (z.y = y); function isOccurrent(zFirst, zLast) { - return ( - zFirst.type === Point.Type.Corner && - zLast.type === Point.Type.Corner && - zFirst.x === zLast.x && - zFirst.y === zLast.y - ); + return zFirst.x === zLast.x && zFirst.y === zLast.y; } function occurrentPrecisionEqual(a, b) { return Math.abs(a - b) < CurveUtil.OCCURRENT_PRECISION; @@ -304,3 +297,10 @@ function aligned(a, b, c) { function between(a, b, c) { return (a <= b && b <= c) || (a >= b && b >= c); } + +// Dropping helper +function dropBy(a, d) { + let r = []; + for (let i = 0; i < a.length; i++) if (!d[i]) r.push(a[i]); + return r; +} diff --git a/font-src/glyphs/letter/latin-ext/ezh.ptl b/font-src/glyphs/letter/latin-ext/ezh.ptl index 1712e7097..1d1ef9f28 100644 --- a/font-src/glyphs/letter/latin-ext/ezh.ptl +++ b/font-src/glyphs/letter/latin-ext/ezh.ptl @@ -131,8 +131,7 @@ glyph-block Letter-Latin-Ezh : begin local y : mix [mix b XH 0.6] b 0.5 include : dispiro widths.rhs - g4 (RightSB - OX) y [heading Downward] - g4 (RightSB - OX) (y - 1) [heading Downward] + g4.down.mid (RightSB - OX) y [heading Downward] arcvh flat [mix SB RightSB 0.45] b curl [mix SB RightSB 0.4] b @@ -153,7 +152,7 @@ glyph-block Letter-Latin-Ezh : begin local y2 Descender include : dispiro widths.lhs - g4.down.start m1 [mix [mix Descender XH 0.6] Descender p] [heading Downward] + g4.down.mid m1 [mix [mix Descender XH 0.6] Descender p] [heading Downward] CurlyTail fine rinner m1 Descender SB x2 y2 define [RetroflexConnectionTerminal top bot yMidBar] : begin