font-cmap
v1.0.1
Published
Parse CMap of a TrueType/OpenType font file buffer
Downloads
7
Maintainers
Readme
font-cmap
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, ... }
Installation
npm install font-cmap
API
var fontCmap = require('font-cmap');
fontCmap(buffer)
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.
CLI
You can use this module as a CLI tool by installing it globally.
npm install -g font-cmap
Usage
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.
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.