Skip to content

Commit

Permalink
sarasa: add TTC target, correct bold italic names
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Sep 27, 2017
1 parent b73b762 commit 7fe27e3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
31 changes: 24 additions & 7 deletions bddy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"use strict";

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

const CVT_PADDING = 300;
const PREFIX = "sarasa";

function objToArgs(o) {
let a = [];
Expand Down Expand Up @@ -39,20 +41,22 @@ const STYLE_FILENAME_OF = {
italic: "italic",
bolditalic: "bolditalic"
};

const STYLE_OF = {
regular: "Regular",
bold: "Bold",
italic: "Italic",
bolditalic: "BoldItalic"
bolditalic: "Bold Italic"
};
const STYLES = Object.keys(STYLE_FILENAME_OF);

const FAMILY_OF = {
cl: "cl",
sc: "sc",
tc: "tc",
j: "j"
};
const SUBFAMILIES = Object.keys(FAMILY_OF);

function styleOf(set) {
return (set + "")
.split("-")
Expand Down Expand Up @@ -84,10 +88,11 @@ module.exports = function(ctx, forany, argv, bddy) {
forany.file(`build/pass0`).def(ctx.ensureDir);
forany.file(`build/pass1`).def(ctx.ensureDir);
forany.file(`build/out`).def(ctx.ensureDir);
forany.file(`build/ttc`).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 rawName = target.name.replace(new RegExp("^" + PREFIX + "-", "g"), "");
const [$1, $2] = await this.need(
`build/pass1/${rawName}.ttf`,
`hint/out/${deItalizedNameOf(rawName)}.ttf`
Expand Down Expand Up @@ -182,14 +187,26 @@ module.exports = function(ctx, forany, argv, bddy) {
await this.rm(tmpOTD);
});

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

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

await this.need(...targets);
});

forany.file(`build/ttc/*.ttc`).def(async function(target) {
await this.check(`${target.dir}`);
const rawName = target.name.replace(new RegExp("^" + PREFIX + "-", "g"), "");
const $$ = await this.need(
...SUBFAMILIES.map(sf => `build/out/${PREFIX}-${sf}-${rawName}.ttf`)
);
const ttcize = "node_modules/.bin/otfcc-ttcize" + (os.platform() === "win32" ? ".cmd" : "");
await this.run(ttcize, "-o", target, ...$$, "-k", "-h");
});
forany.virt("ttc").def(async function(target) {
await this.need(...STYLES.map(st => `build/ttc/${PREFIX}-${st}.ttc`));
});
};
49 changes: 48 additions & 1 deletion build-pass2/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
"use strict";

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

const ENCODINGS = {
J: {
gbk: false,
big5: false,
jis: true,
korean: false
},
SC: {
gbk: true,
big5: false,
jis: false,
korean: false
},
TC: {
gbk: false,
big5: true,
jis: false,
korean: false
},
CL: {
gbk: false,
big5: true,
jis: false,
korean: false
}
};

async function pass(ctx, config, argv) {
const a = await ctx.run(introduce, "a", {
from: argv.main,
Expand All @@ -29,8 +63,21 @@ async function pass(ctx, config, argv) {
version: "0.1.0",
family: "Sarasa Gothic " + argv.subfamily,
style: argv.style
},
zh_CN: {
family: "更纱黑体 " + argv.subfamily,
style: argv.style
},
zh_TW: {
family: "更紗黑體 " + argv.subfamily,
style: argv.style
},
ja_JP: {
family: "更紗ゴシック " + argv.subfamily,
style: argv.style
}
});
await ctx.run(setEncodings, "a", ENCODINGS[argv.subfamily]);
await ctx.run(build, "a", { to: config.o, optimize: true });
}

Expand Down
2 changes: 1 addition & 1 deletion build-pass2/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function convPostscript(name) {
}

function compatibilityName(family, style) {
if (style === "Regular" || style === "Bold" || style === "Italic" || style === "BoldItalic") {
if (style === "Regular" || style === "Bold" || style === "Italic" || style === "Bold Italic") {
return { family, style, standardFour: true };
} else {
return { family: family + " " + style, style: "Regular", standardFour: false };
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"inquirer": "^3.2.3",
"inquirer-file-path": "^1.0.0",
"megaminx": "^0.4.3",
"otfcc-ttcize": "^0.5.0",
"scc-config": "^0.8.1",
"which": "^1.2.14",
"yargs": "^8.0.2"
Expand Down

0 comments on commit 7fe27e3

Please sign in to comment.