Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #6 from mrbar42/patch-1
Browse files Browse the repository at this point in the history
Allowing format specific options
  • Loading branch information
sunflowerdeath committed Mar 24, 2016
2 parents 747fe09 + be62955 commit bbc3d07
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,30 @@ Icons without codepoints will have codepoints incremented from `startCodepoint`
Options that are passed directly to
[svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont).

### formatOptions

Type: `object`

Specific per format arbitrary options to pass to the generator

format and matching generator:
- `svg` - [svgicons2svgfont](https://github.com/nfroidure/svgicons2svgfont).
- `ttf` - [svg2ttf](https://github.com/fontello/svg2ttf).
- `woff` - [ttf2woff](https://github.com/fontello/ttf2woff).
- `eot` - [ttf2eot](https://github.com/fontello/ttf2eot).

```js
webfontsGenerator({
// options
formatOptions: {
// options to pass specifically to the ttf generator
ttf: {
ts: 1451512800000
}
}
}, function(error, result) {})
```

### writeFiles

Type: `boolean`
Expand Down
11 changes: 8 additions & 3 deletions src/generateFonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ var generators = {
var svgOptions = _.pick(options,
'fontName', 'fontHeight', 'descent', 'normalize', 'round'
)

if (options.formatOptions['svg']) {
svgOptions = _.extend(svgOptions, options.formatOptions['svg'])
}

svgOptions.log = function(){}

var fontStream = svgicons2svgfont(svgOptions)
Expand Down Expand Up @@ -53,7 +58,7 @@ var generators = {
ttf: {
deps: ['svg'],
fn: function(options, svgFont, done) {
var font = svg2ttf(svgFont)
var font = svg2ttf(svgFont, options.formatOptions['ttf'])
font = new Buffer(font.buffer)
done(null, font)
}
Expand All @@ -62,7 +67,7 @@ var generators = {
woff: {
deps: ['ttf'],
fn: function(options, ttfFont, done) {
var font = ttf2woff(new Uint8Array(ttfFont))
var font = ttf2woff(new Uint8Array(ttfFont), options.formatOptions['woff'])
font = new Buffer(font.buffer)
done(null, font)
}
Expand All @@ -71,7 +76,7 @@ var generators = {
eot: {
deps: ['ttf'],
fn: function(options, ttfFont, done) {
var font = ttf2eot(new Uint8Array(ttfFont))
var font = ttf2eot(new Uint8Array(ttfFont), options.formatOptions['eot'])
font = new Buffer(font.buffer)
done(null, font)
}
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var DEFAULT_OPTIONS = {
rename: function(file) {
return path.basename(file, path.extname(file))
},
formatOptions: {},
/**
* Unicode Private Use Area start.
* http://en.wikipedia.org/wiki/Private_Use_(Unicode)
Expand Down

0 comments on commit bbc3d07

Please sign in to comment.