grunt-font-optimizer
Optimize TTF fonts and make font subsets with Grunt
Getting Started
This plugin requires Grunt ~0.4.1
and Perl
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-font-optimizer --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
The "font_optimizer" task
Overview
In your project's Gruntfile, add a section named font_optimizer
to the data object passed into grunt.initConfig()
.
grunt
Options
options.chars
Type: String
Default value: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
List of characters to include in the optimized subset of font.
options.includeFeatures
Type: Array
Default value: ['kern']
Font features to include in the optimized font.
- Use "none" to include no features.
- Leave array empty to include all features.
See list of all supported font features: http://en.wikipedia.org/wiki/OpenType_feature_tag_list#OpenType_typographic_features
Usage Examples
Optimizing file-by-file
Default behaviour is to add each font as it's own row to the option.files
grunt
Optimizing whole directory at the time
You can also describe a wildcard selector to include e.g. the whole directory.
In That case, describe a folder (ending with /
) as the target:
grunt
Attributions
Uses Font Optimizer perl script
by Philip Taylor to do the optimization.
Font Optimizer script licensed under MIT license (found in
/lib/font-optimizer/LICENSE
).