diff --git a/maker.js b/maker.js index 3458f22d6..d9a41428b 100644 --- a/maker.js +++ b/maker.js @@ -1,57 +1,62 @@ -const fs = require('fs'); -const path = require('path'); -const argv = require('yargs').argv; -const pad = require('pad'); +const fs = require("fs"); +const path = require("path"); +const argv = require("yargs").argv; +const pad = require("pad"); -const weights = ['thin', 'extralight', 'light', 'book', 'medium', 'bold', 'heavy']; -const slantnesses = ['upright', 'italic', 'oblique']; -const widths = ['term', 'normal', 'cc']; -const designs = ['sans', 'slab']; +const weights = ["thin", "extralight", "light", "book", "medium", "bold", "heavy"]; +const slantnesses = ["upright", "italic", "oblique"]; +const widths = ["term", "normal", "cc"]; +const designs = ["sans", "slab"]; function present(x) { return !!x; } function tofn(a) { - return a.filter(present).join('-'); + return a.filter(present).join("-"); } function getMapping(options) { options = options || { design: [], - width: 'normal', - weight: 'book', - slantness: 'upright', + width: "normal", + weight: "book", + slantness: "upright", styles: {}, - dirPrefix: '', - dirSuffix: '', - filePrefix: '', - infix: '', - fileSuffix: '' + dirPrefix: "", + dirSuffix: "", + filePrefix: "", + infix: "", + fileSuffix: "" }; let design = options.design || []; let prestyle = options.prestyle || []; - let weight = options.weight || 'book'; - let slantness = options.slantness || 'upright'; - let hives = ['iosevka'].concat( + let weight = options.weight || "book"; + let slantness = options.slantness || "upright"; + let hives = ["iosevka"].concat( prestyle, - ['w-' + weight, 's-' + slantness], + ["w-" + weight, "s-" + slantness], (options.styles || {})[slantness] || [], design ); - let dir = [options.dirPrefix || '', 'iosevka', options.infix || tofn(design), options.dirSuffix || ''] - .filter(present) - .join('-'); - let filename = [ - options.filePrefix || '', - 'iosevka', + let dir = [ + options.dirPrefix || "", + "iosevka", options.infix || tofn(design), - options.fileSuffix || '', - (weight === 'book' ? slantness === 'upright' ? 'regular' : '' : weight) + - (slantness === 'upright' ? '' : slantness) + options.dirSuffix || "" ] .filter(present) - .join('-'); + .join("-"); + let filename = [ + options.filePrefix || "", + "iosevka", + options.infix || tofn(design), + options.fileSuffix || "", + (weight === "book" ? (slantness === "upright" ? "regular" : "") : weight) + + (slantness === "upright" ? "" : slantness) + ] + .filter(present) + .join("-"); return { hives, dir, filename, custom: options.custom }; } @@ -66,12 +71,12 @@ function createMake(mapping) { let woffTarget = `$(DIST)/${dir}/woff/${filename}.woff`; let woff2Target = `$(DIST)/${dir}/woff2/${filename}.woff2`; - let buf = ''; + let buf = ""; if (!definedBuildSeqs[tfname]) { buf += ` -${tfname} : ${custom || ''} $(SCRIPTS) | $(BUILD) $(DIST)/${dir}/ - @echo Building ${filename} with ${hives.join(' ')} - $(GENERATE) ${hives.join(' ')} -o $@ ${cm ? '--charmap $(BUILD)/' + filename + '.charmap' : ''}`; +${tfname} : ${custom || ""} $(SCRIPTS) | $(BUILD) $(DIST)/${dir}/ + @echo Building ${filename} with ${hives.join(" ")} + $(GENERATE) ${hives.join(" ")} -o $@ ${cm ? "--charmap $(BUILD)/" + filename + ".charmap" : ""}`; definedBuildSeqs[tfname] = true; } buf += ` @@ -99,8 +104,8 @@ let designGroups = []; if (argv.custom) { designGroups = [ { - custom: '$(BUILD)/targets-' + argv.custom + '.mk', - name: 'customized-' + argv.custom, + custom: "$(BUILD)/targets-" + argv.custom + ".mk", + name: "customized-" + argv.custom, design: argv.design.trim().split(/ +/), prestyle: argv.prestyle.trim().split(/ +/), width: argv.width, @@ -114,19 +119,19 @@ if (argv.custom) { ]; } else { designGroups = [ - { name: 'sans', design: [], dirPrefix: '' }, - { name: 'slab', design: ['slab'], dirPrefix: '' }, - { name: 'r-sans', design: [], dirPrefix: '01' }, - { name: 'r-sans-term', design: ['term'], dirPrefix: '02' }, - { name: 'r-sans-type', design: ['type'], dirPrefix: '03' }, - { name: 'r-sans-cc', design: ['cc'], dirPrefix: '04' }, - { name: 'r-slab', design: ['slab'], dirPrefix: '05' }, - { name: 'r-slab-term', design: ['term', 'slab'], dirPrefix: '06' }, - { name: 'r-slab-type', design: ['type', 'slab'], dirPrefix: '07' }, - { name: 'r-slab-cc', design: ['cc', 'slab'], dirPrefix: '08' } + { name: "sans", design: [], dirPrefix: "" }, + { name: "slab", design: ["slab"], dirPrefix: "" }, + { name: "r-sans", design: [], dirPrefix: "01" }, + { name: "r-sans-term", design: ["term"], dirPrefix: "02" }, + { name: "r-sans-type", design: ["type"], dirPrefix: "03" }, + { name: "r-sans-cc", design: ["cc"], dirPrefix: "04" }, + { name: "r-slab", design: ["slab"], dirPrefix: "05" }, + { name: "r-slab-term", design: ["term", "slab"], dirPrefix: "06" }, + { name: "r-slab-type", design: ["type", "slab"], dirPrefix: "07" }, + { name: "r-slab-cc", design: ["cc", "slab"], dirPrefix: "08" } ]; for (let j = 1; j <= 11; j++) { - const tag = 'ss' + pad(2, '' + j, '0'); + const tag = "ss" + pad(2, "" + j, "0"); designGroups.push({ name: `r-sans-${tag}`, design: [tag], @@ -134,7 +139,7 @@ if (argv.custom) { }); designGroups.push({ name: `r-sans-term-${tag}`, - design: ['term', tag], + design: ["term", tag], dirPrefix: `` }); } @@ -178,7 +183,7 @@ $(DIST)/${groupMapping.dir}/woff2/ : | $(DIST)/${groupMapping.dir}/ config.weight = weight; config.slantness = slantness; const mapping = getMapping(config); - if (weight === 'book' && slantness === 'upright') { + if (weight === "book" && slantness === "upright") { mapping.cm = true; } @@ -190,13 +195,15 @@ $(DIST)/${groupMapping.dir}/woff2/ : | $(DIST)/${groupMapping.dir}/ groupTargets.woff2.push(woff2Target); } - makes.push(`fonts-${dg.name} : ${groupTargets.ttf.join(' ')}`); - makes.push(`fonts-${dg.name}-upright : ${groupTargets.upright.join(' ')}`); - makes.push(`fonts-${dg.name}-italic : ${groupTargets.italic.join(' ')}`); - makes.push(`fonts-${dg.name}-oblique : ${groupTargets.oblique.join(' ')}`); - makes.push(`web-${dg.name} : ${groupTargets.woff.join(' ')} ${groupTargets.woff2.join(' ')}`); + makes.push(`fonts-${dg.name} : ${groupTargets.ttf.join(" ")}`); + makes.push(`fonts-${dg.name}-upright : ${groupTargets.upright.join(" ")}`); + makes.push(`fonts-${dg.name}-italic : ${groupTargets.italic.join(" ")}`); + makes.push(`fonts-${dg.name}-oblique : ${groupTargets.oblique.join(" ")}`); + makes.push(`web-${dg.name} : ${groupTargets.woff.join(" ")} ${groupTargets.woff2.join(" ")}`); makes.push( - `$(ARCHIVEDIR)/${groupMapping.dir}-$(VERSION).zip : fonts-${dg.name} web-${dg.name} | $(ARCHIVEDIR)/ + `$(ARCHIVEDIR)/${groupMapping.dir}-$(VERSION).zip : fonts-${dg.name} web-${ + dg.name + } | $(ARCHIVEDIR)/ cd $(DIST)/${groupMapping.dir}/ && 7z a -tzip -r -mx=9 ../../$@ ./` ); makes.push(`archive-${dg.name} : $(ARCHIVEDIR)/${groupMapping.dir}-$(VERSION).zip`); @@ -217,8 +224,8 @@ $(DIST)/ttc/ : | $(DIST)/ ); for (let tg of ttcgroups) { for (let weight of weights) { + let ttctargets = []; for (let slantness of slantnesses) { - let ttctargets = []; for (let dg of tg.groups) { let config = Object.create(dg); config.weight = weight; @@ -226,30 +233,29 @@ $(DIST)/ttc/ : | $(DIST)/ const mapping = getMapping(config); ttctargets.push(createMake(mapping).target); } - - let config = Object.create(tg.groups[0]); - config.weight = weight; - config.slantness = slantness; - const mapping = getMapping(config); - ttcs.push(`$(DIST)/ttc/${mapping.filename}.ttc`); - makes.push( - ` -$(DIST)/ttc/${mapping.filename}.ttc : ${ttctargets.join(' ')} | $(DIST)/ttc/ - otfcc-ttcize -o $@ ${ttctargets.join(' ')} -` - ); } + let config = Object.create(tg.groups[0]); + config.weight = weight; + config.slantness = "upright"; + const mapping = getMapping(config); + ttcs.push(`$(DIST)/ttc/${mapping.filename}.ttc`); + makes.push( + ` +$(DIST)/ttc/${mapping.filename}.ttc : ${ttctargets.join(" ")} | $(DIST)/ttc/ + otfcc-ttcize -o $@ ${ttctargets.join(" ")} +` + ); } } - makes.push(`ttc : ${ttcs.join(' ')}`); + makes.push(`ttc : ${ttcs.join(" ")}`); makes.push( `$(ARCHIVEDIR)/iosevka-pack-$(VERSION).zip : ttc | $(ARCHIVEDIR)/ cd $(DIST)/ttc/ && 7z a -tzip -mx=9 ../../$@ ./*.ttc` ); makes.push(`archive-ttc : $(ARCHIVEDIR)/iosevka-pack-$(VERSION).zip`); makes.push(`__default : fonts-sans fonts-slab`); - makes.push(`__release : archive-ttc ${designGroups.map(g => 'archive-' + g.name).join(' ')}`); + makes.push(`__release : archive-ttc ${designGroups.map(g => "archive-" + g.name).join(" ")}`); } -console.log(makes.join('\n\n')); +console.log(makes.join("\n\n"));