More cleanup

This commit is contained in:
be5invis 2022-07-17 00:54:59 -07:00
parent e61edd0db9
commit 4a418cd473
58 changed files with 198 additions and 195 deletions

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [Point] from"../../../support/geometry/point.mjs" import [Point] from"../../../support/geometry/point.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [Point] from"../../../support/geometry/point.mjs" import [Point] from"../../../support/geometry/point.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [RightDependentLink RightDependentTrigger CvDecompose] from"../../../support/gr.mjs" import [RightDependentLink RightDependentTrigger CvDecompose] from"../../../support/gr.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix barMixL linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module
@ -13,7 +13,7 @@ glyph-block Letter-Cyrillic-Yu : begin
define SLAB-BULGARIAN 3 define SLAB-BULGARIAN 3
define [CyrYuShape df slabType top xtop ada adb] : glyph-proc define [CyrYuShape df slabType top xtop ada adb] : glyph-proc
local xm : barmixL df.leftSB df.rightSB (df.mvs * HVContrast) [StrokeWidthBlend 0.4 0.45] local xm : barMixL df.leftSB df.rightSB (df.mvs * HVContrast) [StrokeWidthBlend 0.4 0.45]
include : VBarLeft df.leftSB 0 xtop df.mvs include : VBarLeft df.leftSB 0 xtop df.mvs
include : OShape top 0 xm df.rightSB df.mvs (ada * 0.7 * df.div) (adb * 0.7 * df.div) include : OShape top 0 xm df.rightSB df.mvs (ada * 0.7 * df.div) (adb * 0.7 * df.div)
include : HBar (df.leftSB + 1) xm (top / 2) include : HBar (df.leftSB + 1) xm (top / 2)
@ -45,4 +45,4 @@ glyph-block Letter-Cyrillic-Yu : begin
local df : DivFrame para.diversityM 3 local df : DivFrame para.diversityM 3
set-width df.width set-width df.width
include : df.markSet.b include : df.markSet.b
include : CyrYuShape df SLAB-BULGARIAN XH CAP SmallArchDepthA SmallArchDepthB include : CyrYuShape df SLAB-BULGARIAN XH CAP SmallArchDepthA SmallArchDepthB

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [MathSansSerif] from"../../../support/gr.mjs" import [MathSansSerif] from"../../../support/gr.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -1,6 +1,6 @@
$$include '../../../meta/macros.ptl' $$include '../../../meta/macros.ptl'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs" import [mix linreg clamp fallback] from"../../../support/utils.mjs"
import [DesignParameters] from"../../../meta/aesthetics.mjs" import [DesignParameters] from"../../../meta/aesthetics.mjs"
glyph-module glyph-module

View file

