Search code examples
node.jssvggruntjswebfontsfontforge

Grunt-Webfont Generates offset on glyphicon icons in CSS


Not long ago I ran glyphicon generation to CSS tff through grunt-webfont on my Mac OS X Yosemite. Now I had a new icon to add but for some reason the icons don't align anymore after a new run.

The red box is where the icons should be.

The icons should look like this:

Icons centered

The sizing of the icons in image 1 is also wrong, 25x110 but in image 2 50x50 as they should be.

The CSS in the example is as follows:

.icon {
  font-family: "icons";
  font-size: 50px;
  background-color: red;
}

The HTML:

<div id="icon_test" class="icon icon_movies">
</div>

And the SVG:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 200 200" style="enable-background:new 0 0 200 200;" xml:space="preserve">
<style type="text/css">
    .st0{fill:#666666;}
    .st1{fill:#808080;}
    .st2{fill:#4D4D4D;}
    .st3{fill:#FFFFFF;}
</style>
<g id="GRID">
    <polygon class="st0" points="67.5,54.7 132.5,100 67.5,145.3     "/>
</g>
<g id="Layer_1">
</g>
</svg>

My grunt-webfont config is also unchanged:

module.exports = {
  icons: {
    src: 'client/icons/*.svg',
    dest: 'public/fonts',
    destCss: 'public/css',
    options: {
      embed: ['ttf'],
      font: 'icons',
      types: 'ttf',
      hashes: false,
      htmlDemo: false
    }
  }
};

Has anyone encountered this problem before?


Solution

  • Apparently this occurred when at least one of the sag files hade a non 0 0 coordinate for the view box.