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

Incorrect font height output

Open makabde opened this issue 11 years ago • 23 comments

Hi all, I am currently fighting with grunt-webfont as I am facing an issue with the generated font. It seems that few pixels are added to the font height and I did not manage to find where this is coming from. On the screenshot, you'll notice that the icon is 36px height instead of being 32px. My inputs are all 512*512px svg files. Cheers,

EDIT: I have tried to generate the webfont using the FontCustom gem on a ruby based project and everything was fine. Width and height were 32px as expected.

screen shot 2013-11-04 at 10 17 07

makabde avatar Nov 04 '13 09:11 makabde

Hi,

I have a similar issue, I have some 'landscape' icons, where the width is 3 or 4 times the height of the icon. The end result seems to be that I have tiny icons aligned to the top of the font characters bounding box. (The bounding box looks to be almost square)

I can recreate the issue by making any SVG that is not a square shape.

I am going to look at generating the font using FontCustom as well now...

Thanks.

DanielHudson avatar Nov 25 '13 12:11 DanielHudson

@ShinobiCorp It’ll be very cool if you could find time for some experiments.

sapegin avatar Nov 25 '13 13:11 sapegin

@sapegin @ShinobiCorp if I can ben of any help, please feel free to ping at anytime. Cheers.

makabde avatar Nov 25 '13 13:11 makabde

Probably the difference with FontCustom is in this lines: https://github.com/FontCustom/fontcustom/blob/master/lib/fontcustom/scripts/generate.py#L77-L83

sapegin avatar Nov 25 '13 13:11 sapegin

I had the same issue when generating the icons/fonts with Fontcustom, no matter what values I used for the Glyph width.

Also shrinking down the SVG didn't help either...

3cc-london avatar Nov 25 '13 16:11 3cc-london

After some reading here and around in order to understand how others would create their font icons, I have decided to try to tweak some settings of the generate.py file in order to match the settings of the previous links. I finally found some settings that are close to my expectation.

f = fontforge.font()
f.encoding = 'UnicodeFull'
f.design_size = 16
f.em = 1024
f.ascent = 896
f.descent = 128

[...]

f.autoWidth(0, 0, 1024)

With these values, I've also upscaled my SVGs to 1024px

However I am still wondering why the generator is getting rid of the icon bounding box. For certain reasons, I created a font that must have internal margins; setting the font-size to 32px will result to an icon that is actually 24px height. Using the icomoon generator I had a font that kept the bounding box where as in our case the it does not keep the bounding box–may be this is an other subject matter...

screen shot 2013-12-09 at 12 19 58

makabde avatar Dec 09 '13 11:12 makabde

Yes, it would be cool if it could be fixed :) :+1:

pensierinmusica avatar Jan 01 '14 14:01 pensierinmusica

@pensierinmusica PRs are always welcome.

sapegin avatar Jan 01 '14 14:01 sapegin

@sapegin, sorry about my embarassing ignorance... what are "PRs"? :)

pensierinmusica avatar Jan 04 '14 18:01 pensierinmusica

@pensierinmusica Pull request :shipit:

sapegin avatar Jan 05 '14 14:01 sapegin

@sapegin :) Got it

pensierinmusica avatar Jan 05 '14 14:01 pensierinmusica

:+1 I am experiencing the same issue ... the SVG's bounding box seems to be ignored and the resulting icons don't have necessarily the same size. Using the same SVGs with IcoMoon gives the expected results.

Any ideas on how to fix this?

jtammen avatar Jan 20 '14 10:01 jtammen

@jtammen did you try with FontCustom alone? What is the result in that case?

pensierinmusica avatar Jan 20 '14 10:01 pensierinmusica

Having the same experiencing as @jtammen. As @pensierinmusica asked, i tried Fontcustom. Fontcustom comes up with the perfect line heights.

mrzmyr avatar Jan 23 '14 18:01 mrzmyr

A month ago I've posted some tweaks that I did on the generate.py file. It solved this issue on my side. Should I create a PR? I have to admit I don't think this is the end solution but at least it solves the issue. Any thoughts?

makabde avatar Jan 23 '14 22:01 makabde

@makabde I would be great! Thanks!

sapegin avatar Jan 24 '14 06:01 sapegin

@pensierinmusica Can confirm that using FontCustom directly solves the issue in my case. @makabde PR would be great (-:

jtammen avatar Jan 24 '14 16:01 jtammen

Yeah, grunt-webfont ignoring SVG's bounding box is really a pain in the ass... Hope it will be fixed soon. Otherwise fantastic tool, keep up the good job : )

lpillonel avatar Apr 29 '14 07:04 lpillonel

All icons have top padding. I try to change engine, fontHeight, descent, ascent, but icons padding doesn't change. How I can fix this?

screen shot 2014-06-13 at 11 53 43 am

max-mykhailenko avatar Jun 13 '14 08:06 max-mykhailenko

I notice this problem too. I solved it with some dirty css specific to the problem icon.

@makabde have you got round to pushing your changes into a pull request?

peter-mouland avatar Jun 17 '14 10:06 peter-mouland

Same problem for me using fontforge as engine, while with node engine it works great

luruke avatar Sep 04 '14 14:09 luruke

Also seeing a similar problem. My icons are often "cropped" even though the SVGs are hand-crafted to be 512x512 px. Until this issue is fixed by grunt-webfont, does anyone have any idea what I can do with the SVGs themselves to prevent it?

rarkins avatar Sep 23 '14 07:09 rarkins

this issue seems to have confused both the original one and the issue with bounding boxes of the svg.

using fontforge the only issues I had with bounding box were solved by having a very small descent. this page may be of help: http://designwithfontforge.com/en-US/Importing_Glyphs_from_Other_Programs.html

lukeapage avatar Aug 05 '15 14:08 lukeapage