Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taggon/fonty
A simple library and CLI tool for generating web fonts
https://github.com/taggon/fonty
cli css fonty web-fonts
Last synced: 2 months ago
JSON representation
A simple library and CLI tool for generating web fonts
- Host: GitHub
- URL: https://github.com/taggon/fonty
- Owner: taggon
- License: mit
- Created: 2016-11-28T12:24:37.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2021-09-03T09:22:26.000Z (over 3 years ago)
- Last Synced: 2024-10-04T13:18:07.553Z (3 months ago)
- Topics: cli, css, fonty, web-fonts
- Language: JavaScript
- Homepage:
- Size: 19.5 KB
- Stars: 21
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fonty
A simple library/CLI tool for generating web fonts.
## Translations
* [한국어](docs/README.ko.md)
## Prerequisite
* Node >= 6.0
## Usage
```
const fonty = require('fonty');fonty( 'path/to/source.ttf', 'path/to/output', options );
```If the `path/to/output` is a directory, it should end with a single forward slash(`/`).
### Options
* `base64`: If true, the `css` option will automatically turn on and the css file will include base64-encoded web fonts.
* `css`: If true, `fonty` will generate css file for the output web fonts.
* `glyph`: A string contains the glyphs that the output fonts have. All glyphs are preserved by defalut.
* `optimize`: If true, all empty glyphs except for space will be removed.
* `type`: An array of output types. Default: `['ttf', 'eot', 'svg', 'woff', 'woff2']`.Note: if the `glyph` option contains a space, fonty will alias it as both new line and carrage return.
### Events
The `fonty` returns an array of promises and a promise represents each type.
See the following code.```
fonty( 'path/to/source.ttf', 'path/to/output', options ).map( promise => {
promise.done( (type) => {
console.log( `.${type} file has been converted.` );
} );
} );
```The above code write a console message whenever each file conversion completed.
### CLI Tool
First, install the tool globally.
```
$ npm i -g fonty
```And just use it:
```
$ fonty [options] path/to/source.ttf [path/to/output]
```Let's say you have a big list of glyphs in `glyphs.txt` and want to generate `eot` and `woff` type webfonts from `font.ttf`.
You can pass the glyph list to `fonty` like this:```
$ GLYPHS=`cat glyphs.txt` fonty --glyph="$GLYPHS" --type="eot,woff" font.ttf
```You will see more detail help if you just execute `fonty` in the command line.
## License
This library is released under MIT license.