I am using the tool icon-font-buildr which utilizes svgicons2svgfont to generate an SVG font, which is then used to generate TTF/WOFF/etc fonts. I'm running into an issue in my final output, which I've tracked down to behavior in svgicons2svgfont.
Issue
I'm a gentledev i:
[X] fully read the README recently
[X] searched for existing issues
[X] checked i'm up to date with the latest version of the project
It is possible for the path for a particular icon to change slightly between the different glyph entries. In my example, the precision of some of the coordinates seems to change between each glyph.
rotate_left behaves as expected. d is the same between entries.
rotate_right shows the problem. d varies slightly between entries.
Why does this matter?
This causes problems using the final SVG font down the road. For example, the tool svg2ttf converts an SVG font into a TTF font. As part of this, it attemps to dedupe the glyphs in the SVG font. Because these two glyphs are technically different (d does not match), the final TTF ends up with duplicate unexpected glyphs (rotate_right and rotate_right-1) for a single icon.
Debugging informations
node -v result:
v14.16.0
npm -v result:
6.14.13
Solution
I believe this can be solved easily, by moving this line of code. For each glyph, we compute d multiple times, one for each unicode entry. Instead, we should bump this up and compute d once per icon. This would eliminate any chance of precision errors showing up between each glyph.
I am using the tool
icon-font-buildr
which utilizessvgicons2svgfont
to generate an SVG font, which is then used to generate TTF/WOFF/etc fonts. I'm running into an issue in my final output, which I've tracked down to behavior insvgicons2svgfont
.Issue
I'm a gentledev i:
Expected behavior
When a single icon has multiple unicode strings for ligatures, multiple matching glyphs are added to the final SVG font. Each entry is given a unique name, the unicode string, and path.
It is expected that the path for a particular icon be the same for each glyph in the final output.
Actual behavior
It is possible for the path for a particular icon to change slightly between the different glyph entries. In my example, the precision of some of the coordinates seems to change between each glyph.
Steps to reproduce the behavior
I have a particular icon that causes this reliably. I've referenced how
icon-font-buildr
is calling intosvgicons2svgfont
, to create the following minimal reproduction:https://github.com/zbream/issue-svgicons2svgfont-multiple-unicode
Check the output file,
out.svg
.rotate_left
behaves as expected.d
is the same between entries.rotate_right
shows the problem.d
varies slightly between entries.Why does this matter?
This causes problems using the final SVG font down the road. For example, the tool
svg2ttf
converts an SVG font into a TTF font. As part of this, it attemps to dedupe the glyphs in the SVG font. Because these two glyphs are technically different (d
does not match), the final TTF ends up with duplicate unexpected glyphs (rotate_right
androtate_right-1
) for a single icon.Debugging informations
node -v
result:npm -v
result:Solution
I believe this can be solved easily, by moving this line of code. For each glyph, we compute
d
multiple times, one for each unicode entry. Instead, we should bump this up and computed
once per icon. This would eliminate any chance of precision errors showing up between each glyph.