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'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs"
import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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
@ -13,7 +13,7 @@ glyph-block Letter-Cyrillic-Yu : begin
define SLAB-BULGARIAN 3
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 : 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)
@ -45,4 +45,4 @@ glyph-block Letter-Cyrillic-Yu : begin
local df : DivFrame para.diversityM 3
set-width df.width
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'
import [mix barmixL linreg clamp fallback] from"../../../support/utils.mjs"
import [mix linreg clamp fallback] from"../../../support/utils.mjs"
glyph-module

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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 [DesignParameters] from"../../../meta/aesthetics.mjs"

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

@ -1,6 +1,6 @@
$$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"
glyph-module

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import crypto from "crypto";
const Dotless = {
export const Dotless = {
tag: "dtls",
get(glyph) {
if (glyph && glyph.related) return glyph.related.dotless;
@ -15,6 +15,10 @@ const Dotless = {
return name + ".dotless";
}
};
export const LowerYDotAtBelow = SimpleProp("LowerYDotAtBelow");
export const RightDependentTrigger = SimpleProp("RightDependentTrigger");
export const MathSansSerif = SimpleProp("MathSansSerif");
function SimpleProp(key) {
return {
get(glyph) {
@ -28,9 +32,8 @@ function SimpleProp(key) {
}
};
}
const LowerYDotAtBelow = SimpleProp("LowerYDotAtBelow");
const RightDependentTrigger = SimpleProp("RightDependentTrigger");
const MathSansSerif = SimpleProp("MathSansSerif");
export const RightDependentLink = DependentLinkProp("RightDependentLink");
function DependentLinkProp(key) {
return {
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) {
return { ...SimpleProp(key), otlTag };
}
const Nwid = OtlTaggedProp("Nwid", "NWID");
const Wwid = OtlTaggedProp("Wwid", "WWID");
const Lnum = OtlTaggedProp("Lnum", "lnum");
const Onum = OtlTaggedProp("Onum", "onum");
const AplForm = OtlTaggedProp("AplForm", "APLF");
const NumeratorForm = OtlTaggedProp("Numerator", "numr");
const DenominatorForm = OtlTaggedProp("Denominator", "dnom");
export const CvDecompose = DecompositionProp("CvDecompose");
export const PseudoCvDecompose = DecompositionProp("PseudoCvDecompose");
export const CcmpDecompose = DecompositionProp("CcmpDecompose");
function DecompositionProp(key) {
return {
get(glyph) {
@ -76,10 +83,8 @@ function DecompositionProp(key) {
}
};
}
const CvDecompose = DecompositionProp("CvDecompose");
const PseudoCvDecompose = DecompositionProp("PseudoCvDecompose");
const CcmpDecompose = DecompositionProp("CcmpDecompose");
const TieMark = {
export const TieMark = {
tag: "TMRK",
get(glyph) {
if (glyph && glyph.related) return glyph.related.TieMark;
@ -97,7 +102,8 @@ const TieMark = {
return name + ".tieMark";
}
};
const TieGlyph = {
export const TieGlyph = {
get(glyph) {
if (glyph && glyph.related) return glyph.related.TieGlyph;
else return null;
@ -108,7 +114,8 @@ const TieGlyph = {
Joining.or(glyph, Joining.Classes.Mid);
}
};
const Radical = {
export const Radical = {
get(glyph) {
if (glyph && glyph.related) return !!glyph.related.radical;
else return false;
@ -118,7 +125,8 @@ const Radical = {
glyph.related.radical = true;
}
};
const RequireCcmpDecompose = {
export const RequireCcmpDecompose = {
get(glyph) {
if (glyph && glyph.related) return !!glyph.related.RequireCcmpDecompose;
else return false;
@ -128,7 +136,8 @@ const RequireCcmpDecompose = {
glyph.related.RequireCcmpDecompose = true;
}
};
const Joining = {
export const Joining = {
get(glyph) {
if (glyph && glyph.related) return glyph.related.joining || 0;
else return 0;
@ -158,8 +167,12 @@ const Joining = {
Mid: 3
}
};
///////////////////////////////////////////////////////////////////////////////////////////////////
const CvTagCache = new Map();
function Cv(tag, rank) {
export function Cv(tag, rank) {
const key = tag + "#" + rank;
if (CvTagCache.has(key)) return CvTagCache.get(key);
const rel = {
@ -197,13 +210,15 @@ function Cv(tag, rank) {
CvTagCache.set(key, rel);
return rel;
}
const DotlessOrNot = {
export const DotlessOrNot = {
query(glyph) {
if (Dotless.get(glyph)) return [Dotless];
return null;
}
};
const AnyCv = {
export const AnyCv = {
query(glyph) {
let ret = [];
if (glyph && glyph.related && glyph.related.cv) {
@ -217,7 +232,8 @@ const AnyCv = {
return ret;
}
};
const AnyDerivingCv = {
export const AnyDerivingCv = {
query(glyph) {
let ret = [];
if (glyph && glyph.related && glyph.related.cv) {
@ -242,6 +258,15 @@ const AnyDerivingCv = {
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) {
if (!grSetList.length) return;
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);
return sink;
///////////////////////////////////////////////////////////////////////////////////////////////////
export 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();
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) {
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();
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) {
///////////////////////////////////////////////////////////////////////////////////////////////////
export function createGrDisplaySheet(glyphStore, gid) {
const glyph = glyphStore.queryByName(gid);
if (!glyph) return [];
// 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);
}
function linkSuffixGr(gs, suffix, gr) {
export function linkSuffixGr(gs, suffix, gr) {
const reSuffix = new RegExp("\\." + suffix + "$");
for (const [gnSuffixed, gSuffixed] of gs.namedEntries()) {
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 + "$");
for (const [gnCis, gCis] of gs.namedEntries()) {
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");
for (const gr of AnyCv.query(g)) {
hasher.update(`${gr.tag}/${gr.rank}:${gr.get(g)}\n`);
}
return hasher.digest("hex");
}
///////////////////////////////////////////////////////////////////////////////////////////////////
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";
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) {
const defaultBuildup = {};
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";
function applyMetricOverride(para, mo, argv) {
export function applyMetricOverride(para, mo, argv) {
const bindings = initBindings(para, argv);
for (const [field, expr] of Object.entries(mo)) {
if (!validMetricOverrideFields.has(field)) {
@ -47,8 +47,10 @@ const validMetricOverrideFields = new Set([
"archDepth",
"smallArchDepth"
]);
///////////////////////////////////////////////////////////////////////////////////////////////////
// Function bindings
function initBindings(para, argv) {
const valueBindings = new Map();
for (const k of validMetricOverrideFields) {
@ -61,6 +63,7 @@ function initBindings(para, argv) {
functionBindings.set("blend", blend);
return { val: valueBindings, functions: functionBindings };
}
function blend(against, ...pairs) {
const xs = [],
ys = [];
@ -69,8 +72,10 @@ function blend(against, ...pairs) {
}
return monotonicInterpolate(xs, ys)(against);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Simple expression parser
class State {
constructor(input) {
this.input = input;
@ -99,6 +104,7 @@ class State {
throw new SyntaxError("Failed to parse expression: " + this.input + "@" + this.cp);
}
}
function RootExpression(state, bindings) {
const e = Expression(state, bindings);
state.expectEnd();
@ -221,6 +227,7 @@ function List(start, end, state, bindings) {
state.expectAndAdvance(end);
return results;
}
function skipSpaces(state) {
while (state.testCk(isSpace)) state.advance();
}
@ -233,4 +240,3 @@ function isDigit(ch) {
function isAlpha(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";
function initPara(data, argv) {
export function init(data, argv) {
let para = {};
apply(para, data, ["iosevka"]);
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.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;
for (const item of styles) intro(parametersData, item, blendArgs, sink);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line complexity
function intro(source, style, blendArgs, sink) {
let hive = source[style];
@ -68,10 +72,12 @@ function intro(source, style, blendArgs, sink) {
hive = hiveBlend(hive, getBlendArg(blendArgs, style));
for (const k in hive) sink[k] = hive[k];
}
function getBlendArg(blendArgs, style) {
if (!blendArgs) return undefined;
return blendArgs[style];
}
function hiveBlend(hive, value) {
if (!hive || !hive.blend || value == null) return hive;
const block = hive.blend;
@ -98,5 +104,3 @@ function hiveBlend(hive, value) {
}
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(";") + ")";
}
function tuple(...items) {
export function tuple(...items) {
return "(" + items.join(";") + ")";
}
function list(items) {
export function list(items) {
return "{" + items.join(";") + "}";
}
function n(x) {
export function n(x) {
return String(Math.round(x * 0x10000));
}
function typedPoint(z) {
export function typedPoint(z) {
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));
}
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;
}
function barmixL(l, r, b, p) {
return l > r ? barmixL(r, l, b, p) : l + b + p * (r - l - b * 3);
export function barMixL(l, r, b, p) {
return l > r ? barMixL(r, l, b, p) : l + b + p * (r - l - b * 3);
}
function barmixM(l, r, b, p) {
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) {
export function linreg(x0, y0, x1, y1, x) {
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;
}
function fallback(...args) {
export function fallback(...args) {
for (const item of args) if (item !== void 0) return item;
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;
}
function bez3(a, b, c, d, t) {
export function bez3(a, b, c, d, t) {
return (
(1 - t) * (1 - t) * (1 - t) * a +
3 * (1 - t) * (1 - t) * t * b +
@ -31,12 +25,3 @@ function bez3(a, b, c, d, t) {
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) {
const parsed = parseVariantsData(data, argv);
export function apply(data, para, argv) {
const parsed = parse(data, argv);
let tagSet = new Set();
for (const prime of parsed.primes.values()) {
if (!prime.tag) continue;
@ -23,7 +23,8 @@ function applyVariantData(data, para, argv) {
};
para.variantSelector = variantSelector;
}
function parseVariantsData(data, argv) {
export function parse(data, argv) {
const primes = new Map();
const selectorTree = new SelectorTree();
for (const k in data.prime) {
@ -46,6 +47,7 @@ function parseVariantsData(data, argv) {
}
return { selectorTree: selectorTree, primes, composites, defaultComposite };
}
class SelectorTree {
constructor() {
this.m_mapping = new Map();
@ -62,6 +64,7 @@ class SelectorTree {
for (const m of this.m_mapping.values()) yield* m.values();
}
}
class Prime {
constructor(key, cfg) {
if (!cfg.variants) throw new Error(`Missing variants in ${key}`);
@ -116,6 +119,7 @@ class Prime {
return gr;
}
}
class PrimeVariant {
constructor(key, tag, cfg) {
this.key = key;
@ -136,6 +140,7 @@ class PrimeVariant {
Object.assign(vs, this.selector);
}
}
class Composite {
constructor(key, cfg) {
this.key = key;
@ -185,5 +190,3 @@ class Composite {
}
}
}
export { applyVariantData as apply };
export { parseVariantsData as parse };