https://github.com/shinnn/node-font-cmap
Parse CMap of a font file buffer
https://github.com/shinnn/node-font-cmap
Last synced: 3 months ago
JSON representation
Parse CMap of a font file buffer
- Host: GitHub
- URL: https://github.com/shinnn/node-font-cmap
- Owner: shinnn
- License: mit
- Created: 2014-10-13T13:18:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-29T13:17:27.000Z (about 10 years ago)
- Last Synced: 2024-04-24T19:32:25.537Z (about 1 year ago)
- Language: JavaScript
- Size: 164 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# font-cmap
[](https://www.npmjs.com/package/font-cmap)
[](https://travis-ci.org/shinnn/node-font-cmap)
[](https://ci.appveyor.com/project/ShinnosukeWatanabe/node-font-cmap)
[](https://coveralls.io/r/shinnn/node-font-cmap)
[](https://david-dm.org/shinnn/node-font-cmap)
[](https://david-dm.org/shinnn/node-font-cmap#info=devDependencies)Parse [CMap](http://www.microsoft.com/typography/otspec/cmap.htm) of a TrueType/OpenType font file [buffer][buffer]
```javascript
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
[Use npm](https://docs.npmjs.com/cli/install).
```sh
npm install font-cmap
```## API
```javascript
var fontCmap = require('font-cmap');
```### fontCmap(*buffer*)
*buffer*: `Object` ([`Buffer`][buffer] of a TrueType/OpenType font file)
Return: `Object`It returns an object of a CMap table in the form:
```javascript
{
"Unicode value (integer)": "Glyph ID (integer)"
}
```[Here](https://raw.githubusercontent.com/shinnn/node-font-cmap/master/test/fixture.json) is a real-life example, the result of parsing [Font Awesome](https://fortawesome.github.io/Font-Awesome/) CMap table.
## CLI
You can use this module as a CLI tool by installing it [globally](https://docs.npmjs.com/files/folders#global-installation).
```sh
npm install -g font-cmap
```### Usage
```
Usage1: font-cmap
Usage2: cat | font-cmapOptions:
--min, -m Minify output
--help, -h Print usage information
--version, -v Print version
```It prints a CMap table as a [JSON](http://www.json.org/) string.
## License
Copyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn)
Licensed under [the MIT License](./LICENSE).
[buffer]: https://nodejs.org/api/buffer.html#buffer_buffer