A Node module to parse CMap of a TrueType/OpenType font file
const readFontCmap = require('read-font-cmap');
readFontCmap('bower_components/font-awesome/fonts/FontAwesome.otf', (err, map) => {
if (err) {
throw err;
}
console.log(map); // yields: '{"32": 1, "168": 6, "169": 12, "174": 10, ... }'
});
npm install read-font-cmap
const readFontCmap = require('read-font-cmap');
filePath: String
(font file path)
callback: Function
It reads and parses a TrueType/OpenType font file asynchronously, then runs callback function.
error: Object
(an error if it fails to parse the font, otherwise null
)
cmap: Object
The second argument represents CMap table in the form:
{
"Unicode value (integer)": "Glyph ID (integer)"
}
Here is a real-life example, the result of parsing Font Awesome CMap table.
filePath: String
(font file path)
Return: Object
(CMap table)
Synchronous version of readFontCmap
.
const readFontCmap = require('read-font-cmap');
readFontCmap.sync('bower_components/font-awesome/fonts/FontAwesome.otf');
//=> {"32": 1, "168": 6, "169": 12, "174": 10, ... }
Copyright (c) 2014 - 2015 Shinnosuke Watanabe
Licensed under the MIT License.