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) {
|
||||
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],
|
||||
b = this.lastContour[this.lastContour.length - 1];
|
||||
if (isLineExtend(a, b, z)) {
|
||||
this.lastContour.pop();
|
||||
this.lastContour.push(z);
|
||||
return;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.lastContour.push(z);
|
||||
|
@ -157,14 +157,13 @@ class FairizedShapeSink {
|
|||
function isLineExtend(a, b, c) {
|
||||
return (
|
||||
a.on &&
|
||||
b.on &&
|
||||
c.on &&
|
||||
((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)))
|
||||
);
|
||||
}
|
||||
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) {
|
||||
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 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
|
||||
foreach [c : items-of overlay.contours] : foreach [z : items-of c] : if z.on : do
|
||||
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
|
||||
define dx : r / segs * sw
|
||||
define dy : c / segs * sw
|
||||
candidates.push : glyph-construction
|
||||
candidates.push : create-glyph : glyph-construction
|
||||
include overlay
|
||||
apply-transform : Translate dx dy
|
||||
|
||||
include : difference background [union.apply null candidates]
|
||||
include : difference background corners [union.apply null candidates]
|
||||
include overlay
|
||||
|
||||
define [CreateWaveShape dist sw _phaesShift] : begin
|
||||
|
|
|
@ -6006,10 +6006,11 @@ glyph-block Letter-Latin-Thorn : begin
|
|||
save 'Sho' 0x3F7
|
||||
|
||||
sketch # thorn
|
||||
include : create-glyph : glyph-construction
|
||||
include : union
|
||||
glyph-construction
|
||||
include : refer-glyph "b"
|
||||
eject-contour 'serifLB'
|
||||
include : create-glyph : glyph-construction
|
||||
glyph-construction
|
||||
include : refer-glyph "p"
|
||||
eject-contour 'bowl'
|
||||
eject-contour 'serifLT'
|
||||
|
@ -6219,6 +6220,7 @@ glyph-block Letter-Latin-RamsHorn : begin
|
|||
local k1 0.65
|
||||
local k2 0.7
|
||||
local zmidy (XH * 0.15)
|
||||
local offset : Stroke * 0.25
|
||||
include : union
|
||||
dispiro
|
||||
widths.lhs
|
||||
|
@ -6232,10 +6234,10 @@ glyph-block Letter-Latin-RamsHorn : begin
|
|||
g4 Middle zmidy
|
||||
g4.right.end RightSB 0 [heading Rightward]
|
||||
spiro-outline
|
||||
corner Middle (zmidy + 1)
|
||||
g4.up.mid ([mix Middle RightSB k1] - 1) (XH * k2)
|
||||
g4.left.mid Middle XH
|
||||
g4.down.mid ([mix Middle SB k1] + 1) (XH * k2)
|
||||
corner Middle (zmidy + offset)
|
||||
g4.up.mid ([mix Middle RightSB k1] - offset) (XH * k2)
|
||||
g4.left.mid Middle (XH - offset)
|
||||
g4.down.mid ([mix Middle SB k1] + offset) (XH * k2)
|
||||
close
|
||||
save 'latinayin' 0x1D25
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
$$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 [designParameters] from '../meta/aesthetics'
|
||||
import [Arcs Quadify] from "typo-geom"
|
||||
import [Arcs Quadify transferGenericShapeAsBezier] from "typo-geom"
|
||||
import [TieMark TieGlyph] from "../support/gr"
|
||||
|
||||
glyph-module
|
||||
|
@ -226,10 +226,12 @@ glyph-block Overmarks : begin
|
|||
define z4 : currentGlyph.gizmo.apply : object [x rightEnd] [y ttop]
|
||||
define bone : new Arcs.Bez3 z1 z2 z3 z4
|
||||
|
||||
define inner : curveToContour [new OffsetCurve bone (+hs) HVContrast] 32
|
||||
define outer : curveToContour [new OffsetCurve bone (-hs) HVContrast] 32
|
||||
define inner : new OffsetCurve bone (+hs) HVContrast
|
||||
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
|
||||
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) {
|
||||
if (!contour || !contour.length) return [];
|
||||
|
||||
|
@ -79,62 +72,6 @@ function convertContourToCubic(contour) {
|
|||
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) {
|
||||
if (!contour || !contour.length) return [];
|
||||
|
||||
|
@ -192,9 +129,6 @@ function convertShapeToArcs(shape) {
|
|||
}
|
||||
|
||||
exports.convertContourToCubic = convertContourToCubic;
|
||||
exports.convertContourToCubicRev = convertContourToCubicRev;
|
||||
exports.autoCubify = autoCubify;
|
||||
exports.fixedCubify = fixedCubify;
|
||||
exports.convertShapeToArcs = convertShapeToArcs;
|
||||
|
||||
exports.ArcFlattener = class ArcFlattener {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"topsort": "^0.0.2",
|
||||
"ttf2woff": "^2.0.1",
|
||||
"ttf2woff2": "^3.0.0",
|
||||
"typo-geom": "^0.8.0",
|
||||
"typo-geom": "^0.8.4",
|
||||
"unicode-13.0.0": "^0.8.0",
|
||||
"unorm": "^1.6.0",
|
||||
"verda": "^1.0.1",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue