From d52b521debcf3bbf9f7cd00b3400475f24340e91 Mon Sep 17 00:00:00 2001 From: Karl Bowden Date: Wed, 19 Mar 2014 18:17:35 +1100 Subject: [PATCH] Initial commit. --- .gitignore | 1 + LICENSE | 21 ++++++++++++++++++++ README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ gulp-fontgen.js | 32 +++++++++++++++++++++++++++++++ package.json | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 gulp-fontgen.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3996e60 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Karl Bowden + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..9966426 --- /dev/null +++ b/README.md @@ -0,0 +1,51 @@ +# gulp-fontgen + +[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url] + +> gulp-fontgen plugin for [gulp](https://github.com/wearefractal/gulp) + +## Usage + +First, install `gulp-fontgen` as a development dependency: + +```shell +npm install --save-dev gulp-fontgen +``` + +Then, add it to your `gulpfile.js`: + +```javascript +var gulp-fontgen = require("gulp-fontgen"); + +gulp.src("./src/*.ext") + .pipe(gulp-fontgen({ + dest: "./dest/" + })) +``` + +## API + +### gulp-fontgen(options) + +#### options.dest +Type: `String` (Required) + +Destination to write all the font files to + +All other options for `fontfacegen` are passed through. + +## License + +[MIT License](http://en.wikipedia.org/wiki/MIT_License) + +[npm-url]: https://npmjs.org/package/gulp-fontgen +[npm-image]: https://badge.fury.io/js/gulp-fontgen.png + +[travis-url]: http://travis-ci.org/agentk/gulp-fontgen +[travis-image]: https://secure.travis-ci.org/agentk/gulp-fontgen.png?branch=master + +[coveralls-url]: https://coveralls.io/r/agentk/gulp-fontgen +[coveralls-image]: https://coveralls.io/repos/agentk/gulp-fontgen/badge.png + +[depstat-url]: https://david-dm.org/agentk/gulp-fontgen +[depstat-image]: https://david-dm.org/agentk/gulp-fontgen.png \ No newline at end of file diff --git a/gulp-fontgen.js b/gulp-fontgen.js new file mode 100644 index 0000000..986ba8b --- /dev/null +++ b/gulp-fontgen.js @@ -0,0 +1,32 @@ +// through2 is a thin wrapper around node transform streams +var through = require('through2'); +var gutil = require('gulp-util'); +var fontface = require('fontfacegen'); +var path = require('path'); +var PluginError = gutil.PluginError; + +// Consts +const PLUGIN_NAME = 'gulp-fontgen'; + +// Plugin level function(dealing with files) +function gulpFontgen(options) { + + if (!options.dest) { + throw new PluginError(PLUGIN_NAME, "options.dest is missing"); + } + + // Creating a stream through which each file will pass + var stream = through.obj(function(file, enc, callback) { + + options.source = path.join(file.cwd, file.relative); + fontface(options); + + this.push(file); + return callback(); + + }); + + return stream; +}; + +module.exports = gulpFontgen; diff --git a/package.json b/package.json new file mode 100644 index 0000000..1f73cfd --- /dev/null +++ b/package.json @@ -0,0 +1,50 @@ +{ + "name": "gulp-fontgen", + "description": "Generator of browser fonts and css from ttf or otf files", + "version": "0.1.0", + "homepage": "https://github.com/agentk/gulp-fontgen", + "author": { + "name": "Karl Bowden", + "email": "karlbowden@gmail.com", + "url": "http://karlbowden.com/" + }, + "repository": { + "type": "git", + "url": "https://github.com/agentk/gulp-fontgen.git" + }, + "bugs": { + "url": "https://github.com/agentk/gulp-fontgen/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/agentk/grunt-fontgen/blob/master/LICENSE-MIT" + } + ], + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "test": "node test.js" + }, + "main": "gulp-fontgen.js", + "keywords": [ + "font-face", + "fontface", + "font", + "face", + "web-fonts", + "webfonts", + "web", + "ttf", + "otf", + "svg", + "eot", + "css" + ], + "dependencies": { + "fontfacegen": "^0.1.0", + "through2": "^0.4.1", + "gulp-util": "^2.2.14" + } +}