Format cleanup
This commit is contained in:
parent
36835216f5
commit
e61edd0db9
13 changed files with 52 additions and 52 deletions
|
@ -73,7 +73,7 @@ class Cache {
|
|||
}
|
||||
}
|
||||
}
|
||||
export const load = async function (path, version, freshAgeKey) {
|
||||
export async function load(path, version, freshAgeKey) {
|
||||
let cache = new Cache(freshAgeKey);
|
||||
if (path && fs.existsSync(path)) {
|
||||
try {
|
||||
|
@ -85,15 +85,15 @@ export const load = async function (path, version, freshAgeKey) {
|
|||
}
|
||||
}
|
||||
return cache;
|
||||
};
|
||||
export const save = async function savePTCache(path, version, cache, diffOnly) {
|
||||
}
|
||||
export async function save(path, version, cache, diffOnly) {
|
||||
if (path) {
|
||||
const buf = encode(cache.toRep(version, diffOnly));
|
||||
const bufZip = zlib.gzipSync(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength));
|
||||
await fs.promises.writeFile(path, bufZip);
|
||||
}
|
||||
};
|
||||
export const merge = async function (base, diff, version, freshAgeKey) {
|
||||
}
|
||||
export async function merge(base, diff, version, freshAgeKey) {
|
||||
const cacheDiff = await load(diff, version, freshAgeKey);
|
||||
if (!cacheDiff.isEmpty()) {
|
||||
const cacheBase = await load(base, version, freshAgeKey);
|
||||
|
@ -101,4 +101,4 @@ export const merge = async function (base, diff, version, freshAgeKey) {
|
|||
await save(base, version, cacheBase, false);
|
||||
}
|
||||
if (fs.existsSync(diff)) await fs.promises.rm(diff);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Ot } from "ot-builder";
|
||||
|
||||
export const CreateEmptyFont = function (argv) {
|
||||
export function CreateEmptyFont(argv) {
|
||||
let font = {
|
||||
head: new Ot.Head.Table(),
|
||||
hhea: new Ot.MetricHead.Hhea(),
|
||||
|
@ -14,4 +14,4 @@ export const CreateEmptyFont = function (argv) {
|
|||
font.head.modified = new Date(process.env.SOURCE_DATE_EPOCH * 1000);
|
||||
}
|
||||
return font;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -139,9 +139,9 @@ function markGlyphsGsubReverse(sink, lookup, cfg) {
|
|||
function sweep(glyphStore, gnSet) {
|
||||
return glyphStore.filterByName(gnSet);
|
||||
}
|
||||
export const gcFont = function (glyphStore, excludedChars, otl, cfg) {
|
||||
export function gcFont(glyphStore, excludedChars, otl, cfg) {
|
||||
markSweepOtlLookups(otl.GSUB);
|
||||
markSweepOtlLookups(otl.GPOS);
|
||||
const sink = markGlyphs(glyphStore, excludedChars, otl, cfg);
|
||||
return sweep(glyphStore, sink);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ function validateMonospace(para, glyphStore) {
|
|||
throw new Error("Unreachable! Building monospace with more than 2 character widths");
|
||||
}
|
||||
}
|
||||
export const finalizeFont = function (cache, para, glyphStore, excludedCodePoints, restFont) {
|
||||
export function finalizeFont(cache, para, glyphStore, excludedCodePoints, restFont) {
|
||||
assignGrAndCodeRank(glyphStore, Nwid, Wwid);
|
||||
assignSubRank(glyphStore);
|
||||
glyphStore = gcFont(glyphStore, excludedCodePoints, restFont, {});
|
||||
glyphStore = finalizeGlyphs(cache, para, glyphStore);
|
||||
validateMonospace(para, glyphStore);
|
||||
return glyphStore;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class BooleImpl {
|
|||
);
|
||||
}
|
||||
}
|
||||
export const SetupBuilders = function (bindings) {
|
||||
export function SetupBuilders(bindings) {
|
||||
const union = (...operands) =>
|
||||
new BooleImpl(bindings, TypoGeom.Boolean.ClipType.ctUnion, operands);
|
||||
const intersection = (...operands) =>
|
||||
|
@ -39,4 +39,4 @@ export const SetupBuilders = function (bindings) {
|
|||
intersection: intersection,
|
||||
difference: difference
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ function flattenImpl(sink, knots) {
|
|||
function nCyclic(p, n) {
|
||||
return (p + n + n) % n;
|
||||
}
|
||||
export const SetupBuilders = function (bindings) {
|
||||
export function SetupBuilders(bindings) {
|
||||
const { Contrast, GlobalTransform, Stroke, Superness } = bindings;
|
||||
function validateCoord(x) {
|
||||
if (!isFinite(x)) throw new TypeError("NaN detected");
|
||||
|
@ -333,4 +333,4 @@ export const SetupBuilders = function (bindings) {
|
|||
dispiro,
|
||||
"spiro-outline": spiroOutline
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -109,12 +109,12 @@ export class ReverseCurve {
|
|||
export function convertShapeToArcs(shape) {
|
||||
return shape.map(convertContourToArcs);
|
||||
}
|
||||
export const shapeToRep = function (shape) {
|
||||
export function shapeToRep(shape) {
|
||||
return shape.map(contourToRep);
|
||||
};
|
||||
export const repToShape = function (shapeRep) {
|
||||
}
|
||||
export function repToShape(shapeRep) {
|
||||
return shapeRep.map(repToContour);
|
||||
};
|
||||
}
|
||||
export class BezToContoursSink {
|
||||
constructor(gizmo) {
|
||||
this.gizmo = gizmo || Transform.Id();
|
||||
|
|
|
@ -10,7 +10,7 @@ import { Point } from "./point.mjs";
|
|||
import { SpiroExpander } from "./spiro-expand.mjs";
|
||||
import { Transform } from "./transform.mjs";
|
||||
|
||||
class GeometryBase {
|
||||
export class GeometryBase {
|
||||
asContours() {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ class GeometryBase {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
class ContourGeometry extends GeometryBase {
|
||||
|
||||
export class ContourGeometry extends GeometryBase {
|
||||
constructor(points) {
|
||||
super();
|
||||
this.m_points = [];
|
||||
|
@ -66,7 +67,8 @@ class ContourGeometry extends GeometryBase {
|
|||
return Format.struct(`ContourGeometry`, Format.list(this.m_points.map(Format.typedPoint)));
|
||||
}
|
||||
}
|
||||
class SpiroGeometry extends GeometryBase {
|
||||
|
||||
export class SpiroGeometry extends GeometryBase {
|
||||
constructor(gizmo, closed, knots) {
|
||||
super();
|
||||
this.m_knots = [];
|
||||
|
@ -108,7 +110,8 @@ class SpiroGeometry extends GeometryBase {
|
|||
);
|
||||
}
|
||||
}
|
||||
class DiSpiroGeometry extends GeometryBase {
|
||||
|
||||
export class DiSpiroGeometry extends GeometryBase {
|
||||
constructor(gizmo, contrast, closed, biKnots) {
|
||||
super();
|
||||
this.m_biKnots = [];
|
||||
|
@ -178,7 +181,8 @@ class DiSpiroGeometry extends GeometryBase {
|
|||
);
|
||||
}
|
||||
}
|
||||
class ReferenceGeometry extends GeometryBase {
|
||||
|
||||
export class ReferenceGeometry extends GeometryBase {
|
||||
constructor(glyph, x, y) {
|
||||
super();
|
||||
if (!glyph || !glyph.geometry) throw new TypeError("Invalid glyph");
|
||||
|
@ -220,7 +224,8 @@ class ReferenceGeometry extends GeometryBase {
|
|||
return Format.struct("ReferenceGeometry", sTarget, Format.n(this.m_x), Format.n(this.m_y));
|
||||
}
|
||||
}
|
||||
class TaggedGeometry extends GeometryBase {
|
||||
|
||||
export class TaggedGeometry extends GeometryBase {
|
||||
constructor(g, tag) {
|
||||
super();
|
||||
this.m_geom = g;
|
||||
|
@ -249,7 +254,8 @@ class TaggedGeometry extends GeometryBase {
|
|||
return this.m_geom.toShapeStringOrNull();
|
||||
}
|
||||
}
|
||||
class TransformedGeometry extends GeometryBase {
|
||||
|
||||
export class TransformedGeometry extends GeometryBase {
|
||||
constructor(g, tfm) {
|
||||
super();
|
||||
this.m_geom = g;
|
||||
|
@ -310,7 +316,8 @@ class TransformedGeometry extends GeometryBase {
|
|||
return Format.struct("TransformedGeometry", sTarget, Format.gizmo(this.m_transform));
|
||||
}
|
||||
}
|
||||
class CombineGeometry extends GeometryBase {
|
||||
|
||||
export class CombineGeometry extends GeometryBase {
|
||||
constructor(parts) {
|
||||
super();
|
||||
this.m_parts = parts || [];
|
||||
|
@ -380,7 +387,8 @@ class CombineGeometry extends GeometryBase {
|
|||
return Format.struct("CombineGeometry", Format.list(sParts));
|
||||
}
|
||||
}
|
||||
class BooleanGeometry extends GeometryBase {
|
||||
|
||||
export class BooleanGeometry extends GeometryBase {
|
||||
constructor(operator, operands) {
|
||||
super();
|
||||
this.m_operator = operator;
|
||||
|
@ -454,25 +462,17 @@ class BooleanGeometry extends GeometryBase {
|
|||
return Format.struct("BooleanGeometry", this.m_operator, Format.list(sParts));
|
||||
}
|
||||
}
|
||||
function combineWith(a, b) {
|
||||
|
||||
export function combineWith(a, b) {
|
||||
if (a instanceof CombineGeometry) {
|
||||
return a.with(b);
|
||||
} else {
|
||||
return new CombineGeometry([a, b]);
|
||||
}
|
||||
}
|
||||
export const hashGeometry = function (geom) {
|
||||
|
||||
export function hashGeometry(geom) {
|
||||
const s = geom.toShapeStringOrNull();
|
||||
if (!s) return null;
|
||||
return crypto.createHash("sha256").update(s).digest("hex");
|
||||
};
|
||||
export { GeometryBase };
|
||||
export { SpiroGeometry };
|
||||
export { DiSpiroGeometry };
|
||||
export { ContourGeometry };
|
||||
export { ReferenceGeometry };
|
||||
export { TaggedGeometry };
|
||||
export { TransformedGeometry };
|
||||
export { CombineGeometry };
|
||||
export { BooleanGeometry };
|
||||
export { combineWith };
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function createBuildup(simple, buildup) {
|
|||
}
|
||||
return Array.from(ligSet);
|
||||
}
|
||||
export const applyLigationData = function (data, para, argv) {
|
||||
export function applyLigationData(data, para, argv) {
|
||||
const defaultBuildup = {};
|
||||
const hives = {};
|
||||
hives["default"] = { caltBuildup: [] };
|
||||
|
@ -43,4 +43,4 @@ export const applyLigationData = function (data, para, argv) {
|
|||
argv.ligations.enables.map(x => `ligset-enable-${x}`)
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ export function maskBit(x, y) {
|
|||
export function maskBits(x, y) {
|
||||
return x & y;
|
||||
}
|
||||
export const popCountByte = function (x) {
|
||||
export function popCountByte(x) {
|
||||
return pcNibbleLookup[x & 0x0f] + pcNibbleLookup[(x >>> 4) & 0x0f];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const monotonicInterpolate = function (xs, ys) {
|
||||
export function monotonicInterpolate(xs, ys) {
|
||||
let i,
|
||||
length = xs.length;
|
||||
// Deal with length issues
|
||||
|
@ -101,4 +101,4 @@ export const monotonicInterpolate = function (xs, ys) {
|
|||
diffSq = diff * diff;
|
||||
return ys[i] + c1s[i] * diff + c2s[i] * diffSq + c3s[i] * diff * diffSq;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ function buildLigationSet(ligData, getKey) {
|
|||
}
|
||||
return ligationSets;
|
||||
}
|
||||
export const parseLigationData = async function () {
|
||||
export async function parseLigationData() {
|
||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||
const ligToml = await fs.promises.readFile(
|
||||
path.join(__dirname, "../../params/ligation-set.toml"),
|
||||
|
@ -238,4 +238,4 @@ export const parseLigationData = async function () {
|
|||
sets: [...ligationSets.values()],
|
||||
nonMergeSets: [...nonMergeLigationSets.values()]
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ function uniqueHotChars(cfgDefault, cfgSS) {
|
|||
}
|
||||
return Array.from(s);
|
||||
}
|
||||
export const parseVariantsData = async function () {
|
||||
export async function parseVariantsData() {
|
||||
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
||||
const variantsToml = await fs.promises.readFile(
|
||||
path.join(__dirname, "../../params/variants.toml"),
|
||||
|
@ -153,4 +153,4 @@ export const parseVariantsData = async function () {
|
|||
const composites = getSsData(varDatParsed);
|
||||
const defaults = getCompWithLens(varDatParsed, null, x => x.composition);
|
||||
return { primes, composites, specials, defaults };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue