nfroidure / svgicons2svgfont

Concatenate SVG icons and ouput an SVG font
http://nfroidure.github.io/svgiconfont/
MIT License
339 stars 71 forks source link

fix: Fixed issue with NaN in path attribute for some SVG #87

Closed L2jLiga closed 6 years ago

L2jLiga commented 6 years ago

Proposed changes

Original svg:

<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><title>icon-call-window-front</title><g id="g816"><rect id="rect950" x="116.61" y="0.44" width="383.39" height="381.63" rx="22.49"/><path id="rect950-9" d="M23.31,103.79A23.31,23.31,0,0,0,0,127.1V476.22a23.34,23.34,0,0,0,23.34,23.34h413.6a23.31,23.31,0,0,0,23.31-23.31V450.07H61.69a12.23,12.23,0,0,1-12.23-12.23v-334Z"/></g></svg>

Current result of transformation:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
  <font id="iconfont" horiz-adv-x="500">
    <font-face font-family="iconfont"
      units-per-em="500" ascent="500"
      descent="0" />
    <missing-glyph horiz-adv-x="0" />
    <glyph glyph-name="icon-call-window-front"
      unicode="&#xEA01;"
      horiz-adv-x="500" d="M139.1 499.56H477.51ANaN NaN NaN 0 0 500 499.56V117.93ANaN NaN NaN 0 0 477.51 117.93H139.1ANaN NaN NaN 0 0 116.61 117.93V499.56ANaN NaN NaN 0 0 139.1 499.56zM23.31 396.21A23.31 23.31 0 0 1 0 372.9V23.78A23.339999999999996 23.339999999999996 0 0 1 23.34 0.44H436.94A23.31 23.31 0 0 1 460.25 23.75V49.93H61.69A12.23 12.23 0 0 0 49.46 62.16V396.1600000000001z" />
  </font>
</defs>
</svg>

After this PR:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
  <font id="iconfont" horiz-adv-x="500">
    <font-face font-family="iconfont"
      units-per-em="500" ascent="500"
      descent="0" />
    <missing-glyph horiz-adv-x="0" />
    <glyph glyph-name="icon-call-window-front"
      unicode="&#xEA01;"
      horiz-adv-x="500" d="M139.1 499.56H477.51A22.49 22.49 0 0 0 500 477.07V140.42A22.49 22.49 0 0 0 477.51 117.93H139.1A22.49 22.49 0 0 0 116.61 140.42V477.07A22.49 22.49 0 0 0 139.1 499.56zM23.31 396.21A23.31 23.31 0 0 1 0 372.9V23.78A23.339999999999996 23.339999999999996 0 0 1 23.34 0.44H436.94A23.31 23.31 0 0 1 460.25 23.75V49.93H61.69A12.23 12.23 0 0 0 49.46 62.16V396.1600000000001z" />
  </font>
</defs>
</svg>

Code quality

License

To get your contribution merged, you must check the following.

L2jLiga commented 6 years ago

@NaridaL ping

Any updates on this?


Might be it would be usefull: https://github.com/L2jLiga/grunt-webfonts/issues/7 https://github.com/L2jLiga/grunt-webfonts/issues/8

NaridaL commented 6 years ago

Hi, sorry for the delay.

Fixing the original problem would have been a 1 line fix (https://github.com/nfroidure/svgicons2svgfont/blob/master/src/svgshapes2svgpath.js#L27) ;-) and the old tests wouldn't have been affected.

Not that this is a problem, but checking the tests took a bit longer.

L2jLiga commented 6 years ago

Any updates?