grunt-webfont icon indicating copy to clipboard operation
grunt-webfont copied to clipboard

Distorted Icon Rendering from generated Webfont

Open oller opened this issue 8 years ago • 14 comments

Hi there,

Bumping to v1.1.1 for the improved templating options, my font is now coming out rather distorted.

Some examples: image image

The relevant grunt options:

engine: "node",
hashes: false,
relativeFontPath: "../fonts/icons",
types: "eot,woff2,woff,ttf,svg",
order: "eot,woff2,woff,ttf,svg",
normalize: true,
htmlDemo: true,
htmlDemoTemplate: "<%= config.app %>/icons/template/template.html",
htmlDemoFilename: "icons",
fontHeight: 31,
descent: 0,
destHtml: "<%= config.app %>/src/components",

All the source SVG's are 31px width and height and viewport. I've tried buming these all to 512px and updating the fontHeight option, didn't fix the issue.

I have also brew installed ttfautohint, but this doesn't seem to change the output.

node v5.6.0

Anyone else encountering this problem?

oller avatar Mar 01 '16 17:03 oller

I tried tried to upgrade from 0.4.8 and it seems like the icons are rendered worse for each version. See icon_account(1.1.1), icon_order(0.5.4),icon_response(0.5.4) and icon_zoom-track(1.1.1) below. (Open up the images in a new browser tab to be able to see them in good quality)

icons-versions-0 4 8 icons-versions-0 5 4 icons-versions-1 1 1

In version 1.2.0 my icons don't render at all.

icons-versions-1 2 0

hacker112 avatar Mar 03 '16 16:03 hacker112

@oller did you try using the fontforge engine, it seems that node is no longer supported? I switched it over and it solved a lot of rendering issues.

I also found that flattening the transparencies and expanding paths in illustrator also ironed out a few issues.

stevejwikeley avatar Mar 23 '16 22:03 stevejwikeley

With further investigation, this breaking change came in between 0.4.2 and 0.4.3

I assume it's one of the changes in dependencies in during this bump: https://github.com/sapegin/grunt-webfont/compare/v0.4.2...v0.4.3

In the meantime, I've rolled back to 0.4.2 and found some workarounds for the more limited templating options.

oller avatar Mar 24 '16 15:03 oller

We seems to have same regression.

Here are icons from older grunt-webfont:

chrome_2016-08-28_15-18-53

And now part of them started to appear totally broken:

chrome_2016-08-28_15-19-22

Here are inlined svgs for comparison:

chrome_2016-08-28_15-21-14

ArmorDarks avatar Aug 28 '16 12:08 ArmorDarks

Any updates? Still have those terrible icons with node engine.

ArmorDarks avatar Nov 13 '16 17:11 ArmorDarks

I faced a similar problem (distorted icons with the node renderer) and fixed it by disabling the SVGO optimization (optimize option set to false).

With SVG optimization: image

Without: image

motet-a avatar Jan 19 '17 17:01 motet-a

Well, maybe issues in SVGO indeed... So, you example doesn't seems as broken, as ones I've encountered.

Anyway, I don't have where to test it out anymore anyway. We've just switched to inlined SVG, and that fixed our issue :)

ArmorDarks avatar Jan 19 '17 17:01 ArmorDarks

Hi.. i have the same issue with both, node and fontforge rendering. Is there any solution to fix the problem ?

These are my relevant grunt options:

                    types: 'eot, svg, ttf, woff, woff2',
                    fontHeight: 32,
                    descent: 0,
                    stylesheet: 'less',
                    template: 'source/_templates/iconfont/style-template.ejs',
                    relativeFontPath: '../../../fonts/icon-font/',
                    htmlDemo: false,
                    autoHint:false,
                    optimize: false

And i am working on a windows 10 desktop

me1k avatar Nov 02 '17 12:11 me1k

I only this week revisited this and resolved my issue @me1k . For me, the crux of the problem was that fontHeight and the corresponding dimensions of the SVGs. This lib now wants the SVGs to be 512 or bigger. I think at that scale it's kinder if you imagine the decimal points of the coords in the SVG.

Short of it, I used https://github.com/vieron/svg-resizer as a quick CLI tool to batch proportionally enlarge all my svg's to 512px. (this script updated the width, height and viewBox properties correctly). I then lost the fontHeight property from grunt as it defaults to 512px and all was good once again.

Hope this helps

oller avatar Nov 02 '17 13:11 oller

As @motet-a noted earlier, I think this happens when smaller SVGs are run through the SVGO optimization and all your long decimal coordinates get rounded off. This is why the tool works best with larger viewboxes.

alampros avatar Nov 02 '17 13:11 alampros

I am having the same problem; however, none of the solutions presented here are helping. Here's a snippet of the Gruntfile:

font: 'Twemoji Mozilla',
types: 'ttf',
autoHint: false,
descent: 0,
optimize: false,
execMaxBuffer: 1024 * 1000,
version: packageJSON.version,
codepointsFile: 'build/codepoints.js'

TheEssem avatar Apr 19 '18 21:04 TheEssem

In 2018 I would recommend to drop iconic webfonts and use SVG instead

ArmorDarks avatar Apr 19 '18 23:04 ArmorDarks

@ArmorDarks I would, but I'm using this for generating a color emoji font, not an icon font.

TheEssem avatar Apr 20 '18 01:04 TheEssem

Hello, are there any updates?

topolanekmartin avatar Feb 19 '20 09:02 topolanekmartin