From b868e5da3a85b0405a179b7a3c3b87ccb867cc60 Mon Sep 17 00:00:00 2001 From: Zenvie <134689569+Zenvie@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:23:24 +0800 Subject: [PATCH] fix: check dependency when need --- checkenv.js | 1 - verdafile.mjs | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/checkenv.js b/checkenv.js index 928699f5f..0fe318bbe 100644 --- a/checkenv.js +++ b/checkenv.js @@ -11,4 +11,3 @@ function check(util) { check("otc2otf"); check("otf2ttf"); -check("ttfautohint"); diff --git a/verdafile.mjs b/verdafile.mjs index 07684b5de..a888772ee 100644 --- a/verdafile.mjs +++ b/verdafile.mjs @@ -22,6 +22,7 @@ const PROJECT_ROOT = url.fileURLToPath(new URL(".", import.meta.url)); const NODEJS = `node`; const SEVEN_ZIP = process.env.SEVEN_ZIP_PATH || "7z"; const OTC2OTF = `otc2otf`; +const TTFAUTOHINT = process.env.TTFAUTOHINT_PATH || "ttfautohint"; const TTC_BUNDLE = [ NODEJS, @@ -87,6 +88,14 @@ const Ttf = phony(`ttf`, async t => { await t.need(TtfFontFiles`TTF`, TtfFontFiles`TTF-Unhinted`); }); +const CheckTtfAutoHintExists = oracle("oracle:check-ttfautohint-exists", async target => { + try { + return await which(TTFAUTOHINT); + } catch (e) { + fail("External dependency , needed for building hinted font, does not exist."); + } +}); + const Dependencies = oracle("oracles::dependencies", async () => { const pkg = await fs.readJSON(path.resolve(PROJECT_ROOT, "package.json")); const depJson = {}; @@ -308,6 +317,7 @@ const LatinSource = file.make( if (isCff) { await run("otf2ttf", "-o", out.full, source.full); } else { + await t.need(CheckTtfAutoHintExists); await run("ttfautohint", "-d", source.full, out.full); } } @@ -352,7 +362,7 @@ const Pass1 = file.make( const Pass1Hinted = file.make( (family, region, style) => `${BUILD}/pass1-hinted/${family}-${region}-${style}.ttf`, async (t, out, family, region, style) => { - const [pass1] = await t.need(Pass1(family, region, style), de(out.dir)); + const [pass1] = await t.need(Pass1(family, region, style), CheckTtfAutoHintExists, de(out.dir)); await run("ttfautohint", pass1.full, out.full); } );