sapegin / grunt-webfont

SVG to webfont converter for Grunt
MIT License
1.11k stars 211 forks source link

Icons generated by IcoMoon.io cannot be compiled as webfont #158

Open vitmalina opened 10 years ago

vitmalina commented 10 years ago

I have downloaded latest icons from icomoon.io as svg and compiled it with grunt task. I get the following error:

Running "webfont:icons" (webfont) task
Fatal error: Unexpected character "N" at index 1.

The SVG file is

<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by IcoMoon.io -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<g>
    <line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>
</g>
    <path d="M10 6l22-6v23c0 2.761-3.134 5-7 5s-7-2.239-7-5c0-2.761 3.134-5 7-5 1.074 0 2.091 0.173 3 0.481v-10.3l-14 3.818v15c0 2.761-3.134 5-7 5s-7-2.239-7-5c0-2.761 3.134-5 7-5 1.074 0 2.091 0.173 3 0.481v-16.481z" fill="#000000"></path>
</svg>

I can open this SVG file in Illustrator and save it back, then it works. Then I looked into the problem and found that if I remove this line

<line stroke-width="1" x1="" y1="" x2="" y2="" stroke="#449FDB" opacity=""></line>

then everything compiles fine. Not sure whose problem it is, but decided to post here.

sapegin commented 10 years ago

Do you use the node engine?

vitmalina commented 10 years ago

Yes. I use node engine.

sapegin commented 10 years ago

@nfroidure Could you take a look at this files? Maybe it’s IcoMoon bug and shouldn’t be fixed there.

nfroidure commented 10 years ago

I assume the empty x/y values are parsed to NaN so that the SVGPathData parser fails parsing the converted path.

Currently, i'm renovating my new house so will not have time to fix this right now. Feel free to PR svgicons2svgfont since the problem sits at this level.

Otherwise, i'll probably fix it in about 2 weeks.

paulfalgout commented 9 years ago

icomoon adds extra info so they can display the grid on their site. You should remove that prior to attempting to use the file anywhere.