Skip to content

Commit

Permalink
Initial commit with content
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Sep 26, 2017
1 parent 8961c9a commit d3152f8
Show file tree
Hide file tree
Showing 34 changed files with 5,493 additions and 59 deletions.
82 changes: 23 additions & 59 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1,23 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

bin/
build/
node_modules/
references/
doc/
preview/test-fonts
.typeSXS_public
*.7z
*.zip
*.log
*.exe
*.aux
*.fls
*.toc
*.out
*.fdb_latexmk
*.pdf
**.DS_Store
**/*.packed.js
ns-proof-page/fonts
hint/build
hint/source/fonts
hint/out
191 changes: 191 additions & 0 deletions bddy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
"use strict";

const fs = require("fs-extra");

const CVT_PADDING = 300;

function objToArgs(o) {
let a = [];
for (let k in o) {
if (o[k] === false) continue;
if (k.length === 1) {
a.push("-" + k);
} else {
a.push("--" + k);
}
if (o[k] !== true) {
a.push("" + o[k]);
}
}
return a;
}

async function runBuildTask(recipe, args) {
return await this.run("node", "run", "--recipe", recipe, ...objToArgs(args));
}

async function sanitize(target, ttf) {
const tmpTTX = `${ttf}.ttx`;
const tmpTTF2 = `${ttf}.2.ttf`;
await this.run("ttx", "-o", tmpTTX, ttf);
await this.run("ttx", "-o", tmpTTF2, tmpTTX);
await this.run("ttfautohint", tmpTTF2, target);
await this.rm(ttf, tmpTTX, tmpTTF2);
}

const STYLE_FILENAME_OF = {
regular: "regular",
bold: "bold",
italic: "italic",
bolditalic: "bolditalic"
};

const STYLE_OF = {
regular: "Regular",
bold: "Bold",
italic: "Italic",
bolditalic: "BoldItalic"
};

const FAMILY_OF = {
cl: "cl",
sc: "sc",
tc: "tc",
j: "j"
};
function styleOf(set) {
return (set + "")
.split("-")
.map(w => STYLE_FILENAME_OF[w])
.filter(w => w)[0];
}
function familyOf(set) {
return (set + "")
.split("-")
.map(w => FAMILY_OF[w])
.filter(w => w)[0];
}

const DEITALIC = {
italic: "regular",
bolditalic: "bold"
};
function deItalizedNameOf(set) {
return (set + "")
.split("-")
.map(w => DEITALIC[w] || w)
.join("-");
}

module.exports = function(ctx, forany, argv, bddy) {
forany.file(`build`).def(ctx.ensureDir);
forany.file(`build/kanji0`).def(ctx.ensureDir);
forany.file(`build/punct0`).def(ctx.ensureDir);
forany.file(`build/pass0`).def(ctx.ensureDir);
forany.file(`build/pass1`).def(ctx.ensureDir);
forany.file(`build/out`).def(ctx.ensureDir);

forany.file(`build/out/*.ttf`).def(async function(target) {
await this.check(`${target.dir}`);
const rawName = target.name.replace(/^sarasa-/g, "");
const [$1, $2] = await this.need(
`build/pass1/${rawName}.ttf`,
`hint/out/${deItalizedNameOf(rawName)}.ttf`
);
const tmpOTD = `${target.dir}/${rawName}.otd`;
await runBuildTask.call(this, "build-pass2/build.js", {
main: $1,
kanji: $2,
o: tmpOTD,
style: STYLE_OF[styleOf(rawName)],
subfamily: familyOf(rawName).toUpperCase(),
italize: deItalizedNameOf(rawName) === rawName ? false : true
});
await this.run("otfccbuild", tmpOTD, "-o", target, "--keep-average-char-width", "-O3");
await this.rm(tmpOTD);
});
forany.file(`build/pass1/*.ttf`).def(async function(target) {
await this.check(`${target.dir}`);
const [$1, $2] = await this.need(
`sources/iosevka/iosevka-${styleOf(target.name)}.ttf`,
`build/punct0/${deItalizedNameOf(target.name)}.ttf`
);
await runBuildTask.call(this, "build-pass1/build.js", {
main: $1,
asian: $2,
o: target + ".tmp.ttf",
italize: deItalizedNameOf(target.name) === target.name ? false : true
});
await sanitize.call(this, target, target + ".tmp.ttf");
});
forany.file(`build/punct0/*.ttf`).def(async function(target) {
await this.check(`${target.dir}`);
const [$1] = await this.need(`sources/shs/${target.name}.otf`);
const tmpOTD = `${target.dir}/${target.name}.otd`;
await runBuildTask.call(this, "build-punct/build.js", { main: $1, o: tmpOTD });
await this.run("otfccbuild", tmpOTD, "-o", target);
await this.rm(tmpOTD);
});

// kanji tasks
forany.file(`hint/out/*.ttf`).def(async function(target) {
await this.need("hint-finish");
});
forany.virt("hint-finish").def(async function(target) {
await this.need("hint-start");
await this.cd("hint").runInteractive("node", "top", "hint");
});
forany.virt("hint-start").def(async function(target) {
let dependents = [];
const wSet = new Set();
for (let st in STYLE_FILENAME_OF) {
wSet.add(deItalizedNameOf(st));
}

const config = {
settings: {
do_ttfautohint: false,
cvt_padding: CVT_PADDING,
use_externalIDH: false,
use_VTTShell: false
},
fonts: []
};

for (let st of wSet)
for (let sf in FAMILY_OF) {
dependents.push(`hint/source/fonts/${sf}-${st}.ttf`);
config.fonts.push({
input: `source/fonts/${sf}-${st}.ttf`,
param: `source/parameters/${st}.toml`,
allchar: true
});
}
await this.need(...dependents);
await fs.writeFile("hint/source/fonts.json", JSON.stringify(config, null, 2));
});
forany.file(`hint/source/fonts/*.ttf`).def(async function(target) {
const [$1] = await this.need(`build/kanji0/${target.name}.ttf`);
await this.cp($1, target);
});

forany.file(`build/kanji0/*.ttf`).def(async function(target) {
await this.check(`${target.dir}`);
const [$1] = await this.need(`sources/shs/${target.name}.otf`);
const tmpOTD = `${target.dir}/${target.name}.otd`;
await runBuildTask.call(this, "build-kanji/build.js", { main: $1, o: tmpOTD });
await this.run("otfccbuild", tmpOTD, "-o", target);
await this.rm(tmpOTD);
});

forany.virt("all").def(async function(target) {
let targets = [];

for (let sf in FAMILY_OF)
for (let st in STYLE_FILENAME_OF) {
targets.push(`build/out/sarasa-${sf}-${st}.ttf`);
}

await this.need(...targets);
});
};
26 changes: 26 additions & 0 deletions build-kanji/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use strict";

const { quadify, introduce, build, gc } = require("megaminx");
const { isKanji } = require("caryll-iddb");

async function pass(ctx, config, argv) {
const a = await ctx.run(introduce, "a", {
from: argv.main,
prefix: "a",
ignoreHints: true
});
for (let c in a.cmap) {
if (!isKanji(c - 0)) a.cmap[c] = null;
}
await ctx.run(quadify, "a");
a.cvt_ = [];
a.fpgm = [];
a.prep = [];
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);
};
37 changes: 37 additions & 0 deletions build-pass1/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"use strict";

const { quadify, introduce, build, gc, merge: { above: merge } } = require("megaminx");
const { isKanji } = require("caryll-iddb");
const italize = require("../common/italize");

async function pass(ctx, config, argv) {
const a = await ctx.run(introduce, "a", {
from: argv.main,
prefix: "a",
ignoreHints: true
});
const b = await ctx.run(introduce, "b", {
from: argv.asian,
prefix: "b",
ignoreHints: true
});

// vhea
a.vhea = b.vhea;
for (let g in a.glyf) {
a.glyf[g].verticalOrigin = a.head.unitsPerEm * 0.88;
a.glyf[g].advanceHeight = a.head.unitsPerEm;
}

// italize
if (argv.italize) italize(b, 10);

// merge and build
await ctx.run(merge, "a", "a", "b", { mergeOTL: true });
await ctx.run(gc, "a");
await ctx.run(build, "a", { to: config.o, optimize: true });
}

module.exports = async function makeFont(ctx, config, argv) {
await pass(ctx, { o: argv.o }, argv);
};
39 changes: 39 additions & 0 deletions build-pass2/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use strict";

const { quadify, introduce, build, gc, merge: { below: merge } } = require("megaminx");
const { isKanji } = require("caryll-iddb");
const italize = require("../common/italize");
const { nameFont } = require("./metadata.js");

async function pass(ctx, config, argv) {
const a = await ctx.run(introduce, "a", {
from: argv.main,
prefix: "a"
});
const b = await ctx.run(introduce, "b", {
from: argv.kanji,
prefix: "b"
});

// italize
if (argv.italize) italize(b, 10);
for (let j = 300; j < b.cvt_.length; j++) {
a.cvt_[j] = b.cvt_[j];
}

await ctx.run(merge, "a", "a", "b", { mergeOTL: true });
await ctx.run(gc, "a");
await ctx.run(nameFont, "a", {
en_US: {
copyright: "Copyright (c) 2017 Belleve Invis, et al.",
version: "0.1.0",
family: "Sarasa Gothic " + argv.subfamily,
style: argv.style
}
});
await ctx.run(build, "a", { to: config.o, optimize: true });
}

module.exports = async function makeFont(ctx, config, argv) {
await pass(ctx, { o: argv.o }, argv);
};
Loading

0 comments on commit d3152f8

Please sign in to comment.