forked from parallax/jsPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeFonts.js
More file actions
28 lines (22 loc) · 790 Bytes
/
makeFonts.js
File metadata and controls
28 lines (22 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
'use strict'
const fs = require('fs');
const path = require('path');
const minimist = require('minimist');
const minimistOptions = {
string: ['out'],
alias: {
o: 'out'
},
'default': {
'out': './dist/default_vfs.js'
}
};
const cliOptions = minimist(process.argv.slice(2), minimistOptions);
const inputPath = path.resolve((cliOptions._ && cliOptions._[0]) || './fonts');
const outputPath = cliOptions.out;
fs.readdir(inputPath, (err, files) => {
if (err) console.log(err);
const fontList = files.map(file => `jsPDFAPI.addFileToVFS('${file}','${new Buffer(fs.readFileSync(path.join(inputPath, file))).toString('base64')}');`);
fs.writeFileSync(outputPath, `(function (jsPDFAPI) { \n"use strict";\n${fontList.join('\n')}\n})(jsPDF.API);`);
});