Remove DistCharMap and remove yargs dependency

This commit is contained in:
Belleve Invis 2020-04-24 18:17:16 -07:00
parent a4bbf085da
commit cea82d67a8
5 changed files with 107 additions and 133 deletions

View file

@ -3,28 +3,18 @@
const fs = require("fs-extra"); const fs = require("fs-extra");
const path = require("path"); const path = require("path");
const argv = require("yargs").argv;
const buildFont = require("./build-font.js"); const buildFont = require("./build-font.js");
const EmptyFont = require("./empty-font.js");
const parameters = require("../support/parameters"); const parameters = require("../support/parameters");
const formVariantData = require("../support/variant-data"); const formVariantData = require("../support/variant-data");
const formLigationData = require("../support/ligation-data"); const formLigationData = require("../support/ligation-data");
const regulateGlyphs = require("../support/regulate-glyph");
const toml = require("toml"); const toml = require("toml");
main().catch(e => { module.exports = async function main(argv) {
console.error(e);
process.exit(1);
});
///////////////////////////////////////////////////////////////////////////////////////////////////
async function main() {
const para = await getParameters(argv); const para = await getParameters(argv);
const font = buildFont(para); const font = buildFont(para);
if (argv.charmap) await saveCharMap(font); if (argv.charmap) await saveCharMap(argv, font);
if (argv.o) await saveOtd(font); if (argv.o) await saveOtd(argv, font);
} };
// Parameter preparation // Parameter preparation
async function getParameters(argv) { async function getParameters(argv) {
@ -41,23 +31,23 @@ async function getParameters(argv) {
const rawVariantsData = await tryParseToml(VARIANTS_TOML); const rawVariantsData = await tryParseToml(VARIANTS_TOML);
const rawLigationData = await tryParseToml(LIGATIONS_TOML); const rawLigationData = await tryParseToml(LIGATIONS_TOML);
const para = parameters.build(parametersData, argv._, { "shape-weight": argv["shape-weight"] }); const para = parameters.build(parametersData, argv.hives, { shapeWeight: argv.shapeWeight });
const variantsData = formVariantData(rawVariantsData, para); const variantsData = formVariantData(rawVariantsData, para);
para.variants = variantsData; para.variants = variantsData;
para.variantSelector = parameters.build(variantsData, ["default", ...argv._]); para.variantSelector = parameters.build(variantsData, ["default", ...argv.hives]);
para.defaultVariant = variantsData.default; para.defaultVariant = variantsData.default;
const ligationData = formLigationData(rawLigationData, para); const ligationData = formLigationData(rawLigationData, para);
para.defaultBuildup = ligationData.defaultBuildup; para.defaultBuildup = ligationData.defaultBuildup;
para.ligation = parameters.build(ligationData.hives, ["default", ...argv._]); para.ligation = parameters.build(ligationData.hives, ["default", ...argv.hives]);
para.naming = { para.naming = {
family: argv.family, family: argv.family,
version: argv.ver, version: argv.version,
weight: argv["menu-weight"] - 0, weight: argv.menuWeight - 0,
width: argv["menu-width"] - 0, width: argv.menuWidth - 0,
slant: argv["menu-slant"] slant: argv.menuSlant
}; };
return para; return para;
@ -74,7 +64,7 @@ async function tryParseToml(str) {
} }
// Save OTD // Save OTD
async function saveOtd(font) { async function saveOtd(argv, font) {
if (argv.o === "|") { if (argv.o === "|") {
process.stdout.write(JSON.stringify(font)); process.stdout.write(JSON.stringify(font));
} else { } else {
@ -89,7 +79,7 @@ function objHashNonEmpty(obj) {
return false; return false;
} }
async function saveCharMap(font) { async function saveCharMap(argv, font) {
let charMap = []; let charMap = [];
for (const gid in font.glyf) { for (const gid in font.glyf) {
const glyph = font.glyf[gid]; const glyph = font.glyf[gid];

View file

@ -21,8 +21,7 @@
"ttf2woff2": "^3.0.0", "ttf2woff2": "^3.0.0",
"unorm": "^1.6.0", "unorm": "^1.6.0",
"verda": "^1.0.1", "verda": "^1.0.1",
"fs-extra": "^9.0.0", "fs-extra": "^9.0.0"
"yargs": "^15.3.1"
}, },
"devDependencies": { "devDependencies": {
"cldr": "^5.5.4", "cldr": "^5.5.4",

View file

@ -64,7 +64,7 @@ enableLigation = true
# Excluded code points # Excluded code points
excludedCodePointRanges = [] excludedCodePointRanges = []
[shape-weight.blend.400] [shapeWeight.blend.400]
stroke = 72 # Primary stroke width stroke = 72 # Primary stroke width
sb = 60 # Primary sidebearings sb = 60 # Primary sidebearings
essx = 1.12 # Proportion of widen of center of "S" essx = 1.12 # Proportion of widen of center of "S"
@ -110,7 +110,7 @@ cthinb = 0.5
vtipfine = 0.8 vtipfine = 0.8
vtipfineSlab = 0.9 vtipfineSlab = 0.9
[shape-weight.blend.100] [shapeWeight.blend.100]
jut = 85 jut = 85
vjut = 145 vjut = 145
smooth = 195 smooth = 195
@ -127,7 +127,7 @@ sb = 72
dotsize = 53 dotsize = 53
periodsize = 55 periodsize = 55
[shape-weight.blend.200] [shapeWeight.blend.200]
jut = 85 jut = 85
vjut = 145 vjut = 145
smooth = 195 smooth = 195
@ -144,7 +144,7 @@ sb = 68
dotsize = 70 dotsize = 70
periodsize = 77 periodsize = 77
[shape-weight.blend.300] [shapeWeight.blend.300]
jut = 85 jut = 85
vjut = 145 vjut = 145
smooth = 195 smooth = 195
@ -161,7 +161,7 @@ sb = 64
dotsize = 100 dotsize = 100
periodsize = 115 periodsize = 115
[shape-weight.blend.500] [shapeWeight.blend.500]
essx = 1.12 essx = 1.12
jut = 85 jut = 85
vjut = 157 vjut = 157
@ -175,7 +175,7 @@ sb = 57
dotsize = 135 dotsize = 135
periodsize = 160 periodsize = 160
[shape-weight.blend.600] [shapeWeight.blend.600]
essx = 1.07 essx = 1.07
jut = 85 jut = 85
vjut = 170 vjut = 170
@ -189,7 +189,7 @@ sb = 54
dotsize = 145 dotsize = 145
periodsize = 168 periodsize = 168
[shape-weight.blend.700] [shapeWeight.blend.700]
essx = 1.06 essx = 1.06
jut = 89 jut = 89
vjut = 179 vjut = 179
@ -203,7 +203,7 @@ sb = 50
dotsize = 157 dotsize = 157
periodsize = 180 periodsize = 180
[shape-weight.blend.800] [shapeWeight.blend.800]
essx = 1.05 essx = 1.05
jut = 96 jut = 96
vjut = 189 vjut = 189
@ -217,7 +217,7 @@ sb = 45
dotsize = 167 dotsize = 167
periodsize = 188 periodsize = 188
[shape-weight.blend.900] [shapeWeight.blend.900]
essx = 1.03 essx = 1.03
jut = 100 jut = 100
vjut = 199 vjut = 199

View file

@ -1,5 +1,5 @@
const { app, BrowserWindow } = require("electron"); const { app, BrowserWindow } = require("electron");
let argv = require("yargs").argv; let argDir = process.argv[2];
let fs = require("fs"); let fs = require("fs");
let cp = require("child_process"); let cp = require("child_process");
@ -52,7 +52,7 @@ const phases = {
pendingTasks += 1; pendingTasks += 1;
console.log("Received rect."); console.log("Received rect.");
rect = JSON.parse(JSON.stringify(rect)); rect = JSON.parse(JSON.stringify(rect));
let file = argv.dir + "/" + rect.name + ".png"; let file = argDir + "/" + rect.name + ".png";
let j = 0; let j = 0;
let totalFiles = Math.ceil(rect.height / rect.windowHeight); let totalFiles = Math.ceil(rect.height / rect.windowHeight);
let pendingFiles = totalFiles; let pendingFiles = totalFiles;
@ -63,7 +63,7 @@ const phases = {
if (pendingFiles <= 0) { if (pendingFiles <= 0) {
let images = []; let images = [];
for (let k = 0; k < j; k++) { for (let k = 0; k < j; k++) {
images.push(argv.dir + "/" + rect.name + "." + k + ".png"); images.push(argDir + "/" + rect.name + "." + k + ".png");
} }
combineImages( combineImages(
images, images,
@ -79,7 +79,7 @@ const phases = {
GOTO(function (event) { GOTO(function (event) {
mainWindow.capturePage().then(function (image) { mainWindow.capturePage().then(function (image) {
fs.writeFile( fs.writeFile(
argv.dir + "/" + rect.name + "." + j + ".png", argDir + "/" + rect.name + "." + j + ".png",
image.toPNG(), image.toPNG(),
doneFileWrite doneFileWrite
); );

View file

@ -24,7 +24,7 @@ const GENERATE = ["node", "gen/generator"];
const webfontFormats = [ const webfontFormats = [
["woff2", "woff2"], ["woff2", "woff2"],
["woff", "woff"], ["woff", "woff"],
["ttf", "truetype"], ["ttf", "truetype"]
]; ];
const BUILD_PLANS = path.relative(__dirname, path.resolve(__dirname, "./build-plans.toml")); const BUILD_PLANS = path.relative(__dirname, path.resolve(__dirname, "./build-plans.toml"));
@ -59,7 +59,7 @@ async function tryParseToml(str) {
} }
} }
const RawPlans = oracle(`metadata:raw-plans`, async (target) => { const RawPlans = oracle(`metadata:raw-plans`, async target => {
await target.need(sfu(BUILD_PLANS), ofu(PRIVATE_BUILD_PLANS)); await target.need(sfu(BUILD_PLANS), ofu(PRIVATE_BUILD_PLANS));
const bp = await tryParseToml(BUILD_PLANS); const bp = await tryParseToml(BUILD_PLANS);
@ -91,31 +91,31 @@ const RawPlans = oracle(`metadata:raw-plans`, async (target) => {
return bp; return bp;
}); });
const BuildPlans = computed("metadata:build-plans", async (target) => { const BuildPlans = computed("metadata:build-plans", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.buildPlans; return rp.buildPlans;
}); });
const ExportPlans = computed("metadata:export-plans", async (target) => { const ExportPlans = computed("metadata:export-plans", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.exportPlans; return rp.exportPlans;
}); });
const RawCollectPlans = computed("metadata:raw-collect-plans", async (target) => { const RawCollectPlans = computed("metadata:raw-collect-plans", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.collectPlans; return rp.collectPlans;
}); });
const Weights = computed("metadata:global-weights", async (target) => { const Weights = computed("metadata:global-weights", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.weights; return rp.weights;
}); });
const Slants = computed("metadata:global-slants", async (target) => { const Slants = computed("metadata:global-slants", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.slants; return rp.slants;
}); });
const Widths = computed("metadata:global-widths", async (target) => { const Widths = computed("metadata:global-widths", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.widths; return rp.widths;
}); });
const CollectConfig = computed("metadata:collect-config", async (target) => { const CollectConfig = computed("metadata:collect-config", async target => {
const [rp] = await target.need(RawPlans); const [rp] = await target.need(RawPlans);
return rp.collectConfig; return rp.collectConfig;
}); });
@ -158,7 +158,7 @@ const recommendedMenuWeights = {
semibold: 600, semibold: 600,
bold: 700, bold: 700,
extrabold: 800, extrabold: 800,
heavy: 900, heavy: 900
}; };
function validateRecommendedWeight(w, value, label) { function validateRecommendedWeight(w, value, label) {
if (recommendedMenuWeights[w] && recommendedMenuWeights[w] !== value) { if (recommendedMenuWeights[w] && recommendedMenuWeights[w] !== value) {
@ -178,7 +178,7 @@ function getSuffixSet(weights, slants, widths) {
for (const wd in widths) { for (const wd in widths) {
const suffix = makeSuffix(w, wd, s, "regular"); const suffix = makeSuffix(w, wd, s, "regular");
mapping[suffix] = { mapping[suffix] = {
hives: [`shape-weight`, `s-${s}`, `wd-${widths[wd].shape}`], hives: [`shapeWeight`, `s-${s}`, `wd-${widths[wd].shape}`],
weight: w, weight: w,
shapeWeight: nValidate("Shape weight of " + w, weights[w].shape, vlShapeWeight), shapeWeight: nValidate("Shape weight of " + w, weights[w].shape, vlShapeWeight),
cssWeight: nValidate("CSS weight of " + w, weights[w].css, vlCssWeight), cssWeight: nValidate("CSS weight of " + w, weights[w].css, vlCssWeight),
@ -189,7 +189,7 @@ function getSuffixSet(weights, slants, widths) {
menuWidth: nValidate("Menu width of " + wd, widths[wd].menu, vlMenuWidth), menuWidth: nValidate("Menu width of " + wd, widths[wd].menu, vlMenuWidth),
slant: s, slant: s,
cssStyle: slants[s] || s, cssStyle: slants[s] || s,
menuStyle: slants[s] || s, menuSlant: slants[s] || s
}; };
} }
} }
@ -197,12 +197,12 @@ function getSuffixSet(weights, slants, widths) {
return mapping; return mapping;
} }
const Suffixes = computed(`metadata:suffixes`, async (target) => { const Suffixes = computed(`metadata:suffixes`, async target => {
const [weights, slants, widths] = await target.need(Weights, Slants, Widths); const [weights, slants, widths] = await target.need(Weights, Slants, Widths);
return getSuffixSet(weights, slants, widths); return getSuffixSet(weights, slants, widths);
}); });
const FontBuildingParameters = computed(`metadata:font-building-parameters`, async (target) => { const FontBuildingParameters = computed(`metadata:font-building-parameters`, async target => {
const [buildPlans, defaultWeights, defaultSlants, defaultWidths] = await target.need( const [buildPlans, defaultWeights, defaultSlants, defaultWidths] = await target.need(
BuildPlans, BuildPlans,
Weights, Weights,
@ -233,18 +233,18 @@ const FontBuildingParameters = computed(`metadata:font-building-parameters`, asy
shapeWidth: suffixMapping[suffix].shapeWidth, shapeWidth: suffixMapping[suffix].shapeWidth,
menuWeight: suffixMapping[suffix].menuWeight, menuWeight: suffixMapping[suffix].menuWeight,
menuWidth: suffixMapping[suffix].menuWidth, menuWidth: suffixMapping[suffix].menuWidth,
menuStyle: suffixMapping[suffix].menuStyle, menuSlant: suffixMapping[suffix].menuSlant,
cssWeight: suffixMapping[suffix].cssWeight, cssWeight: suffixMapping[suffix].cssWeight,
cssStretch: suffixMapping[suffix].cssStretch, cssStretch: suffixMapping[suffix].cssStretch,
cssStyle: suffixMapping[suffix].cssStyle, cssStyle: suffixMapping[suffix].cssStyle,
hintParams: hintParams || [], hintParams: hintParams || []
}; };
targets.push(fileName); targets.push(fileName);
} }
bp[prefix] = { bp[prefix] = {
family, family,
prefix, prefix,
targets, targets
}; };
} }
return { fontInfos, buildPlans: bp }; return { fontInfos, buildPlans: bp };
@ -292,7 +292,7 @@ function fnStandardTtc(collectConfig, prefix, w, wd, s) {
return `${prefix}-${ttcSuffix}`; return `${prefix}-${ttcSuffix}`;
} }
const CollectPlans = computed(`metadata:collect-plans`, async (target) => { const CollectPlans = computed(`metadata:collect-plans`, async target => {
const [rawCollectPlans, suffixMapping, collectConfig] = await target.need( const [rawCollectPlans, suffixMapping, collectConfig] = await target.need(
RawCollectPlans, RawCollectPlans,
Suffixes, Suffixes,
@ -345,24 +345,23 @@ const BuildTTF = file.make(
(gr, fn) => `${BUILD}/${gr}/${fn}.ttf`, (gr, fn) => `${BUILD}/${gr}/${fn}.ttf`,
async (target, output, _gr, fn) => { async (target, output, _gr, fn) => {
const [ const [
{ hives, family, shapeWeight, menuWeight, menuStyle, menuWidth }, { hives, family, shapeWeight, menuWeight, menuSlant, menuWidth },
version, version
] = await target.need(HivesOf(fn), Version); ] = await target.need(HivesOf(fn), Version);
const otdTmp = output.dir + "/" + output.name + ".tmp.otd"; const otdTmp = output.dir + "/" + output.name + ".tmp.otd";
const charmap = output.dir + "/" + output.name + ".charmap"; const charmap = output.dir + "/" + output.name + ".charmap";
await target.need(Scripts, fu`parameters.toml`, de`${output.dir}`); await target.need(Scripts, fu`parameters.toml`, de`${output.dir}`);
await run( await node("gen/index", {
GENERATE, o: otdTmp,
["-o", otdTmp], charmap,
["--charmap", charmap], family,
["--family", family], version,
["--ver", version], shapeWeight,
["--shape-weight", shapeWeight], menuWeight,
["--menu-weight", menuWeight], menuSlant,
["--menu-slant", menuStyle], menuWidth,
["--menu-width", menuWidth],
hives hives
); });
await run( await run(
"otfccbuild", "otfccbuild",
otdTmp, otdTmp,
@ -423,23 +422,23 @@ const DistTTC = file.make(
} }
); );
const SuperTTC = file.make( const SuperTTC = file.make(
(f) => `${DIST}/super-ttc/${f}.ttc`, f => `${DIST}/super-ttc/${f}.ttc`,
async (target, out, f) => { async (target, out, f) => {
await target.need(de(out.dir)); await target.need(de(out.dir));
const [inputs] = await target.need(CollectionFontsOf(f)); const [inputs] = await target.need(CollectionFontsOf(f));
await run( await run(
OTF2OTC, OTF2OTC,
["-o", out.full], ["-o", out.full],
inputs.map((f) => f.full) inputs.map(f => f.full)
); );
} }
); );
async function buildTtcForFile(target, parts, out, xMode) { async function buildTtcForFile(target, parts, out, xMode) {
await target.need(de`${out.dir}`); await target.need(de`${out.dir}`);
const [ttfs] = await target.need(parts.map((part) => DistHintedTTF(part.dir, part.file))); const [ttfs] = await target.need(parts.map(part => DistHintedTTF(part.dir, part.file)));
await run( await run(
TTCIZE, TTCIZE,
ttfs.map((p) => p.full), ttfs.map(p => p.full),
["-o", out.full], ["-o", out.full],
[xMode ? "-x" : "-h", "--common-width=500"] [xMode ? "-x" : "-h", "--common-width=500"]
); );
@ -448,36 +447,27 @@ async function buildTtcForFile(target, parts, out, xMode) {
// Group-level // Group-level
const GroupTTFs = task.group("ttf", async (target, gid) => { const GroupTTFs = task.group("ttf", async (target, gid) => {
const [ts] = await target.need(GroupFontsOf(gid)); const [ts] = await target.need(GroupFontsOf(gid));
await target.need(ts.map((tn) => DistHintedTTF(gid, tn))); await target.need(ts.map(tn => DistHintedTTF(gid, tn)));
}); });
const GroupUnhintedTTFs = task.group("ttf-unhinted", async (target, gid) => { const GroupUnhintedTTFs = task.group("ttf-unhinted", async (target, gid) => {
const [ts] = await target.need(GroupFontsOf(gid)); const [ts] = await target.need(GroupFontsOf(gid));
await target.need(ts.map((tn) => DistUnhintedTTF(gid, tn))); await target.need(ts.map(tn => DistUnhintedTTF(gid, tn)));
}); });
const GroupWoffs = task.group("woff", async (target, gid) => { const GroupWoffs = task.group("woff", async (target, gid) => {
const [ts] = await target.need(GroupFontsOf(gid)); const [ts] = await target.need(GroupFontsOf(gid));
await target.need(ts.map((tn) => DistWoff(gid, tn))); await target.need(ts.map(tn => DistWoff(gid, tn)));
}); });
const GroupWoff2s = task.group("woff2", async (target, gid) => { const GroupWoff2s = task.group("woff2", async (target, gid) => {
const [ts] = await target.need(GroupFontsOf(gid)); const [ts] = await target.need(GroupFontsOf(gid));
await target.need(ts.map((tn) => DistWoff2(gid, tn))); await target.need(ts.map(tn => DistWoff2(gid, tn)));
}); });
const GroupFonts = task.group("fonts", async (target, gid) => { const GroupFonts = task.group("fonts", async (target, gid) => {
await target.need(GroupTTFs(gid), GroupUnhintedTTFs(gid), GroupWoffs(gid), GroupWoff2s(gid)); await target.need(GroupTTFs(gid), GroupUnhintedTTFs(gid), GroupWoffs(gid), GroupWoff2s(gid));
}); });
// Charmap (for specimen)
const DistCharMaps = file.make(
(gid, suffix) => `${DIST}/${gid}/${suffix}.charmap`,
async (target, { full, dir }, gid, suffix) => {
const [src] = await target.need(BuildCM(gid, suffix), de`${dir}`);
await cp(src.full, full);
}
);
// Webfont CSS // Webfont CSS
const DistWebFontCSS = file.make( const DistWebFontCSS = file.make(
(gid) => `${DIST}/${gid}/webfont.css`, gid => `${DIST}/${gid}/webfont.css`,
async (target, { dir }, gid) => { async (target, { dir }, gid) => {
// Note: this target does NOT depend on the font files. // Note: this target does NOT depend on the font files.
const [gr, ts] = await target.need(GroupInfo(gid), GroupFontsOf(gid), de(dir)); const [gr, ts] = await target.need(GroupInfo(gid), GroupFontsOf(gid), de(dir));
@ -493,12 +483,7 @@ const DistWebFontCSS = file.make(
); );
const GroupContents = task.group("contents", async (target, gid) => { const GroupContents = task.group("contents", async (target, gid) => {
const [gr] = await target.need(GroupInfo(gid)); await target.need(GroupFonts(gid), DistWebFontCSS(gid));
await target.need(
GroupFonts(gid),
DistWebFontCSS(gid),
DistCharMaps(gid, `${gr.prefix}-regular`)
);
return gid; return gid;
}); });
@ -525,7 +510,7 @@ const GroupArchives = task.group(`archive`, async (target, gid) => {
// Collection-level // Collection-level
const CollectionFontsOf = task.group("collection-fonts", async (target, cid) => { const CollectionFontsOf = task.group("collection-fonts", async (target, cid) => {
const [{ groups }] = await target.need(CollectPlans); const [{ groups }] = await target.need(CollectPlans);
const [files] = await target.need(groups[cid].map((file) => DistTTC(cid, file))); const [files] = await target.need(groups[cid].map(file => DistTTC(cid, file)));
return files; return files;
}); });
const TTCArchiveFile = file.make( const TTCArchiveFile = file.make(
@ -552,7 +537,7 @@ const CollectionArchive = task.group(`collection-archive`, async (target, cid) =
////// Root Tasks ////// ////// Root Tasks //////
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
const PagesDir = oracle(`pages-dir-path`, async (target) => { const PagesDir = oracle(`pages-dir-path`, async target => {
const pagesDir = path.resolve(__dirname, "../Iosevka-Pages"); const pagesDir = path.resolve(__dirname, "../Iosevka-Pages");
if (!fs.existsSync(pagesDir)) { if (!fs.existsSync(pagesDir)) {
return ""; return "";
@ -561,12 +546,12 @@ const PagesDir = oracle(`pages-dir-path`, async (target) => {
} }
}); });
const PagesDataExport = task(`pages:data-export`, async (target) => { const PagesDataExport = task(`pages:data-export`, async target => {
target.is.volatile(); target.is.volatile();
const [version, pagesDir] = await target.need(Version, PagesDir); const [version, pagesDir] = await target.need(Version, PagesDir);
if (!pagesDir) return; if (!pagesDir) return;
await target.need(sfu`variants.toml`, sfu`ligation-set.toml`, UtilScripts); await target.need(sfu`variants.toml`, sfu`ligation-set.toml`, UtilScripts);
const [cm] = await target.need(DistCharMaps("iosevka", "iosevka-regular")); const [cm] = await target.need(BuildCM("iosevka", "iosevka-regular"));
await run( await run(
`node`, `node`,
`utility/export-data/index`, `utility/export-data/index`,
@ -575,7 +560,7 @@ const PagesDataExport = task(`pages:data-export`, async (target) => {
); );
}); });
const PagesFontExport = task(`pages:font-export`, async (target) => { const PagesFontExport = task(`pages:font-export`, async target => {
const [pagesDir] = await target.need(PagesDir); const [pagesDir] = await target.need(PagesDir);
if (!pagesDir) return; if (!pagesDir) return;
const dirs = await target.need( const dirs = await target.need(
@ -590,7 +575,7 @@ const PagesFontExport = task(`pages:font-export`, async (target) => {
} }
}); });
const PagesFastFontExport = task(`pages:fast-font-export`, async (target) => { const PagesFastFontExport = task(`pages:fast-font-export`, async target => {
const [pagesDir] = await target.need(PagesDir); const [pagesDir] = await target.need(PagesDir);
if (!pagesDir) return; if (!pagesDir) return;
const dirs = await target.need(GroupContents`iosevka`); const dirs = await target.need(GroupContents`iosevka`);
@ -599,14 +584,14 @@ const PagesFastFontExport = task(`pages:fast-font-export`, async (target) => {
} }
}); });
const Pages = task(`pages`, async (target) => { const Pages = task(`pages`, async target => {
await target.need(PagesDataExport, PagesFontExport); await target.need(PagesDataExport, PagesFontExport);
}); });
const PagesFast = task(`pages-fast`, async (target) => { const PagesFast = task(`pages-fast`, async target => {
await target.need(PagesDataExport, PagesFastFontExport); await target.need(PagesDataExport, PagesFastFontExport);
}); });
const SampleImagesPre = task(`sample-images:pre`, async (target) => { const SampleImagesPre = task(`sample-images:pre`, async target => {
const [sans, slab] = await target.need( const [sans, slab] = await target.need(
GroupContents`iosevka`, GroupContents`iosevka`,
GroupContents`iosevka-slab`, GroupContents`iosevka-slab`,
@ -617,9 +602,9 @@ const SampleImagesPre = task(`sample-images:pre`, async (target) => {
await cp(`${DIST}/${sans}`, `snapshot/${sans}`); await cp(`${DIST}/${sans}`, `snapshot/${sans}`);
await cp(`${DIST}/${slab}`, `snapshot/${slab}`); await cp(`${DIST}/${slab}`, `snapshot/${slab}`);
}); });
const SnapShotHtml = file(`snapshot/index.html`, async (target) => { const SnapShotHtml = file(`snapshot/index.html`, async target => {
const [cm] = await target.need( const [cm] = await target.need(
DistCharMaps("iosevka", "iosevka-regular"), BuildCM("iosevka", "iosevka-regular"),
sfu`variants.toml`, sfu`variants.toml`,
sfu`ligation-set.toml`, sfu`ligation-set.toml`,
UtilScripts UtilScripts
@ -627,20 +612,20 @@ const SnapShotHtml = file(`snapshot/index.html`, async (target) => {
await run(`node`, `utility/generate-snapshot-page/index.js`); await run(`node`, `utility/generate-snapshot-page/index.js`);
await run(`node`, `utility/amend-readme/index`, cm.full); await run(`node`, `utility/amend-readme/index`, cm.full);
}); });
const SnapShotCSS = file(`snapshot/index.css`, async (target) => { const SnapShotCSS = file(`snapshot/index.css`, async target => {
await target.need(sfu`snapshot/index.styl`); await target.need(sfu`snapshot/index.styl`);
await run(`npx`, `stylus`, `snapshot/index.styl`, `-c`); await run(`npx`, `stylus`, `snapshot/index.styl`, `-c`);
}); });
const TakeSampleImages = task(`sample-images:take`, async (target) => { const TakeSampleImages = task(`sample-images:take`, async target => {
await target.need(SampleImagesPre); await target.need(SampleImagesPre);
await cd(`snapshot`).run("npx", "electron", "get-snap.js", ["--dir", "../images"]); await cd(`snapshot`).run("npx", "electron", "get-snap.js", "../images");
}); });
const ScreenShot = file.glob(`images/*.png`, async (target, { full }) => { const ScreenShot = file.glob(`images/*.png`, async (target, { full }) => {
await target.need(TakeSampleImages); await target.need(TakeSampleImages);
await run("optipng", full); await run("optipng", full);
}); });
const SampleImages = task(`sample-images`, async (target) => { const SampleImages = task(`sample-images`, async target => {
await target.need(TakeSampleImages); await target.need(TakeSampleImages);
await target.need( await target.need(
ScreenShot`images/charvars.png`, ScreenShot`images/charvars.png`,
@ -653,7 +638,7 @@ const SampleImages = task(`sample-images`, async (target) => {
); );
}); });
const AllArchives = task(`all:archives`, async (target) => { const AllArchives = task(`all:archives`, async target => {
const [exportPlans, collectPlans] = await target.need(ExportPlans, CollectPlans); const [exportPlans, collectPlans] = await target.need(ExportPlans, CollectPlans);
await target.need( await target.need(
Object.keys(exportPlans).map(GroupArchives), Object.keys(exportPlans).map(GroupArchives),
@ -661,12 +646,12 @@ const AllArchives = task(`all:archives`, async (target) => {
); );
}); });
const AllTtfArchives = task(`all:ttf`, async (target) => { const AllTtfArchives = task(`all:ttf`, async target => {
const [exportPlans] = await target.need(ExportPlans); const [exportPlans] = await target.need(ExportPlans);
await target.need(Object.keys(exportPlans).map(GroupArchives)); await target.need(Object.keys(exportPlans).map(GroupArchives));
}); });
const AllTtcArchives = task(`all:ttc`, async (target) => { const AllTtcArchives = task(`all:ttc`, async target => {
const [collectPlans] = await target.need(CollectPlans); const [collectPlans] = await target.need(CollectPlans);
await target.need(Object.keys(collectPlans.groups).map(CollectionArchive)); await target.need(Object.keys(collectPlans.groups).map(CollectionArchive));
}); });
@ -674,17 +659,17 @@ const AllTtcArchives = task(`all:ttc`, async (target) => {
const SpecificSuperTtc = task.group(`super-ttc`, async (target, gr) => { const SpecificSuperTtc = task.group(`super-ttc`, async (target, gr) => {
await target.need(SuperTTC(gr)); await target.need(SuperTTC(gr));
}); });
const AllSuperTtc = task(`all:super-ttc`, async (target) => { const AllSuperTtc = task(`all:super-ttc`, async target => {
const [collectPlans] = await target.need(CollectPlans); const [collectPlans] = await target.need(CollectPlans);
await target.need(Object.keys(collectPlans.groups).map((gr) => SuperTTC(gr))); await target.need(Object.keys(collectPlans.groups).map(gr => SuperTTC(gr)));
}); });
const ChangeFileList = oracle.make( const ChangeFileList = oracle.make(
() => `release:change-file-list`, () => `release:change-file-list`,
(target) => FileList({ under: "changes", pattern: "*.md" })(target) target => FileList({ under: "changes", pattern: "*.md" })(target)
); );
const ReleaseNotesFile = file.make( const ReleaseNotesFile = file.make(
(version) => `${ARCHIVE_DIR}/release-notes-${version}.md`, version => `${ARCHIVE_DIR}/release-notes-${version}.md`,
async (t, out, version) => { async (t, out, version) => {
await t.need(UtilScripts, de(ARCHIVE_DIR)); await t.need(UtilScripts, de(ARCHIVE_DIR));
const [changeFiles] = await t.need(ChangeFileList()); const [changeFiles] = await t.need(ChangeFileList());
@ -692,7 +677,7 @@ const ReleaseNotesFile = file.make(
await run("node", "utility/generate-release-note/index", version, out.full); await run("node", "utility/generate-release-note/index", version, out.full);
} }
); );
const ReleaseNotes = task(`release:release-note`, async (t) => { const ReleaseNotes = task(`release:release-note`, async t => {
const [version] = await t.need(Version); const [version] = await t.need(Version);
await t.need(ReleaseNotesFile(version)); await t.need(ReleaseNotesFile(version));
}); });
@ -703,7 +688,7 @@ phony(`clean`, async () => {
await rm(`release-archives`); await rm(`release-archives`);
build.deleteJournal(); // Disable journal build.deleteJournal(); // Disable journal
}); });
phony(`release`, async (target) => { phony(`release`, async target => {
await target.need(AllArchives, AllSuperTtc); await target.need(AllArchives, AllSuperTtc);
await target.need(SampleImages, Pages); await target.need(SampleImages, Pages);
await target.need(ReleaseNotes); await target.need(ReleaseNotes);
@ -718,7 +703,7 @@ const ScriptsUnder = oracle.make(
(ext, dir) => `${ext}-scripts-under::${dir}`, (ext, dir) => `${ext}-scripts-under::${dir}`,
(target, ext, dir) => FileList({ under: dir, pattern: `**/*.${ext}` })(target) (target, ext, dir) => FileList({ under: dir, pattern: `**/*.${ext}` })(target)
); );
const UtilScriptFiles = computed("util-script-files", async (target) => { const UtilScriptFiles = computed("util-script-files", async target => {
const [js, ejs, md] = await target.need( const [js, ejs, md] = await target.need(
ScriptsUnder("js", "utility"), ScriptsUnder("js", "utility"),
ScriptsUnder("ejs", "utility"), ScriptsUnder("ejs", "utility"),
@ -736,9 +721,9 @@ const ScriptFiles = computed.group("script-files", async (target, ext) => {
); );
return ss.reduce((a, b) => [...a, ...b]); return ss.reduce((a, b) => [...a, ...b]);
}); });
const JavaScriptFromPtl = computed("scripts-js-from-ptl", async (target) => { const JavaScriptFromPtl = computed("scripts-js-from-ptl", async target => {
const [ptl] = await target.need(ScriptFiles("ptl")); const [ptl] = await target.need(ScriptFiles("ptl"));
return ptl.map((x) => x.replace(/\.ptl$/g, ".js")); return ptl.map(x => x.replace(/\.ptl$/g, ".js"));
}); });
const ScriptJS = file.glob(`{gen|glyphs|meta|otl|support}/**/*.js`, async (target, path) => { const ScriptJS = file.glob(`{gen|glyphs|meta|otl|support}/**/*.js`, async (target, path) => {
@ -754,14 +739,14 @@ const ScriptJS = file.glob(`{gen|glyphs|meta|otl|support}/**/*.js`, async (targe
await target.need(fu`${path.full}`); await target.need(fu`${path.full}`);
} }
}); });
const Scripts = task("scripts", async (target) => { const Scripts = task("scripts", async target => {
await target.need(sfu`parameters.toml`, sfu`variants.toml`, sfu`ligation-set.toml`); await target.need(sfu`parameters.toml`, sfu`variants.toml`, sfu`ligation-set.toml`);
const [jsFromPtl] = await target.need(JavaScriptFromPtl); const [jsFromPtl] = await target.need(JavaScriptFromPtl);
await target.need(jsFromPtl); await target.need(jsFromPtl);
const [js] = await target.need(ScriptFiles("js")); const [js] = await target.need(ScriptFiles("js"));
await target.need(js.map(ScriptJS)); await target.need(js.map(ScriptJS));
}); });
const UtilScripts = task("util-scripts", async (target) => { const UtilScripts = task("util-scripts", async target => {
const [files] = await target.need(UtilScriptFiles); const [files] = await target.need(UtilScriptFiles);
await target.need(files.map((f) => fu`${f}`)); await target.need(files.map(f => fu`${f}`));
}); });