Skip to content

Commit

Permalink
Add a intermediate pass to make building faster
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Nov 2, 2019
1 parent 899a6a5 commit 8509372
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
27 changes: 27 additions & 0 deletions make/non-kanji/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";

const { introduce, build, gc } = require("megaminx");
const { isIdeograph, isKorean, filterUnicodeRange } = require("../common/unicode-kind");

async function pass(ctx, config, argv) {
const a = await ctx.run(introduce, "a", {
from: argv.main,
prefix: "a",
ignoreHints: true
});
filterUnicodeRange(a, c => !isIdeograph(c) && !isKorean(c));
a.cvt_ = [];
a.fpgm = [];
a.prep = [];
if (!config.loclFeature) {
a.GSUB = null;
a.GPOS = null;
}
await ctx.run(gc, "a");
await ctx.run(build, "a", { to: config.o, optimize: true });
ctx.remove("a");
}

module.exports = async function makeFont(ctx, config, argv) {
await pass(ctx, { o: argv.o }, argv);
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.10.1",
"main": "./run",
"dependencies": {
"@chlorophytum/cli": "^0.3.0",
"@chlorophytum/cli": "^0.3.5",
"@chlorophytum/final-hint-format-hltt": "^0.3.0",
"@chlorophytum/font-format-otd": "^0.3.0",
"@chlorophytum/hint-store-provider-file": "^0.3.0",
Expand All @@ -17,7 +17,7 @@
"yargs": "^9.0.0"
},
"engines": {
"node": ">=12.13.0"
"node": ">=12.0.0"
},
"scripts": {
"install": "node checkenv",
Expand Down
27 changes: 22 additions & 5 deletions verdafile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const OTFCCDUMP = `otfccdump`;
const OTFCCBUILD = `otfccbuild`;
const OTF2TTF = `otf2ttf`;

const NPX_SUFFIX = os.platform() === "win32" ? ".cmd" : "";
const TTCIZE = "node_modules/.bin/otfcc-ttcize" + NPX_SUFFIX;
const Chlorophytum = [NODEJS, `./node_modules/@chlorophytum/cli/bin/_startup`];

///////////////////////////////////////////////////////////////////////////////////////////////////
// Entrypoint
const Start = phony("all", async t => {
Expand Down Expand Up @@ -106,11 +110,25 @@ const ShsOtd = file.make(
}
);

const NonKanji = file.make(
(region, style) => `${BUILD}/non-kanji0/${region}-${style}.ttf`,
async (t, { full, dir, name }, region, style) => {
await t.need(Config, Scripts);
const [$1] = await t.need(ShsOtd(region, style), de(dir));
const tmpOTD = `${dir}/${name}.otd`;
await RunFontBuildTask("make/non-kanji/build.js", {
main: $1.full,
o: tmpOTD
});
await OtfccBuildAsIs(tmpOTD, full);
}
);

const WS0 = file.make(
(family, region, style) => `${BUILD}/ws0/${family}-${region}-${style}.ttf`,
async (t, { full, dir, name }, family, region, style) => {
const [config] = await t.need(Config, Scripts);
const [, $1] = await t.need(de(dir), ShsOtd(region, style));
const [, $1] = await t.need(de(dir), NonKanji(region, style));
const tmpOTD = `${dir}/${name}.otd`;
await RunFontBuildTask("make/punct/ws.js", {
main: $1.full,
Expand All @@ -128,7 +146,7 @@ const AS0 = file.make(
(family, region, style) => `${BUILD}/as0/${family}-${region}-${style}.ttf`,
async (t, { full, dir, name }, family, region, style) => {
const [config] = await t.need(Config, Scripts);
const [, $1] = await t.need(de(dir), ShsOtd(region, style));
const [, $1] = await t.need(de(dir), NonKanji(region, style));
const tmpOTD = `${dir}/${name}.otd`;
await RunFontBuildTask("make/punct/as.js", {
main: $1.full,
Expand Down Expand Up @@ -224,7 +242,7 @@ const Prod = file.make(

///////////////////////////////////////////////////////////////////////////////////////////////////
// HINTING
const Chlorophytum = [NODEJS, `./node_modules/@chlorophytum/cli/lib/index.js`];

const HintDirPrefix = `${BUILD}/hf`;
const HintDirOutPrefix = `${BUILD}/hfo`;

Expand Down Expand Up @@ -384,9 +402,8 @@ const TTCFile = file.make(
}

const [$$] = await t.need(requirements.map(t => t.from));
const ttcize = "node_modules/.bin/otfcc-ttcize" + (os.platform() === "win32" ? ".cmd" : "");
await run(
ttcize,
TTCIZE,
["-x", "--common-width", 1000, "--common-height", 1000],
["-o", full],
[...$$.map(t => t.full)]
Expand Down

0 comments on commit 8509372

Please sign in to comment.