-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (34 loc) · 844 Bytes
/
index.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
const fs = require('fs'),
nameTable = require('./tableName')
postTable = require('./tablePost'),
os2Table = require('./tableOS2');
function ttfInfo(data) {
try {
return {
'name': nameTable(data),
'post': postTable(data),
'OS/2': os2Table(data)
};
}
catch(e) {
console.error(String(e));
throw ("Error reading ttf: " + String(e));
}
}
module.exports = function(pathOrData, cb) {
var data = fs.readFileSync(pathOrData);
return ttfInfo(data);
};
/*
var getData = (pathOrData instanceof Buffer) ?
function(data, cb) { cb(null, data); } : fs.readFile;
getData(pathOrData, function(err, data) {
if (err) return cb(pathOrData + ' not found.');
try {
var info = ttfInfo(data);
cb(null, info);
} catch(err) {
cb(err);
}a
});
};*/