-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add additional metrics to make it easier to have different size icon fonts #175
Conversation
Woah — thanks for this! I'm on limited connectivity while traveling, but will integrate it as soon as I can. |
Any word on this? |
Just another nudge for merging this PR ;) Those changes @jlong made are super helpful. |
Another vote for this wonderful patch. |
Hey any word on this? Would love to have this functionality in the master branch! |
I'd also really like this feature. |
+1 |
I am trying to get crisp font-icons on Windows-Firefox. Therefore I'd like to try this branch. I use bootstrap which has 14px as default. So I adjusted the fontcustom.yml:
But the generated font still looks blurry on windows. Do the SVG's have to have a special format? |
In order to avoid blurriness, your
Or, 32 (in your case). |
Thanx for the hint. My current setting is now:
It seems that I have to redraw all icons so they align perfect to the grid. |
Please update the README & website docs accordingly, explaining all possible settings for font generating. Can't the generator have an option to fit SVG to a center of a glyph? it makes no sense to manually edit each SVG file make it fit a certain grid manually |
This pull-request adds four additional settings:
These map cleanly to the Fontforge values by the same name. Basically this allows you to have fonts scale correctly for a perfect baseline when the height of the glyphs does not evenly go into 512 (which is a bit of a magic number otherwise).
For example, to get a font that is designed with 18px icons I used these settings:
These metrics also allow us to calculate the precise size of a "pixel" using the following formula:
Knowing this allows us to solve another problem. It appears that glyphs are centered on the "canvas" regardless of their original position in the SVG. This works out well if the glyph is an even number of pixels (6, 8, 10...) but if it is an odd number of pixels vertical lines will appear blurry because the glyph will not be aligned to perfectly to a pixel grid.
To solve this I've added a bit of code that will shift the glyph over to the left to align with the pixel grid as long as the width of the glyph is an integer number of pixels. So if the glyph is 7 pixels wide on an 18 pixel canvas the left edge of the glyph will be at 5 pixels instead of 5.5 pixels as it would without this code. This only works if the width of the glyph is an integer. So if the width of the glyph is 3.3 pixels (a real number) the left edge will be at 7.35 pixels.
I've chosen the integer alignment rule because it seems to be a pretty safe bet that if an icon's width is an integer that it should be aligned to a pixel grid. It works well for all of my own icons.