jaywcjlove / svgtofont

Read a set of SVG icons and ouput a TTF/EOT/WOFF/WOFF2/SVG font.
https://jaywcjlove.github.io/svgtofont
MIT License
515 stars 81 forks source link

The css file cannot be generated and an error is reported #224

Open zhangxiaochuZXC opened 3 months ago

zhangxiaochuZXC commented 3 months ago

demo:

svgtofont({ src: icons_pro, // svg path dist: path.resolve(process.cwd(), fonts/${project.name}), // output path styleTemplates: path.resolve(process.cwd(), styles/${project.name}), // file templates path (optional) fontName: 'fs-ava', // font name classNamePrefix: 'ava-', // css: true, // Create CSS files. css: { fontSize: true, output: path.resolve(process.cwd(), styles/${project.name}), cssPath: '../styles/', include: '\.(css)$', fileName: 'fs-ava-styles', }, startUnicode: 0xea01, // unicode start number svgicons2svgfont: { fontHeight: 1024, normalize: true }, // website = null, no demo html files })

result:

Font created SUCCESS SVG font successfully created! ╰┈▶./fonts/75255_zhangj/fs-ava.svg GET /ava/projects 304 59.558 ms - - SUCCESS TTF font successfully created! ╰┈▶ ./fonts/75255_zhangj/fs-ava.ttf SUCCESS EOT font successfully created! ╰┈▶ ./fonts/75255_zhangj/fs-ava.eot GET /ava/projects/icons/3 200 30.489 ms - 4998 SUCCESS WOFF font successfully created! ╰┈▶ ./fonts/75255_zhangj/fs-ava.woff SUCCESS WOFF2 font successfully created! ╰┈▶ ./fonts/75255_zhangj/fs-ava.woff2 SvgToFont:CLI:ERR: Error: Unmatched selector: ="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> at parse (./node_modules/css-what/lib/commonjs/parse.js:85:15) at Object.select (./node_modules/cheerio-select/lib/index.js:191:68) at LoadedCheerio.find (./node_modules/cheerio/lib/api/traversing.js:90:30) at initialize (./node_modules/cheerio/lib/load.js:156:34) at ./node_modules/svgtofont/lib/utils.js:238:29 at Array.forEach () at ./node_modules/svgtofont/lib/utils.js:235:37 at new Promise () at createSvgSymbol (./node_modules/svgtofont/lib/utils.js:234:12) at exports.default (./node_modules/svgtofont/lib/index.js:123:43) done!

jaywcjlove commented 3 months ago

@zhangxiaochuZXC If you want me to help you, you need to provide an example that reproduces the error.

abaldoni commented 3 weeks ago

Hi, I'm having the same issue. It looks like that if the SVG file has an <?xml header it gets rejected. I'm attaching a sample.

Kind regards, A. hop_logo