Building: support custom optimization filter
This commit is contained in:
parent
43431f8ba8
commit
fbd8700c1f
3 changed files with 29 additions and 9 deletions
|
@ -13,7 +13,6 @@
|
||||||
},
|
},
|
||||||
"extends": ["eslint:recommended", "prettier"],
|
"extends": ["eslint:recommended", "prettier"],
|
||||||
"rules": {
|
"rules": {
|
||||||
"indent": ["error", "tab", { "SwitchCase": 1 }],
|
|
||||||
"semi": ["error", "always"],
|
"semi": ["error", "always"],
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
"no-console": 0,
|
"no-console": 0,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "iosevka",
|
"name": "iosevka",
|
||||||
"version": "3.2.0",
|
"version": "3.2.1",
|
||||||
"main": "./generate.js",
|
"main": "./generate.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "verda -f verdafile.js",
|
"build": "verda -f verdafile.js",
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
"ejs": "^3.1.3",
|
"ejs": "^3.1.3",
|
||||||
"fs-extra": "^9.0.0",
|
"fs-extra": "^9.0.0",
|
||||||
"object-assign": "^4.1.1",
|
"object-assign": "^4.1.1",
|
||||||
"otfcc-ttcize": "^0.10.1",
|
"otfcc-ttcize": "^0.10.2",
|
||||||
"patel": "^0.33.1",
|
"patel": "^0.33.1",
|
||||||
"semver": "^7.1.3",
|
"semver": "^7.1.3",
|
||||||
"spiro": "^2.0.0",
|
"spiro": "^2.0.0",
|
||||||
|
|
33
verdafile.js
33
verdafile.js
|
@ -92,6 +92,10 @@ const OptimizeWithTtx = computed("metadata:optimize-with-ttx", async target => {
|
||||||
const [hasTtx, rp] = await target.need(HasTtx, RawPlans);
|
const [hasTtx, rp] = await target.need(HasTtx, RawPlans);
|
||||||
return hasTtx && !!rp.buildOptions.optimizeWithTtx;
|
return hasTtx && !!rp.buildOptions.optimizeWithTtx;
|
||||||
});
|
});
|
||||||
|
const OptimizeWithFilter = computed("metadata:optimize-with-filter", async target => {
|
||||||
|
const [rp] = await target.need(RawPlans);
|
||||||
|
return rp.buildOptions.optimizeWithFilter;
|
||||||
|
});
|
||||||
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;
|
||||||
|
@ -392,7 +396,12 @@ function fnStandardTtc(collectConfig, prefix, w, wd, s) {
|
||||||
const BuildRawTtf = file.make(
|
const BuildRawTtf = file.make(
|
||||||
(gr, fn) => `${BUILD}/${gr}/${fn}.raw.ttf`,
|
(gr, fn) => `${BUILD}/${gr}/${fn}.raw.ttf`,
|
||||||
async (target, output, gr, fn) => {
|
async (target, output, gr, fn) => {
|
||||||
const [fi, useTtx] = await target.need(FontInfoOf(fn), OptimizeWithTtx, Version);
|
const [fi] = await target.need(
|
||||||
|
FontInfoOf(fn),
|
||||||
|
Version,
|
||||||
|
OptimizeWithFilter,
|
||||||
|
OptimizeWithTtx
|
||||||
|
);
|
||||||
const charmap = output.dir + "/" + fn + ".charmap";
|
const charmap = output.dir + "/" + fn + ".charmap";
|
||||||
await target.need(Scripts, Parameters, de`${output.dir}`);
|
await target.need(Scripts, Parameters, de`${output.dir}`);
|
||||||
const otdPath = `${output.dir}/${output.name}.otd`;
|
const otdPath = `${output.dir}/${output.name}.otd`;
|
||||||
|
@ -405,11 +414,18 @@ const BuildRawTtf = file.make(
|
||||||
const BuildTTF = file.make(
|
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 [useTtx] = await target.need(OptimizeWithTtx, de`${output.dir}`);
|
const [useFilter, useTtx] = await target.need(
|
||||||
|
OptimizeWithFilter,
|
||||||
|
OptimizeWithTtx,
|
||||||
|
de`${output.dir}`
|
||||||
|
);
|
||||||
await target.needed(FontInfoOf(fn), Version, Scripts, Parameters);
|
await target.needed(FontInfoOf(fn), Version, Scripts, Parameters);
|
||||||
|
|
||||||
const [rawTtf] = await target.order(BuildRawTtf(gr, fn));
|
const [rawTtf] = await target.order(BuildRawTtf(gr, fn));
|
||||||
if (useTtx) {
|
if (useFilter) {
|
||||||
|
const filterArgs = useFilter.split(/ +/g);
|
||||||
|
await run(filterArgs, rawTtf.full, output.full);
|
||||||
|
await rm(rawTtf.full);
|
||||||
|
} else if (useTtx) {
|
||||||
const ttxPath = `${output.dir}/${output.name}.temp.ttx`;
|
const ttxPath = `${output.dir}/${output.name}.temp.ttx`;
|
||||||
await run(TTX, "-q", ["-o", ttxPath], rawTtf.full);
|
await run(TTX, "-q", ["-o", ttxPath], rawTtf.full);
|
||||||
await rm(rawTtf.full);
|
await rm(rawTtf.full);
|
||||||
|
@ -531,11 +547,16 @@ async function buildCompositeTtc(out, inputs) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
async function buildGlyfTtc(target, parts, out) {
|
async function buildGlyfTtc(target, parts, out) {
|
||||||
const [useTtx] = await target.need(OptimizeWithTtx, de`${out.dir}`);
|
const [useFilter, useTtx] = await target.need(
|
||||||
|
OptimizeWithFilter,
|
||||||
|
OptimizeWithTtx,
|
||||||
|
de`${out.dir}`
|
||||||
|
);
|
||||||
const [ttfInputs] = await target.need(parts.map(part => BuildTTF(part.dir, part.file)));
|
const [ttfInputs] = await target.need(parts.map(part => BuildTTF(part.dir, part.file)));
|
||||||
const tmpTtc = `${out.dir}/${out.name}.unhinted.ttc`;
|
const tmpTtc = `${out.dir}/${out.name}.unhinted.ttc`;
|
||||||
const ttfInputPaths = ttfInputs.map(p => p.full);
|
const ttfInputPaths = ttfInputs.map(p => p.full);
|
||||||
await run(TTCIZE, ttfInputPaths, ["-o", tmpTtc], useTtx ? "--ttx-loop" : null);
|
const optimization = useFilter ? ["--filter-loop", useFilter] : useTtx ? ["--ttx-loop"] : [];
|
||||||
|
await run(TTCIZE, optimization, ["-o", tmpTtc], ttfInputPaths);
|
||||||
await run("ttfautohint", tmpTtc, out.full);
|
await run("ttfautohint", tmpTtc, out.full);
|
||||||
await rm(tmpTtc);
|
await rm(tmpTtc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue