Giter VIP home page Giter VIP logo

fonty's Introduction

Fonty : A simple library/CLI tool for generating web fonts

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:

$ text=`cat glyphs.txt` fonty -g="$text" -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.

fonty's People

Contributors

taggon avatar

Watchers

Kyungwook, Park avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.