sapegin / grunt-webfont

SVG to webfont converter for Grunt
MIT License
1.1k stars 210 forks source link

"node" engine in 0.4.4 makes broken font file #155

Closed vitch closed 10 years ago

vitch commented 10 years ago

I upgraded to the latest version of grunt-webfont and my icon fonts stopped working in Firefox. The web inspector gives the following message:

downloadable font: head: Bad ppm of 14...

I'm not sure what caused it but downgrading to 0.4.2 fixed it.

It doesn't seem to be specific to my SVG files (I tried removing nearly all of them) but in case you can see the files I am running it though here and the config I'm passing here

sapegin commented 10 years ago

Does it work with 0.4.3? ttf2woff was updated in 0.4.3 and svgicons2svgfont was updated in 0.4.4. Probably it’s the reason of this bug but I’m not sure yet.

sapegin commented 10 years ago

fontHeight should be at least 16 but I don’t know why.

/cc @nfroidure

vitch commented 10 years ago

Actually I still get the problem with 0.4.3...

Although it looks like svgicons2svgfont was upgraded from 0.0.11 to 0.1.0 in that release:

➜  npm install grunt-webfont@0.4.3
npm WARN engine hawk@0.10.2: wanted: {"node":"0.8.x"} (current: {"node":"0.10.29","npm":"1.4.20"})
...
grunt-webfont@0.4.3 node_modules/grunt-webfont
├── exec@0.1.1
├── async@0.9.0
├── chalk@0.4.0 (has-color@0.1.7, ansi-styles@1.0.0, strip-ansi@0.1.1)
├── temp@0.8.0 (rimraf@2.2.8)
├── underscore.string@2.3.3
├── lodash@2.4.1
├── mkdirp@0.5.0 (minimist@0.0.8)
├── ttf2woff@1.3.0 (pako@0.2.5, argparse@0.1.15)
├── ttf2eot@1.3.0 (argparse@0.1.15)
├── svg2ttf@1.1.2 (xmldom@0.1.19, lodash@2.1.0, argparse@0.1.15, svgpath@1.0.6)
├── glob@4.0.4 (once@1.3.0, inherits@2.0.1, graceful-fs@3.0.2, minimatch@0.3.0)
├── svgicons2svgfont@0.1.0 (readable-stream@1.0.27-1, svg-pathdata@0.0.6, sax@0.6.0)
└── winston@0.7.3 (cycle@1.0.3, eyes@0.1.8, stack-trace@0.0.9, colors@0.6.2, async@0.2.10, pkginfo@0.3.0, request@2.16.6)
➜  npm install grunt-webfont@0.4.2
...
> node-gyp rebuild
...
grunt-webfont@0.4.2 node_modules/grunt-webfont
├── exec@0.1.1
├── async@0.8.0
├── mkdirp@0.4.2 (minimist@0.0.8)
├── underscore.string@2.3.3
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── temp@0.7.0 (rimraf@2.2.8)
├── chalk@0.4.0 (has-color@0.1.7, ansi-styles@1.0.0, strip-ansi@0.1.1)
├── lodash@2.4.1
├── ttf2eot@1.3.0 (argparse@0.1.15)
├── ttf2woff@1.2.0 (argparse@0.1.15)
├── svg2ttf@1.1.2 (xmldom@0.1.19, argparse@0.1.15, lodash@2.1.0, svgpath@1.0.6)
├── winston@0.7.3 (cycle@1.0.3, stack-trace@0.0.9, eyes@0.1.8, colors@0.6.2, async@0.2.10, pkginfo@0.3.0, request@2.16.6)
└── svgicons2svgfont@0.0.11 (readable-stream@1.0.27-1, sax@0.6.0, svg-pathdata@0.0.5)

I'm not sure what the node-gyp rebuild command is but that only happens on 0.4.2...

These are the errors that I see with the font in Firefox (it works fine in Chrome):

screen shot 2014-07-26 at 18 36 42

Hope it helps!

p.s. I didn't understand what you mean about the fontHeight...

sapegin commented 10 years ago

You have this setting in your Gruntfile:

      fontHeight: 14,
      descent: 2,
      ascent: 2,

If you set fontHeight to 16 the font will works fine.

vitch commented 10 years ago

Ahhh!

If I change that then the font builds OK but it renders corrupted:

screen shot 2014-07-26 at 18 53 47

Compared to how it renders in 0.4.2:

screen shot 2014-07-26 at 18 57 11

(I also tested 0.4.2 with the font-size set to 14 and it rendered correctly)

sapegin commented 10 years ago

That’s because 16 is too small. Default value is 512 and it looks fine. fontHeight, descent and ascent options was added in 0.4.3, that’s why it’s fine in 0.4.2. too.

vitch commented 10 years ago

Awesome - thanks :smiley:

Maybe there is a divide by zero happening somewhere if it is triggered by unexpectedly small numbers?

I'm happy to close this since it works fine with the default options. I only chose 14 as the fontHeight because some of the icons were exported from icomoon and that was set to 14px icons.