Parse CMap of a TrueType/OpenType font file buffer
var fs = require('fs');
var fontCmap = require('font-cmap');
var buf = fs.readFileSync('bower_components/font-awesome/fonts/FontAwesome.otf');
fontCmap(buf); //=> {"32": 1, "168": 6, "169": 12, "174": 10, ... }
npm install font-cmap
var fontCmap = require('font-cmap');
buffer: Object
(Buffer
of a TrueType/OpenType font file)
Return: Object
It returns an object of a 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.
You can use this module as a CLI tool by installing it globally.
npm install -g font-cmap
Usage1: font-cmap <font file path>
Usage2: cat <font file path> | font-cmap
Options:
--min, -m Minify output
--help, -h Print usage information
--version, -v Print version
It prints a CMap table as a JSON string.
Copyright (c) 2014 - 2015 Shinnosuke Watanabe
Licensed under the MIT License.