-
Notifications
You must be signed in to change notification settings - Fork 19
/
ttf2eot.js
executable file
·68 lines (54 loc) · 1.14 KB
/
ttf2eot.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
#!/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 ttf2eot = require('./index.js')
var parser = new ArgumentParser({
add_help: true,
description: 'TTF to EOT font converter'
})
parser.add_argument(
'infile',
{
nargs: '?',
help: 'Input file (stdin if not defined)'
}
)
parser.add_argument(
'outfile',
{
nargs: '?',
help: 'Output file (stdout if not defined)'
}
)
parser.add_argument(
'-v', '--version',
{
action: 'version',
version: require('./package.json').version,
help: "show program's version number and exit"
}
)
/* eslint-disable no-console */
var args = parser.parse_args()
var input
try {
if (args.infile) {
input = fs.readFileSync(args.infile)
} else {
input = fs.readFileSync(process.stdin.fd)
}
} catch (e) {
console.error("Can't open input file (%s)", args.infile || 'stdin')
process.exit(1)
}
var eot = ttf2eot(input)
if (args.outfile) {
fs.writeFileSync(args.outfile, eot)
} else {
process.stdout.write(eot)
}