-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathttf2woff.js
executable file
·81 lines (63 loc) · 1.35 KB
/
ttf2woff.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env node
/*
Author: Viktor Semykin <[email protected]>
Written for fontello.com project.
*/
'use strict';
var fs = require('fs');
var ArgumentParser = require('argparse').ArgumentParser;
var ttf2woff = require('./index.js');
var parser = new ArgumentParser({
add_help: true,
description: 'TTF to WOFF font converter'
});
parser.add_argument(
'infile',
{
nargs: 1,
help: 'Input file'
}
);
parser.add_argument(
'outfile',
{
nargs: 1,
help: 'Output file'
}
);
parser.add_argument(
'-m', '--metadata',
{
help: 'Metadata XML file (optional)',
required: false
}
);
parser.add_argument(
'-v', '--version',
{
action: 'version',
version: require('./package.json').version,
help: "show program's version number and exit"
}
);
var args = parser.parse_args();
var input;
var options = {};
/* eslint-disable */
try {
input = fs.readFileSync(args.infile[0]);
} catch (e) {
console.error("Can't open input file (%s)", args.infile[0]);
process.exit(1);
}
if (args.metadata) {
try {
options.metadata = Array.prototype.slice.call(fs.readFileSync (args.metadata), 0);
} catch (e) {
console.error("Can't open metadata file (%s)", args.infile);
process.exit(1);
}
}
var ttf = new Uint8Array(input);
var woff = ttf2woff(ttf, options);
fs.writeFileSync(args.outfile[0], woff);