Repository: mattdesl/fontpath Branch: master Commit: b29141620e5d Files: 8 Total size: 13.7 KB Directory structure: gitextract_0tfz4ibk/ ├── .gitignore ├── bin/ │ └── fontpath ├── lib/ │ ├── SimpleJson.js │ ├── defaultFields.js │ ├── index.js │ └── parser.js ├── package.json └── readme.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ node_modules *.log *. ================================================ FILE: bin/fontpath ================================================ #!/usr/bin/env node var fs = require('fs'); var argv = require('optimist') .usage('fontpath [options] path/to/FontFile.ttf') .demand(1) .alias('c', 'chars') .describe('c', 'the character set: all, ascii, ascii-extended') .default('c', 'ascii') .alias('s', 'size') .default('s', 64) .describe('s', 'the font size in points') .alias('r', 'resolution') .describe('r', 'the resolution in DPI') .default('r', 72) .alias('o', 'output') .describe('o', 'a file to save the data to') .describe('commonJS', 'wrap with module.exports for a JS file') .describe('ignoreKerning', 'ignore kerning') .describe('ignorePath', 'ignore font outlines') .describe('pretty', 'pretty-print the output') .argv; var parse = require('../lib/index.js'); fs.readFile(argv._[0], function(err, buffer) { if (err) throw err; parse(buffer, { output: argv.o, commonJS: argv.commonJS, prettyPrint: argv.pretty, ignoreKerning: argv.ignoreKerning, ignorePath: argv.ignorePath, resolution: argv.resolution, size: argv.size, charcodes: argv.c, }); }); ================================================ FILE: lib/SimpleJson.js ================================================ //Exports to a minimal JSON format that is useful for web purposes var fs = require('fs'); var pkg = require('../package.json'); var EXPORTER_NAME = "SimpleJson"; function SimpleJson() { } SimpleJson.prototype.export = function(fontInfo, options) { var writer = options.output ? fs.createWriteStream(options.output) : process.stdout; var objOut = {}; for (var k in fontInfo) { if (k !== 'glyphs' && k !== 'kerning') objOut[k] = fontInfo[k]; } //For better minification, a list of arrays //Format: [leftChar, rightChar, kerning] objOut.kerning = []; if (fontInfo.kerning) { for (var i=0; i