Caching code cleanup
This commit is contained in:
parent
e28ce0fd68
commit
edbe5ff47e
6 changed files with 68 additions and 31 deletions
|
@ -7,6 +7,7 @@ const zlib = require("zlib");
|
|||
const { FontIo } = require("ot-builder");
|
||||
const Toml = require("@iarna/toml");
|
||||
|
||||
const Caching = require("./caching/index");
|
||||
const BuildFont = require("./gen/build-font.js");
|
||||
const Parameters = require("./support/parameters");
|
||||
const VariantData = require("./support/variant-data");
|
||||
|
@ -16,26 +17,15 @@ const { createGrDisplaySheet } = require("./support/gr");
|
|||
module.exports = async function main(argv) {
|
||||
const paraT = await getParameters();
|
||||
|
||||
const ptCache = await loadPTCache(argv);
|
||||
const cache = await Caching.load(argv);
|
||||
|
||||
const { font, glyphStore } = await BuildFont(argv, paraT(argv), ptCache);
|
||||
const { font, glyphStore } = await BuildFont(cache, paraT(argv));
|
||||
if (argv.oCharMap) await saveCharMap(argv, glyphStore);
|
||||
if (argv.o) await saveTTF(argv, font);
|
||||
|
||||
await savePTCache(argv, ptCache);
|
||||
await Caching.save(argv, cache);
|
||||
};
|
||||
|
||||
async function loadPTCache(argv) {
|
||||
let ptCache = { source: {}, sink: {} };
|
||||
if (argv.ptCache && fs.existsSync(argv.ptCache)) {
|
||||
ptCache.source = unzip(await fs.readFile(argv.ptCache));
|
||||
}
|
||||
return ptCache;
|
||||
}
|
||||
async function savePTCache(argv, ptCache) {
|
||||
if (argv.ptCache) await fs.writeFile(argv.ptCache, zip(ptCache.sink));
|
||||
}
|
||||
|
||||
// Parameter preparation
|
||||
async function getParameters() {
|
||||
const PARAMETERS_TOML = path.resolve(__dirname, "../params/parameters.toml");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue