Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Commit

Permalink
Node engine: create SVG font.
Browse files Browse the repository at this point in the history
  • Loading branch information
sapegin committed Nov 12, 2013
1 parent 25d991b commit 3671118
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 5 deletions.
8 changes: 8 additions & 0 deletions Gruntfile.js
Expand Up @@ -172,6 +172,14 @@ module.exports = function(grunt) {
order: 'svg,woff',
hashes: false
}
},
node: {
src: 'test/src/*.svg',
dest: 'test/tmp/node',
options: {
hashes: false,
engine: 'node'
}
}
},
nodeunit: {
Expand Down
11 changes: 7 additions & 4 deletions package.json
Expand Up @@ -31,15 +31,18 @@
"node": "*"
},
"dependencies": {
"temp": "~0.4.0"
"temp": "~0.4.0",
"svgicons2svgfont": "0.0.1",
"async": "~0.2.9",
"lodash": "~2.3.0"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-nodeunit": "~0.2.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-jscs-checker": "~0.2.2",
"stylus": "~0.38.0",
"grunt-jscs-checker": "~0.2.3",
"stylus": "~0.40.2",
"matchdep": "~0.3.0"
},
"peerDependencies": {
Expand Down
51 changes: 51 additions & 0 deletions tasks/engines/node.js
@@ -0,0 +1,51 @@
/**
* grunt-webfont: Node.js engine
*
* @requires ttfautohint
* @author Artem Sapegin (http://sapegin.me)
*/

/*jshint node:true, laxbreak:true, latedef:false */
module.exports = function(grunt, o, done) {
'use strict';

var path = require('path');
var async = require('async');
var svgicons2svgfont = require('svgicons2svgfont');

// @todo Append hashes

var result = {
fontName: o.fontName,
glyphs: []
};

async.waterfall([
svgFilesToSvgFont,
allDone
]);


// Convert SVG files to SVG font
function svgFilesToSvgFont(done) {
console.log(o.files);
svgicons2svgfont(o.files, path.join(o.dest, o.fontName + '.svg'), {
fontName: o.fontName,
callback: function(glyphs) {
console.log('done', glyphs);
result.glyphs = glyphs;
done();
}
});
}

// Create TTF font
// Autohint TTF
// Create WOFF font
// Create OTF font


function allDone() {
done(result);
}
};
2 changes: 1 addition & 1 deletion tasks/webfont.js
Expand Up @@ -12,7 +12,7 @@ module.exports = function(grunt) {
var fs = require('fs');
var path = require('path');
var temp = require('temp');
var async = grunt.util.async;
var async = require('async');
var _ = grunt.util._;

var COMMAND_NOT_FOUND = 127;
Expand Down
20 changes: 20 additions & 0 deletions test/src/plusone.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions test/src/single.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3671118

Please sign in to comment.