@ -66,10 +66,12 @@ function convertContourToArcs(contour) {
} }
return newContour; return newContour;
} }
export const SPIRO_PRECISION = 1 / 2; export const SPIRO_PRECISION = 1 / 2;
export const OCCURRENT_PRECISION = 1 / 16; export const OCCURRENT_PRECISION = 1 / 16;
export const GEOMETRY_PRECISION = 1 / 4; export const GEOMETRY_PRECISION = 1 / 4;
export const BOOLE_RESOLUTION = 0x4000; export const BOOLE_RESOLUTION = 0x4000;
export class OffsetCurve { export class OffsetCurve {
constructor(bone, offset, contrast) { constructor(bone, offset, contrast) {
this.bone = bone; this.bone = bone;
@ -95,6 +97,7 @@ export class OffsetCurve {
}; };
} }
} }
export class ReverseCurve { export class ReverseCurve {
constructor(original) { constructor(original) {
this.m_original = original; this.m_original = original;
@ -106,6 +109,7 @@ export class ReverseCurve {
return -this.m_original.derivative(1 - t); return -this.m_original.derivative(1 - t);
} }
} }
export function convertShapeToArcs(shape) { export function convertShapeToArcs(shape) {
return shape.map(convertContourToArcs); return shape.map(convertContourToArcs);
} }
@ -115,6 +119,7 @@ export function shapeToRep(shape) {
export function repToShape(shapeRep) { export function repToShape(shapeRep) {
return shapeRep.map(repToContour); return shapeRep.map(repToContour);
} }
export class BezToContoursSink { export class BezToContoursSink {
constructor(gizmo) { constructor(gizmo) {
this.gizmo = gizmo || Transform.Id(); this.gizmo = gizmo || Transform.Id();

View file

@ -1,4 +1,4 @@
class Point { export class Point {
constructor(type, x, y) { constructor(type, x, y) {
this.type = type; this.type = type;
this.x = x; this.x = x;
@ -64,4 +64,3 @@ Point.Type = {
CubicEnd: 2, CubicEnd: 2,
Quadratic: 3 Quadratic: 3
}; };
export { Point };

View file

@ -38,7 +38,8 @@ class BiKnot {
); );
} }
} }
class BiKnotCollector {
export class BiKnotCollector {
constructor(gizmo, contrast) { constructor(gizmo, contrast) {
this.gizmo = gizmo; this.gizmo = gizmo;
this.contrast = contrast; this.contrast = contrast;
@ -76,7 +77,8 @@ class BiKnotCollector {
if (k0) k0.unimportant = 1; if (k0) k0.unimportant = 1;
} }
} }
class SpiroExpander {
export class SpiroExpander {
constructor(gizmo, contrast, closed, cks) { constructor(gizmo, contrast, closed, cks) {
this.gizmo = gizmo; this.gizmo = gizmo;
this.contrast = contrast; this.contrast = contrast;
@ -204,20 +206,21 @@ class NormalRectifier {
this.nKnotsProcessed += 1; this.nKnotsProcessed += 1;
} }
} }
function isTangentValid(d) { function isTangentValid(d) {
return isFinite(d.x) && isFinite(d.y); return isFinite(d.x) && isFinite(d.y);
} }
function normalX(tangent, contrast) { function normalX(tangent, contrast) {
return contrast * (-tangent.y / Math.hypot(tangent.x, tangent.y)); return contrast * (-tangent.y / Math.hypot(tangent.x, tangent.y));
} }
function normalY(tangent) { function normalY(tangent) {
return tangent.x / Math.hypot(tangent.x, tangent.y); return tangent.x / Math.hypot(tangent.x, tangent.y);
} }
function reverseKnotType(ty) { function reverseKnotType(ty) {
return ty === "left" ? "right" : ty === "right" ? "left" : ty; return ty === "left" ? "right" : ty === "right" ? "left" : ty;
} }
function cyNth(a, j) { function cyNth(a, j) {
return a[j % a.length]; return a[j % a.length];
} }
export { BiKnotCollector };
export { SpiroExpander };

View file

@ -1,6 +1,6 @@
import crypto from "crypto"; import crypto from "crypto";
const Dotless = { export const Dotless = {
tag: "dtls", tag: "dtls",
get(glyph) { get(glyph) {
if (glyph && glyph.related) return glyph.related.dotless; if (glyph && glyph.related) return glyph.related.dotless;
@ -15,6 +15,10 @@ const Dotless = {
return name + ".dotless"; return name + ".dotless";
} }
}; };
export const LowerYDotAtBelow = SimpleProp("LowerYDotAtBelow");
export const RightDependentTrigger = SimpleProp("RightDependentTrigger");
export const MathSansSerif = SimpleProp("MathSansSerif");
function SimpleProp(key) { function SimpleProp(key) {
return { return {
get(glyph) { get(glyph) {
@ -28,9 +32,8 @@ function SimpleProp(key) {
} }
}; };
} }
const LowerYDotAtBelow = SimpleProp("LowerYDotAtBelow");
const RightDependentTrigger = SimpleProp("RightDependentTrigger"); export const RightDependentLink = DependentLinkProp("RightDependentLink");
const MathSansSerif = SimpleProp("MathSansSerif");
function DependentLinkProp(key) { function DependentLinkProp(key) {
return { return {
get(glyph, subKey) { get(glyph, subKey) {
@ -52,17 +55,21 @@ function DependentLinkProp(key) {
} }
}; };
} }
const RightDependentLink = DependentLinkProp("RightDependentLink");
export const Nwid = OtlTaggedProp("Nwid", "NWID");
export const Wwid = OtlTaggedProp("Wwid", "WWID");
export const Lnum = OtlTaggedProp("Lnum", "lnum");
export const Onum = OtlTaggedProp("Onum", "onum");
export const AplForm = OtlTaggedProp("AplForm", "APLF");
export const NumeratorForm = OtlTaggedProp("Numerator", "numr");
export const DenominatorForm = OtlTaggedProp("Denominator", "dnom");
function OtlTaggedProp(key, otlTag) { function OtlTaggedProp(key, otlTag) {
return { ...SimpleProp(key), otlTag }; return { ...SimpleProp(key), otlTag };
} }
const Nwid = OtlTaggedProp("Nwid", "NWID");
const Wwid = OtlTaggedProp("Wwid", "WWID"); export const CvDecompose = DecompositionProp("CvDecompose");
const Lnum = OtlTaggedProp("Lnum", "lnum"); export const PseudoCvDecompose = DecompositionProp("PseudoCvDecompose");
const Onum = OtlTaggedProp("Onum", "onum"); export const CcmpDecompose = DecompositionProp("CcmpDecompose");
const AplForm = OtlTaggedProp("AplForm", "APLF");
const NumeratorForm = OtlTaggedProp("Numerator", "numr");
const DenominatorForm = OtlTaggedProp("Denominator", "dnom");
function DecompositionProp(key) { function DecompositionProp(key) {
return { return {
get(glyph) { get(glyph) {
@ -76,10 +83,8 @@ function DecompositionProp(key) {
} }
}; };
} }
const CvDecompose = DecompositionProp("CvDecompose");
const PseudoCvDecompose = DecompositionProp("PseudoCvDecompose"); export const TieMark = {
const CcmpDecompose = DecompositionProp("CcmpDecompose");
const TieMark = {
tag: "TMRK", tag: "TMRK",
get(glyph) { get(glyph) {
if (glyph && glyph.related) return glyph.related.TieMark; if (glyph && glyph.related) return glyph.related.TieMark;
@ -97,7 +102,8 @@ const TieMark = {
return name + ".tieMark"; return name + ".tieMark";
} }
}; };
const TieGlyph = {
export const TieGlyph = {
get(glyph) { get(glyph) {
if (glyph && glyph.related) return glyph.related.TieGlyph; if (glyph && glyph.related) return glyph.related.TieGlyph;
else return null; else return null;
@ -108,7 +114,8 @@ const TieGlyph = {
Joining.or(glyph, Joining.Classes.Mid); Joining.or(glyph, Joining.Classes.Mid);
} }
}; };
const Radical = {
export const Radical = {
get(glyph) { get(glyph) {
if (glyph && glyph.related) return !!glyph.related.radical; if (glyph && glyph.related) return !!glyph.related.radical;
else return false; else return false;
@ -118,7 +125,8 @@ const Radical = {
glyph.related.radical = true; glyph.related.radical = true;
} }
}; };
const RequireCcmpDecompose = {
export const RequireCcmpDecompose = {
get(glyph) { get(glyph) {
if (glyph && glyph.related) return !!glyph.related.RequireCcmpDecompose; if (glyph && glyph.related) return !!glyph.related.RequireCcmpDecompose;
else return false; else return false;
@ -128,7 +136,8 @@ const RequireCcmpDecompose = {
glyph.related.RequireCcmpDecompose = true; glyph.related.RequireCcmpDecompose = true;
} }
}; };
const Joining = {
export const Joining = {
get(glyph) { get(glyph) {
if (glyph && glyph.related) return glyph.related.joining || 0; if (glyph && glyph.related) return glyph.related.joining || 0;
else return 0; else return 0;
@ -158,8 +167,12 @@ const Joining = {
Mid: 3 Mid: 3
} }
}; };
///////////////////////////////////////////////////////////////////////////////////////////////////
const CvTagCache = new Map(); const CvTagCache = new Map();
function Cv(tag, rank) {
export function Cv(tag, rank) {
const key = tag + "#" + rank; const key = tag + "#" + rank;
if (CvTagCache.has(key)) return CvTagCache.get(key); if (CvTagCache.has(key)) return CvTagCache.get(key);
const rel = { const rel = {
@ -197,13 +210,15 @@ function Cv(tag, rank) {
CvTagCache.set(key, rel); CvTagCache.set(key, rel);
return rel; return rel;
} }
const DotlessOrNot = {
export const DotlessOrNot = {
query(glyph) { query(glyph) {
if (Dotless.get(glyph)) return [Dotless]; if (Dotless.get(glyph)) return [Dotless];
return null; return null;
} }
}; };
const AnyCv = {
export const AnyCv = {
query(glyph) { query(glyph) {
let ret = []; let ret = [];
if (glyph && glyph.related && glyph.related.cv) { if (glyph && glyph.related && glyph.related.cv) {
@ -217,7 +232,8 @@ const AnyCv = {
return ret; return ret;
} }
}; };
const AnyDerivingCv = {
export const AnyDerivingCv = {
query(glyph) { query(glyph) {
let ret = []; let ret = [];
if (glyph && glyph.related && glyph.related.cv) { if (glyph && glyph.related && glyph.related.cv) {
@ -242,6 +258,15 @@ const AnyDerivingCv = {
return false; return false;
} }
}; };
///////////////////////////////////////////////////////////////////////////////////////////////////
export function getGrTree(gid, grSetList, fnGidToGlyph) {
if (typeof gid !== "string") throw new TypeError("Must supply a GID");
let sink = [];
getGrTreeImpl(gid, grSetList, fnGidToGlyph, sink);
return sink;
}
function getGrTreeImpl(gid, grSetList, fnGidToGlyph, sink) { function getGrTreeImpl(gid, grSetList, fnGidToGlyph, sink) {
if (!grSetList.length) return; if (!grSetList.length) return;
const g = fnGidToGlyph(gid); const g = fnGidToGlyph(gid);
@ -255,11 +280,30 @@ function getGrTreeImpl(gid, grSetList, fnGidToGlyph, sink) {
} }
} }
} }
function getGrTree(gid, grSetList, fnGidToGlyph) {
if (typeof gid !== "string") throw new TypeError("Must supply a GID"); ///////////////////////////////////////////////////////////////////////////////////////////////////
let sink = [];
getGrTreeImpl(gid, grSetList, fnGidToGlyph, sink); export function getGrMesh(gidList, grq, fnGidToGlyph) {
return sink; if (typeof gidList === "string" || !Array.isArray(gidList))
throw new TypeError(`glyphs must be a glyph array!`);
const allGrSet = new Set();
for (const g of gidList) {
for (const gr of grq.query(fnGidToGlyph(g))) allGrSet.add(gr);
}
const allGrList = Array.from(allGrSet);
let ret = [];
for (const gr of allGrList) {
const col = [];
collectGidLists(gidList, gidList, allGrList, gr, fnGidToGlyph, col);
if (!col.length) continue;
for (const from of col) {
const to = gidListMap(from, gr, fnGidToGlyph);
if (to && !gidListSame(from, to)) {
ret.push([gr, from, to]);
}
}
}
return ret;
} }
function gidListSame(a, b) { function gidListSame(a, b) {
for (let j = 0; j < a.length; j++) { for (let j = 0; j < a.length; j++) {
@ -295,29 +339,10 @@ function collectGidLists(gidListOrig, gidList, grl, excluded, fnGidToGlyph, sink
} }
} }
} }
function getGrMesh(gidList, grq, fnGidToGlyph) {
if (typeof gidList === "string" || !Array.isArray(gidList)) ///////////////////////////////////////////////////////////////////////////////////////////////////
throw new TypeError(`glyphs must be a glyph array!`);
const allGrSet = new Set(); export function createGrDisplaySheet(glyphStore, gid) {
for (const g of gidList) {
for (const gr of grq.query(fnGidToGlyph(g))) allGrSet.add(gr);
}
const allGrList = Array.from(allGrSet);
let ret = [];
for (const gr of allGrList) {
const col = [];
collectGidLists(gidList, gidList, allGrList, gr, fnGidToGlyph, col);
if (!col.length) continue;
for (const from of col) {
const to = gidListMap(from, gr, fnGidToGlyph);
if (to && !gidListSame(from, to)) {
ret.push([gr, from, to]);
}
}
}
return ret;
}
function createGrDisplaySheet(glyphStore, gid) {
const glyph = glyphStore.queryByName(gid); const glyph = glyphStore.queryByName(gid);
if (!glyph) return []; if (!glyph) return [];
// Query selected typographic features -- mostly NWID and WWID // Query selected typographic features -- mostly NWID and WWID
@ -389,7 +414,8 @@ function queryCvFeatureTagsOf(sink, gid, glyph, variantAssignmentSet) {
} }
for (const g of m.values()) if (g.length) sink.push(g); for (const g of m.values()) if (g.length) sink.push(g);
} }
function linkSuffixGr(gs, suffix, gr) {
export function linkSuffixGr(gs, suffix, gr) {
const reSuffix = new RegExp("\\." + suffix + "$"); const reSuffix = new RegExp("\\." + suffix + "$");
for (const [gnSuffixed, gSuffixed] of gs.namedEntries()) { for (const [gnSuffixed, gSuffixed] of gs.namedEntries()) {
if (reSuffix.test(gnSuffixed) && !/^\./.test(gnSuffixed)) { if (reSuffix.test(gnSuffixed) && !/^\./.test(gnSuffixed)) {
@ -400,7 +426,8 @@ function linkSuffixGr(gs, suffix, gr) {
} }
} }
} }
function linkSuffixPairGr(gs, tagCis, tagTrans, grCis, grTrans) {
export function linkSuffixPairGr(gs, tagCis, tagTrans, grCis, grTrans) {
const reTagCis = new RegExp("\\." + tagCis + "$"); const reTagCis = new RegExp("\\." + tagCis + "$");
for (const [gnCis, gCis] of gs.namedEntries()) { for (const [gnCis, gCis] of gs.namedEntries()) {
if (reTagCis.test(gnCis) && !/^\./.test(gnCis)) { if (reTagCis.test(gnCis) && !/^\./.test(gnCis)) {
@ -412,41 +439,17 @@ function linkSuffixPairGr(gs, tagCis, tagTrans, grCis, grTrans) {
} }
} }
} }
function hashCv(g) {
///////////////////////////////////////////////////////////////////////////////////////////////////
export function hashCv(g) {
const hasher = crypto.createHash("sha256"); const hasher = crypto.createHash("sha256");
for (const gr of AnyCv.query(g)) { for (const gr of AnyCv.query(g)) {
hasher.update(`${gr.tag}/${gr.rank}:${gr.get(g)}\n`); hasher.update(`${gr.tag}/${gr.rank}:${gr.get(g)}\n`);
} }
return hasher.digest("hex"); return hasher.digest("hex");
} }
///////////////////////////////////////////////////////////////////////////////////////////////////
export const SvInheritableRelations = [RightDependentLink, RightDependentTrigger, Joining]; export const SvInheritableRelations = [RightDependentLink, RightDependentTrigger, Joining];
export { Dotless };
export { LowerYDotAtBelow };
export { Cv };
export { AnyCv };
export { DotlessOrNot };
export { getGrTree };
export { getGrMesh };
export { TieMark };
export { TieGlyph };
export { Radical };
export { RequireCcmpDecompose };
export { Joining };
export { AnyDerivingCv };
export { CcmpDecompose };
export { CvDecompose };
export { PseudoCvDecompose };
export { RightDependentLink };
export { RightDependentTrigger };
export { MathSansSerif };
export { Nwid };
export { Wwid };
export { Lnum };
export { Onum };
export { AplForm };
export { NumeratorForm };
export { DenominatorForm };
export { hashCv };
export { createGrDisplaySheet };
export { linkSuffixGr };
export { linkSuffixPairGr };

View file

@ -1,13 +1,5 @@
import * as Parameters from "./parameters.mjs"; import * as Parameters from "./parameters.mjs";
function createBuildup(simple, buildup) {
let ligSet = new Set();
for (const s of buildup) {
if (!simple[s]) throw new Error("Cannot find simple ligation group " + s);
ligSet.add(simple[s].ligGroup);
}
return Array.from(ligSet);
}
export function applyLigationData(data, para, argv) { export function applyLigationData(data, para, argv) {
const defaultBuildup = {}; const defaultBuildup = {};
const hives = {}; const hives = {};
@ -44,3 +36,12 @@ export function applyLigationData(data, para, argv) {
); );
} }
} }
function createBuildup(simple, buildup) {
let ligSet = new Set();
for (const s of buildup) {
if (!simple[s]) throw new Error("Cannot find simple ligation group " + s);
ligSet.add(simple[s].ligGroup);
}
return Array.from(ligSet);
}

View file

@ -1,6 +1,6 @@
import { monotonicInterpolate } from "./util/monotonic-interpolate.mjs"; import { monotonicInterpolate } from "./util/monotonic-interpolate.mjs";
function applyMetricOverride(para, mo, argv) { export function applyMetricOverride(para, mo, argv) {
const bindings = initBindings(para, argv); const bindings = initBindings(para, argv);
for (const [field, expr] of Object.entries(mo)) { for (const [field, expr] of Object.entries(mo)) {
if (!validMetricOverrideFields.has(field)) { if (!validMetricOverrideFields.has(field)) {
@ -47,8 +47,10 @@ const validMetricOverrideFields = new Set([
"archDepth", "archDepth",
"smallArchDepth" "smallArchDepth"
]); ]);
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Function bindings // Function bindings
function initBindings(para, argv) { function initBindings(para, argv) {
const valueBindings = new Map(); const valueBindings = new Map();
for (const k of validMetricOverrideFields) { for (const k of validMetricOverrideFields) {
@ -61,6 +63,7 @@ function initBindings(para, argv) {
functionBindings.set("blend", blend); functionBindings.set("blend", blend);
return { val: valueBindings, functions: functionBindings }; return { val: valueBindings, functions: functionBindings };
} }
function blend(against, ...pairs) { function blend(against, ...pairs) {
const xs = [], const xs = [],
ys = []; ys = [];
@ -69,8 +72,10 @@ function blend(against, ...pairs) {
} }
return monotonicInterpolate(xs, ys)(against); return monotonicInterpolate(xs, ys)(against);
} }
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Simple expression parser // Simple expression parser
class State { class State {
constructor(input) { constructor(input) {
this.input = input; this.input = input;
@ -99,6 +104,7 @@ class State {
throw new SyntaxError("Failed to parse expression: " + this.input + "@" + this.cp); throw new SyntaxError("Failed to parse expression: " + this.input + "@" + this.cp);
} }
} }
function RootExpression(state, bindings) { function RootExpression(state, bindings) {
const e = Expression(state, bindings); const e = Expression(state, bindings);
state.expectEnd(); state.expectEnd();
@ -221,6 +227,7 @@ function List(start, end, state, bindings) {
state.expectAndAdvance(end); state.expectAndAdvance(end);
return results; return results;
} }
function skipSpaces(state) { function skipSpaces(state) {
while (state.testCk(isSpace)) state.advance(); while (state.testCk(isSpace)) state.advance();
} }
@ -233,4 +240,3 @@ function isDigit(ch) {
function isAlpha(ch) { function isAlpha(ch) {
return (ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || ch === "_"; return (ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || ch === "_";
} }
export { applyMetricOverride };

View file

@ -1,6 +1,6 @@
import { monotonicInterpolate } from "./util/monotonic-interpolate.mjs"; import { monotonicInterpolate } from "./util/monotonic-interpolate.mjs";
function initPara(data, argv) { export function init(data, argv) {
let para = {}; let para = {};
apply(para, data, ["iosevka"]); apply(para, data, ["iosevka"]);
if (argv.shape.serifs) apply(para, data, ["serifs-" + argv.shape.serifs]); if (argv.shape.serifs) apply(para, data, ["serifs-" + argv.shape.serifs]);
@ -29,10 +29,14 @@ function applyAlternatesParam(argv, para, data, key, keyArgv) {
if (argv.shape.serifs) apply(para, data, [`${kBase}-serifs-${argv.shape.serifs}`]); if (argv.shape.serifs) apply(para, data, [`${kBase}-serifs-${argv.shape.serifs}`]);
if (argv.shape.spacing) apply(para, data, [`${kBase}-spacing-${argv.shape.spacing}`]); if (argv.shape.spacing) apply(para, data, [`${kBase}-spacing-${argv.shape.spacing}`]);
} }
function apply(sink, parametersData, styles, blendArgs) {
export function apply(sink, parametersData, styles, blendArgs) {
if (!styles) return; if (!styles) return;
for (const item of styles) intro(parametersData, item, blendArgs, sink); for (const item of styles) intro(parametersData, item, blendArgs, sink);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line complexity // eslint-disable-next-line complexity
function intro(source, style, blendArgs, sink) { function intro(source, style, blendArgs, sink) {
let hive = source[style]; let hive = source[style];
@ -68,10 +72,12 @@ function intro(source, style, blendArgs, sink) {
hive = hiveBlend(hive, getBlendArg(blendArgs, style)); hive = hiveBlend(hive, getBlendArg(blendArgs, style));
for (const k in hive) sink[k] = hive[k]; for (const k in hive) sink[k] = hive[k];
} }
function getBlendArg(blendArgs, style) { function getBlendArg(blendArgs, style) {
if (!blendArgs) return undefined; if (!blendArgs) return undefined;
return blendArgs[style]; return blendArgs[style];
} }
function hiveBlend(hive, value) { function hiveBlend(hive, value) {
if (!hive || !hive.blend || value == null) return hive; if (!hive || !hive.blend || value == null) return hive;
const block = hive.blend; const block = hive.blend;
@ -98,5 +104,3 @@ function hiveBlend(hive, value) {
} }
return generatedHive; return generatedHive;
} }
export { initPara as init };
export { apply };

View file

@ -1,24 +1,18 @@
function struct(leader, ...items) { export function struct(leader, ...items) {
return "" + leader + "(" + items.join(";") + ")"; return "" + leader + "(" + items.join(";") + ")";
} }
function tuple(...items) { export function tuple(...items) {
return "(" + items.join(";") + ")"; return "(" + items.join(";") + ")";
} }
function list(items) { export function list(items) {
return "{" + items.join(";") + "}"; return "{" + items.join(";") + "}";
} }
function n(x) { export function n(x) {
return String(Math.round(x * 0x10000)); return String(Math.round(x * 0x10000));
} }
function typedPoint(z) { export function typedPoint(z) {
return tuple(z.type, n(z.x), n(z.y)); return tuple(z.type, n(z.x), n(z.y));
} }
function gizmo(g) { export function gizmo(g) {
return tuple(n(g.xx), n(g.xy), n(g.yx), n(g.yy), n(g.x), n(g.y)); return tuple(n(g.xx), n(g.xy), n(g.yx), n(g.yy), n(g.x), n(g.y));
} }
export { struct };
export { tuple };
export { list };
export { n };
export { typedPoint };
export { gizmo };

View file

@ -1,29 +1,23 @@
function mix(a, b, p) { export function mix(a, b, p) {
return a + (b - a) * p; return a + (b - a) * p;
} }
function barmixL(l, r, b, p) { export function barMixL(l, r, b, p) {
return l > r ? barmixL(r, l, b, p) : l + b + p * (r - l - b * 3); return l > r ? barMixL(r, l, b, p) : l + b + p * (r - l - b * 3);
} }
function barmixM(l, r, b, p) { export function linreg(x0, y0, x1, y1, x) {
return barmixL(l, r, b, p) + b / 2;
}
function barMixR(l, r, b, p) {
return barMixR(l, r, b, p) + b;
}
function linreg(x0, y0, x1, y1, x) {
return y0 + ((x - x0) * (y1 - y0)) / (x1 - x0); return y0 + ((x - x0) * (y1 - y0)) / (x1 - x0);
} }
function clamp(l, h, x) { export function clamp(l, h, x) {
return x < l ? l : x > h ? h : x; return x < l ? l : x > h ? h : x;
} }
function fallback(...args) { export function fallback(...args) {
for (const item of args) if (item !== void 0) return item; for (const item of args) if (item !== void 0) return item;
return void 0; return void 0;
} }
function bez2(a, b, c, t) { export function bez2(a, b, c, t) {
return (1 - t) * (1 - t) * a + 2 * (1 - t) * t * b + t * t * c; return (1 - t) * (1 - t) * a + 2 * (1 - t) * t * b + t * t * c;
} }
function bez3(a, b, c, d, t) { export function bez3(a, b, c, d, t) {
return ( return (
(1 - t) * (1 - t) * (1 - t) * a + (1 - t) * (1 - t) * (1 - t) * a +
3 * (1 - t) * (1 - t) * t * b + 3 * (1 - t) * (1 - t) * t * b +
@ -31,12 +25,3 @@ function bez3(a, b, c, d, t) {
t * t * t * d t * t * t * d
); );
} }
export { mix };
export { barmixL };
export { barmixM };
export { barMixR as barmixR };
export { linreg };
export { clamp };
export { fallback };
export { bez2 };
export { bez3 };

View file

@ -1,5 +1,5 @@
function applyVariantData(data, para, argv) { export function apply(data, para, argv) {
const parsed = parseVariantsData(data, argv); const parsed = parse(data, argv);
let tagSet = new Set(); let tagSet = new Set();
for (const prime of parsed.primes.values()) { for (const prime of parsed.primes.values()) {
if (!prime.tag) continue; if (!prime.tag) continue;
@ -23,7 +23,8 @@ function applyVariantData(data, para, argv) {
}; };
para.variantSelector = variantSelector; para.variantSelector = variantSelector;
} }
function parseVariantsData(data, argv) {
export function parse(data, argv) {
const primes = new Map(); const primes = new Map();
const selectorTree = new SelectorTree(); const selectorTree = new SelectorTree();
for (const k in data.prime) { for (const k in data.prime) {
@ -46,6 +47,7 @@ function parseVariantsData(data, argv) {
} }
return { selectorTree: selectorTree, primes, composites, defaultComposite }; return { selectorTree: selectorTree, primes, composites, defaultComposite };
} }
class SelectorTree { class SelectorTree {
constructor() { constructor() {
this.m_mapping = new Map(); this.m_mapping = new Map();
@ -62,6 +64,7 @@ class SelectorTree {
for (const m of this.m_mapping.values()) yield* m.values(); for (const m of this.m_mapping.values()) yield* m.values();
} }
} }
class Prime { class Prime {
constructor(key, cfg) { constructor(key, cfg) {
if (!cfg.variants) throw new Error(`Missing variants in ${key}`); if (!cfg.variants) throw new Error(`Missing variants in ${key}`);
@ -116,6 +119,7 @@ class Prime {
return gr; return gr;
} }
} }
class PrimeVariant { class PrimeVariant {
constructor(key, tag, cfg) { constructor(key, tag, cfg) {
this.key = key; this.key = key;
@ -136,6 +140,7 @@ class PrimeVariant {
Object.assign(vs, this.selector); Object.assign(vs, this.selector);
} }
} }
class Composite { class Composite {
constructor(key, cfg) { constructor(key, cfg) {
this.key = key; this.key = key;
@ -185,5 +190,3 @@ class Composite {
} }
} }
} }
export { applyVariantData as apply };
export { parseVariantsData as parse };