nfroidure / svgfont2svgicons

Extract SVG icons from an SVG font
MIT License
15 stars 10 forks source link

Saving glyph "undefined" to "fontelloFont/undefined.svg" #10

Open Jab2870 opened 6 years ago

Jab2870 commented 6 years ago

This is the output I'm getting

Saving glyph "undefined" to "fontelloFont/undefined.svg"
/usr/lib/node_modules/svgfont2svgicons/bin/svgfont2svgicons.js:21
      glyph.stream.pipe(Fs.createWriteStream(glyphPath));
                   ^

TypeError: Cannot read property 'pipe' of undefined
    at SVGFont2SVGIcons.<anonymous> (/usr/lib/node_modules/svgfont2svgicons/bin/svgfont2svgicons.js:21:20)
    at emitNone (events.js:105:13)
    at SVGFont2SVGIcons.emit (events.js:207:7)
    at emitReadable_ (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/node_modules/readable-stream/lib/_stream_readable.js:456:10)
    at emitReadable (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/node_modules/readable-stream/lib/_stream_readable.js:450:7)
    at readableAddChunk (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/node_modules/readable-stream/lib/_stream_readable.js:206:11)
    at SVGFont2SVGIcons.Readable.push (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/node_modules/readable-stream/lib/_stream_readable.js:162:10)
    at SVGFont2SVGIcons.Duplexer._pushAll (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/src/index.js:123:31)
    at PassThrough.<anonymous> (/usr/lib/node_modules/svgfont2svgicons/node_modules/plexer/src/index.js:102:13)
    at emitNone (events.js:105:13)
chrisb34 commented 4 years ago

Is there a solution to this?

javascriptlove commented 3 years ago

Apparently the version in npm differs from master, we had to point to specific commit:

    "svgfont2svgicons": "https://github.com/nfroidure/svgfont2svgicons#249afa1953ec230a8b1e16073b9a9b986ca03e65",
insinfo commented 2 years ago

Hello I'm having this problem also with the npm version, any solution?

 node --version
v8.9.4
cd  C:\Users\isaque\AppData\Roaming\npm\node_modules>
git  clone  https://github.com/nfroidure/svgfont2svgicons.git
cd svgfont2svgicons
npm install
npm WARN deprecated mocha@2.2.5: Mocha v2.2.x is no longer supported.
npm WARN deprecated istanbul@0.3.22: This module is no longer maintained, try this instead:
npm WARN deprecated   npm i nyc
npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated mkdirp@0.5.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated request@2.79.0: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mkdirp@0.3.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@2.0.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated har-validator@2.0.6: this library is no longer supported
npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN svgfont2svgicons@2.0.0 No license field.

added 154 packages in 9.757s
PS C:\MyDartProjects\appjazz\appjazzmobile\fonts> svgfont2svgicons  C:\MyDartProjects\appjazz\appjazzmobile\fonts\iconsmind.svg C:\MyDartProjects\appjazz\appjazzmobile\fonts\icons
Saving glyph ".notdef" to "C:\MyDartProjects\appjazz\appjazzmobile\fonts\icons\.notdef.svg"
C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\bin\svgfont2svgicons.js:35
      readableHex = glyph.metadata.unicode.map(function(str) {
                                           ^

TypeError: Cannot read property 'map' of undefined
    at SVGFont2SVGIcons.<anonymous> (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\bin\svgfont2svgicons.js:35:44)
    at emitNone (events.js:106:13)
    at SVGFont2SVGIcons.emit (events.js:208:7)
    at emitReadable_ (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\node_modules\readable-stream\lib\_stream_readable.js:456:10)
    at emitReadable (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\node_modules\readable-stream\lib\_stream_readable.js:450:7)
    at readableAddChunk (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\node_modules\readable-stream\lib\_stream_readable.js:206:11)
    at SVGFont2SVGIcons.Readable.push (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\node_modules\readable-stream\lib\_stream_readable.js:162:10)
    at SVGFont2SVGIcons.Duplexer._pushAll (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\src\index.js:123:31)
    at PassThrough.<anonymous> (C:\Users\isaque\AppData\Roaming\npm\node_modules\svgfont2svgicons\node_modules\plexer\src\index.js:102:13)
    at emitNone (events.js:106:13)
cdauth commented 6 months ago

Fix:

diff --git a/bin/svgfont2svgicons.js b/bin/svgfont2svgicons.js
index 2ea7627..ad1b4e8 100755
--- a/bin/svgfont2svgicons.js
+++ b/bin/svgfont2svgicons.js
@@ -31,11 +31,7 @@ fontStream.pipe(iconProvider);
 iconProvider.on('readable', function() {
   var glyph;
   while((glyph = iconProvider.read()) !== null) {
-    var glyphName = glyph.metadata.name,
-      readableHex = glyph.metadata.unicode.map(function(str) {
-        return '\\u' + str.charCodeAt(0).toString(16).toUpperCase();
-      }).join('');
-
+    var glyphName = glyph.metadata.name;
     var glyphPath = path.join(destPath, glyphName + '.svg');
     console.log('Saving glyph "' + glyphName + '" to "' + glyphPath + '"');
     glyph.pipe(Fs.createWriteStream(glyphPath));