Further outline cleanup and dep udpate
This commit is contained in:
parent
31d8857f39
commit
ba12643c37
6 changed files with 28 additions and 91 deletions
|
@ -134,13 +134,13 @@ class FairizedShapeSink {
|
||||||
}
|
}
|
||||||
lineTo(x, y) {
|
lineTo(x, y) {
|
||||||
const z = Point.cornerFromXY(x, y).round(FINAL_SIMPLIFY_RESOLUTION);
|
const z = Point.cornerFromXY(x, y).round(FINAL_SIMPLIFY_RESOLUTION);
|
||||||
if (this.lastContour.length >= 2) {
|
while (this.lastContour.length >= 2) {
|
||||||
const a = this.lastContour[this.lastContour.length - 2],
|
const a = this.lastContour[this.lastContour.length - 2],
|
||||||
b = this.lastContour[this.lastContour.length - 1];
|
b = this.lastContour[this.lastContour.length - 1];
|
||||||
if (isLineExtend(a, b, z)) {
|
if (isLineExtend(a, b, z)) {
|
||||||
this.lastContour.pop();
|
this.lastContour.pop();
|
||||||
this.lastContour.push(z);
|
} else {
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.lastContour.push(z);
|
this.lastContour.push(z);
|
||||||
|
@ -157,14 +157,13 @@ class FairizedShapeSink {
|
||||||
function isLineExtend(a, b, c) {
|
function isLineExtend(a, b, c) {
|
||||||
return (
|
return (
|
||||||
a.on &&
|
a.on &&
|
||||||
b.on &&
|
|
||||||
c.on &&
|
c.on &&
|
||||||
((aligned(a.x, b.x, c.x) && between(a.y, b.y, c.y)) ||
|
((aligned(a.x, b.x, c.x) && between(a.y, b.y, c.y)) ||
|
||||||
(aligned(a.y, b.y, c.y) && between(a.x, b.x, c.x)))
|
(aligned(a.y, b.y, c.y) && between(a.x, b.x, c.x)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function aligned(a, b, c) {
|
function aligned(a, b, c) {
|
||||||
return a === b && b === c;
|
return Math.round(a) === Math.round(b) && Math.round(b) === Math.round(c);
|
||||||
}
|
}
|
||||||
function between(a, b, c) {
|
function between(a, b, c) {
|
||||||
return (a <= b && b <= c) || (a >= b && b >= c);
|
return (a <= b && b <= c) || (a >= b && b >= c);
|
||||||
|
|
|
@ -729,7 +729,7 @@ glyph-block CommonShapes : begin
|
||||||
define overlay : create-glyph : glyph-construction : include fnOverlay AS_BASE ALSO_METRICS
|
define overlay : create-glyph : glyph-construction : include fnOverlay AS_BASE ALSO_METRICS
|
||||||
define background : create-glyph : glyph-construction : include fnBackground AS_BASE ALSO_METRICS
|
define background : create-glyph : glyph-construction : include fnBackground AS_BASE ALSO_METRICS
|
||||||
|
|
||||||
candidates.push : glyph-construction
|
local corners : create-glyph : glyph-construction
|
||||||
set this.gizmo : Translate 0 0
|
set this.gizmo : Translate 0 0
|
||||||
foreach [c : items-of overlay.contours] : foreach [z : items-of c] : if z.on : do
|
foreach [c : items-of overlay.contours] : foreach [z : items-of c] : if z.on : do
|
||||||
define x z.x
|
define x z.x
|
||||||
|
@ -743,11 +743,11 @@ glyph-block CommonShapes : begin
|
||||||
foreach [r : range (0 - segs) till (segs)] : foreach [c : range (0 - segs) till (segs)] : do
|
foreach [r : range (0 - segs) till (segs)] : foreach [c : range (0 - segs) till (segs)] : do
|
||||||
define dx : r / segs * sw
|
define dx : r / segs * sw
|
||||||
define dy : c / segs * sw
|
define dy : c / segs * sw
|
||||||
candidates.push : glyph-construction
|
candidates.push : create-glyph : glyph-construction
|
||||||
include overlay
|
include overlay
|
||||||
apply-transform : Translate dx dy
|
apply-transform : Translate dx dy
|
||||||
|
|
||||||
include : difference background [union.apply null candidates]
|
include : difference background corners [union.apply null candidates]
|
||||||
include overlay
|
include overlay
|
||||||
|
|
||||||
define [CreateWaveShape dist sw _phaesShift] : begin
|
define [CreateWaveShape dist sw _phaesShift] : begin
|
||||||
|
|
|
@ -6006,10 +6006,11 @@ glyph-block Letter-Latin-Thorn : begin
|
||||||
save 'Sho' 0x3F7
|
save 'Sho' 0x3F7
|
||||||
|
|
||||||
sketch # thorn
|
sketch # thorn
|
||||||
include : create-glyph : glyph-construction
|
include : union
|
||||||
|
glyph-construction
|
||||||
include : refer-glyph "b"
|
include : refer-glyph "b"
|
||||||
eject-contour 'serifLB'
|
eject-contour 'serifLB'
|
||||||
include : create-glyph : glyph-construction
|
glyph-construction
|
||||||
include : refer-glyph "p"
|
include : refer-glyph "p"
|
||||||
eject-contour 'bowl'
|
eject-contour 'bowl'
|
||||||
eject-contour 'serifLT'
|
eject-contour 'serifLT'
|
||||||
|
@ -6219,6 +6220,7 @@ glyph-block Letter-Latin-RamsHorn : begin
|
||||||
local k1 0.65
|
local k1 0.65
|
||||||
local k2 0.7
|
local k2 0.7
|
||||||
local zmidy (XH * 0.15)
|
local zmidy (XH * 0.15)
|
||||||
|
local offset : Stroke * 0.25
|
||||||
include : union
|
include : union
|
||||||
dispiro
|
dispiro
|
||||||
widths.lhs
|
widths.lhs
|
||||||
|
@ -6232,10 +6234,10 @@ glyph-block Letter-Latin-RamsHorn : begin
|
||||||
g4 Middle zmidy
|
g4 Middle zmidy
|
||||||
g4.right.end RightSB 0 [heading Rightward]
|
g4.right.end RightSB 0 [heading Rightward]
|
||||||
spiro-outline
|
spiro-outline
|
||||||
corner Middle (zmidy + 1)
|
corner Middle (zmidy + offset)
|
||||||
g4.up.mid ([mix Middle RightSB k1] - 1) (XH * k2)
|
g4.up.mid ([mix Middle RightSB k1] - offset) (XH * k2)
|
||||||
g4.left.mid Middle XH
|
g4.left.mid Middle (XH - offset)
|
||||||
g4.down.mid ([mix Middle SB k1] + 1) (XH * k2)
|
g4.down.mid ([mix Middle SB k1] + offset) (XH * k2)
|
||||||
close
|
close
|
||||||
save 'latinayin' 0x1D25
|
save 'latinayin' 0x1D25
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
$$include '../meta/macros.ptl'
|
$$include '../meta/macros.ptl'
|
||||||
|
|
||||||
import [curveToContour OffsetCurve] from '../support/curve-util'
|
import [OffsetCurve ArcFlattener] from '../support/curve-util'
|
||||||
import [mix linreg clamp fallback] from '../support/utils'
|
import [mix linreg clamp fallback] from '../support/utils'
|
||||||
import [designParameters] from '../meta/aesthetics'
|
import [designParameters] from '../meta/aesthetics'
|
||||||
import [Arcs Quadify] from "typo-geom"
|
import [Arcs Quadify transferGenericShapeAsBezier] from "typo-geom"
|
||||||
import [TieMark TieGlyph] from "../support/gr"
|
import [TieMark TieGlyph] from "../support/gr"
|
||||||
|
|
||||||
glyph-module
|
glyph-module
|
||||||
|
@ -226,10 +226,12 @@ glyph-block Overmarks : begin
|
||||||
define z4 : currentGlyph.gizmo.apply : object [x rightEnd] [y ttop]
|
define z4 : currentGlyph.gizmo.apply : object [x rightEnd] [y ttop]
|
||||||
define bone : new Arcs.Bez3 z1 z2 z3 z4
|
define bone : new Arcs.Bez3 z1 z2 z3 z4
|
||||||
|
|
||||||
define inner : curveToContour [new OffsetCurve bone (+hs) HVContrast] 32
|
define inner : new OffsetCurve bone (+hs) HVContrast
|
||||||
define outer : curveToContour [new OffsetCurve bone (-hs) HVContrast] 32
|
define outer : new Arcs.Reverted : new OffsetCurve bone (-hs) HVContrast
|
||||||
|
|
||||||
currentGlyph.contours.push : inner.concat [outer.reverse]
|
define cs : new ArcFlattener
|
||||||
|
transferGenericShapeAsBezier {{inner outer}} cs (1 / 4)
|
||||||
|
include cs
|
||||||
|
|
||||||
sketch # tildeAbove
|
sketch # tildeAbove
|
||||||
set-width 0
|
set-width 0
|
||||||
|
|
|
@ -31,13 +31,6 @@ exports.OffsetCurve = class OffsetCurve {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.curveToContour = function (curve, segments) {
|
|
||||||
const z0 = curve.eval(0);
|
|
||||||
const z1 = curve.eval(1);
|
|
||||||
const offPoints = fixedCubify(curve, segments || 16);
|
|
||||||
return [Point.cornerFrom(z0), ...offPoints, Point.cornerFrom(z1)];
|
|
||||||
};
|
|
||||||
|
|
||||||
function convertContourToCubic(contour) {
|
function convertContourToCubic(contour) {
|
||||||
if (!contour || !contour.length) return [];
|
if (!contour || !contour.length) return [];
|
||||||
|
|
||||||
|
@ -79,62 +72,6 @@ function convertContourToCubic(contour) {
|
||||||
return newContour;
|
return newContour;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertContourToCubicRev(contour) {
|
|
||||||
return convertContourToCubic(contour).reverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
function autoCubify(arc, err) {
|
|
||||||
const MaxSegments = 16;
|
|
||||||
const Hits = 64;
|
|
||||||
let offPoints = [];
|
|
||||||
for (let nSeg = 1; nSeg <= MaxSegments; nSeg++) {
|
|
||||||
const perSegHits = Math.ceil(Hits / nSeg);
|
|
||||||
offPoints.length = 0;
|
|
||||||
let good = true;
|
|
||||||
out: for (let s = 0; s < nSeg; s++) {
|
|
||||||
const tBefore = s / nSeg;
|
|
||||||
const tAfter = (s + 1) / nSeg;
|
|
||||||
const z0 = Point.cornerFrom(arc.eval(tBefore));
|
|
||||||
const z3 = Point.cornerFrom(arc.eval(tAfter));
|
|
||||||
const z1 = Point.cubicOffFrom(z0).addScale(1 / (3 * nSeg), arc.derivative(tBefore));
|
|
||||||
const z2 = Point.cubicOffFrom(z3).addScale(-1 / (3 * nSeg), arc.derivative(tAfter));
|
|
||||||
|
|
||||||
if (s > 0) offPoints.push(z0);
|
|
||||||
offPoints.push(z1, z2);
|
|
||||||
|
|
||||||
const bezArc = new TypoGeom.Arcs.Bez3(z0, z1, z2, z3);
|
|
||||||
|
|
||||||
for (let k = 1; k < perSegHits; k++) {
|
|
||||||
const tk = k / perSegHits;
|
|
||||||
const zTest = arc.eval(mix(tBefore, tAfter, tk));
|
|
||||||
const zBez = bezArc.eval(tk);
|
|
||||||
if (Math.hypot(zTest.x - zBez.x, zTest.y - zBez.y) > err) {
|
|
||||||
good = false;
|
|
||||||
break out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (good) break;
|
|
||||||
}
|
|
||||||
return offPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixedCubify(arc, nSeg) {
|
|
||||||
let offPoints = [];
|
|
||||||
for (let s = 0; s < nSeg; s++) {
|
|
||||||
const tBefore = s / nSeg;
|
|
||||||
const tAfter = (s + 1) / nSeg;
|
|
||||||
const z0 = Point.cornerFrom(arc.eval(tBefore));
|
|
||||||
const z3 = Point.cornerFrom(arc.eval(tAfter));
|
|
||||||
const z1 = Point.cubicOffFrom(z0).addScale(1 / (3 * nSeg), arc.derivative(tBefore));
|
|
||||||
const z2 = Point.cubicOffFrom(z3).addScale(-1 / (3 * nSeg), arc.derivative(tAfter));
|
|
||||||
|
|
||||||
if (s > 0) offPoints.push(z0);
|
|
||||||
offPoints.push(z1, z2);
|
|
||||||
}
|
|
||||||
return offPoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertContourToArcs(contour) {
|
function convertContourToArcs(contour) {
|
||||||
if (!contour || !contour.length) return [];
|
if (!contour || !contour.length) return [];
|
||||||
|
|
||||||
|
@ -192,9 +129,6 @@ function convertShapeToArcs(shape) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.convertContourToCubic = convertContourToCubic;
|
exports.convertContourToCubic = convertContourToCubic;
|
||||||
exports.convertContourToCubicRev = convertContourToCubicRev;
|
|
||||||
exports.autoCubify = autoCubify;
|
|
||||||
exports.fixedCubify = fixedCubify;
|
|
||||||
exports.convertShapeToArcs = convertShapeToArcs;
|
exports.convertShapeToArcs = convertShapeToArcs;
|
||||||
|
|
||||||
exports.ArcFlattener = class ArcFlattener {
|
exports.ArcFlattener = class ArcFlattener {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"topsort": "^0.0.2",
|
"topsort": "^0.0.2",
|
||||||
"ttf2woff": "^2.0.1",
|
"ttf2woff": "^2.0.1",
|
||||||
"ttf2woff2": "^3.0.0",
|
"ttf2woff2": "^3.0.0",
|
||||||
"typo-geom": "^0.8.0",
|
"typo-geom": "^0.8.4",
|
||||||
"unicode-13.0.0": "^0.8.0",
|
"unicode-13.0.0": "^0.8.0",
|
||||||
"unorm": "^1.6.0",
|
"unorm": "^1.6.0",
|
||||||
"verda": "^1.0.1",
|
"verda": "^1.0.1",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue