make-glyphs
Version:
Tools for working with .glyphs font files.
94 lines (67 loc) • 3.02 kB
Markdown
> Tools for working with `.glyphs` font files
Load, validate, manipulate, and write font files for [Glyphs](http://glyphsapp.com/) using Javascript.
The API described below is functional but may change. Testing and contributions are welcome. See [issues](https://github.com/delucis/make-glyphs/issues) for known problems and to report any bugs or feature requests.
npm install --save make-glyphs
```js
const GLYPHS = require('make-glyphs')
// load a .glyphs file
GLYPHS.load('my-font.glyphs')
// subset '!' and all capital letters
.then(font => GLYPHS.subset(font, ['0021', ['0041', '005A']]))
// increment the minor version
.then(font => GLYPHS.version(font))
// rename the font
.then(font => GLYPHS.set(font, 'familyName', 'New Font'))
// write the changes to a new font file
.then(font => GLYPHS.write('new-font.glyphs', font))
```
Installing this package will also install a `make-glyphs` command that you can use to set up builds for your project. To use this, you will need to create a `glyphs.config.js` file in your project root, describing your builds. Here’s an example:
```js
// glyphs.config.js
module.exports = {
builds: {
'basic-latin': {
load: 'src/my-font.glyphs',
process: [
['subset', ['Basic Latin']],
['set', 'familyName', (name) => `${name} Basic`]
],
write: 'build/my-font-basic-latin.glyphs'
},
version: {
load: 'src/my-font.glyphs',
process: [
['version']
],
write: 'src/my-font.glyphs'
}
}
}
```
See [documentation for the `.build()` method](https://github.com/delucis/make-glyphs/blob/master/API.md#buildbuilds) for more details.
Now you can set up npm scripts to run these builds in your `package.json`…
```json
/* package.json */
{
"scripts": {
"subset": "make-glyphs --build basic-latin",
"version": "make-glyphs --build version"
}
}
```
…and then run the scripts from the command line:
```sh
npm run subset
npm run version
```
- [readable-glyph-names](https://github.com/delucis/readable-glyph-names) — Unicode string to readable character name mapping as JSON
- [write-glyphs-file](https://github.com/delucis/write-glyphs-file) — Stringify and write a `.glyphs` font file atomically
This software is free to use, modify, and redistribute under a [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.txt).