svgicons2svgfont
Advanced tools
Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "svgicons2svgfont", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Read a set of SVG icons and ouput a SVG font", | ||
@@ -25,4 +25,4 @@ "homepage": "https://github.com/nfroidure/svgicons2svgfont", | ||
"sax": "0.6.x", | ||
"svg-pathdata": "0.0.4", | ||
"readable-stream": "^1.0.26-2" | ||
"svg-pathdata": "0.0.5", | ||
"readable-stream": "^1.0.26-4" | ||
}, | ||
@@ -33,3 +33,3 @@ "devDependencies": { | ||
"coveralls": "~2.10.0", | ||
"istanbul": "~0.2.6", | ||
"istanbul": "~0.2.7", | ||
"sax": "~0.6.0" | ||
@@ -36,0 +36,0 @@ }, |
@@ -9,4 +9,3 @@ # svgicons2svgfont | ||
Transform attributes either on 'g' element or path/shapes elements are | ||
currently unsupported. | ||
Transform attributes support is currenly experimental, report issues if any. | ||
@@ -55,3 +54,3 @@ ## Usage | ||
Default value: `MAX(icons.height)` | ||
The ouputted font height (defaults to the height of the highest input icon). | ||
The outputted font height (defaults to the height of the highest input icon). | ||
@@ -58,0 +57,0 @@ ### descent |
@@ -13,2 +13,28 @@ /* | ||
// Transform helpers (will move elsewhere later) | ||
function parseTransforms(value) { | ||
return value.match( | ||
/(rotate|translate|scale|skewX|skewY|matrix)\s*\(([^\)]*)\)\s*/g | ||
).map(function(transform) { | ||
return transform.match(/[\w\.\-]+/g); | ||
}); | ||
} | ||
function transformPath(path, transforms) { | ||
transforms.forEach(function(transform) { | ||
path[transform[0]].apply(path, transform.slice(1).map(function(n) { | ||
return parseInt(n, 10); | ||
})); | ||
}); | ||
return path; | ||
} | ||
function applyTransforms(d, parents) { | ||
var transforms = []; | ||
parents.forEach(function(parent) { | ||
if('undefined' !== typeof parent.attributes.transform) { | ||
transforms = transforms.concat(parseTransforms(parent.attributes.transform)); | ||
} | ||
}); | ||
return transformPath(new SVGPathData(d), transforms).encode(); | ||
} | ||
// Required modules | ||
@@ -92,3 +118,3 @@ var Path = require("path") | ||
} else if('rect' === tag.name) { | ||
glyph.d.push( | ||
glyph.d.push(applyTransforms( | ||
// Move to the left corner | ||
@@ -101,8 +127,8 @@ 'M' + parseFloat(tag.attributes.x || 0,10).toString(10) | ||
+ 'h' + (parseFloat(tag.attributes.width, 10)*-1).toString(10) | ||
+ 'z' | ||
); | ||
+ 'z', parents | ||
)); | ||
} else if('line' === tag.name) { | ||
log('Found a line element in the icon "' + glyph.name + '" the result' | ||
+' could be different than expected.'); | ||
glyph.d.push( | ||
glyph.d.push(applyTransforms( | ||
// Move to the line start | ||
@@ -117,14 +143,14 @@ 'M' + parseFloat(tag.attributes.x1,10).toString(10) | ||
+ ' ' + parseFloat(tag.attributes.y2,10).toString(10) | ||
+ 'Z' | ||
); | ||
+ 'Z', parents | ||
)); | ||
} else if('polyline' === tag.name) { | ||
log('Found a polyline element in the icon "' + glyph.name + '" the' | ||
+' result could be different than expected.'); | ||
glyph.d.push( | ||
'M' + tag.attributes.points | ||
); | ||
glyph.d.push(applyTransforms( | ||
'M' + tag.attributes.points, parents | ||
)); | ||
} else if('polygon' === tag.name) { | ||
glyph.d.push( | ||
'M' + tag.attributes.points + 'Z' | ||
); | ||
glyph.d.push(applyTransforms( | ||
'M' + tag.attributes.points + 'Z', parents | ||
)); | ||
} else if('circle' === tag.name || 'ellipse' === tag.name) { | ||
@@ -137,3 +163,3 @@ var cx = parseFloat(tag.attributes.cx,10) | ||
parseFloat(tag.attributes.ry,10) : parseFloat(tag.attributes.r,10); | ||
glyph.d.push( | ||
glyph.d.push(applyTransforms( | ||
'M' + (cx - rx) + ',' + cy | ||
@@ -152,6 +178,6 @@ + 'C' + (cx - rx) + ',' + (cy + ry*KAPPA) | ||
+ ' ' + (cx - rx) + ',' + cy | ||
+ 'Z' | ||
); | ||
+ 'Z', parents | ||
)); | ||
} else if('path' === tag.name && tag.attributes.d) { | ||
glyph.d.push(tag.attributes.d); | ||
glyph.d.push(applyTransforms(tag.attributes.d, parents)); | ||
} | ||
@@ -158,0 +184,0 @@ }); |
@@ -130,2 +130,8 @@ var assert = require('assert') | ||
it("should work with transformed SVG icons", function(done) { | ||
generateFontToFile({ | ||
fontName: 'transformedicons' | ||
}, done); | ||
}); | ||
}); | ||
@@ -132,0 +138,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142998
75
535
81
+ Added@colors/colors@1.5.0(transitive)
+ Added@socket.io/component-emitter@3.1.2(transitive)
+ Added@types/cookie@0.4.1(transitive)
+ Added@types/cors@2.8.17(transitive)
+ Added@types/node@22.7.4(transitive)
+ Addedaccepts@1.3.8(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedassertion-error@2.0.1(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbase64id@2.0.0(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbody-parser@1.20.3(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addedchai@5.1.1(transitive)
+ Addedcheck-error@2.1.1(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcliui@7.0.4(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconnect@3.7.0(transitive)
+ Addedcontent-type@1.0.5(transitive)
+ Addedcookie@0.4.2(transitive)
+ Addedcors@2.8.5(transitive)
+ Addedcustom-event@1.0.1(transitive)
+ Addeddate-format@4.0.14(transitive)
+ Addeddebug@2.6.94.3.7(transitive)
+ Addeddeep-eql@5.0.2(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddepd@2.0.0(transitive)
+ Addeddestroy@1.2.0(transitive)
+ Addeddi@0.0.1(transitive)
+ Addeddom-serialize@2.2.1(transitive)
+ Addedee-first@1.1.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedencodeurl@1.0.2(transitive)
+ Addedengine.io@6.6.1(transitive)
+ Addedengine.io-parser@5.2.3(transitive)
+ Addedent@2.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescape-html@1.0.3(transitive)
+ Addedeventemitter3@4.0.7(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfinalhandler@1.1.2(transitive)
+ Addedflatted@3.3.1(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedfs-extra@8.1.0(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhttp-errors@2.0.0(transitive)
+ Addedhttp-proxy@1.18.1(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedisbinaryfile@4.0.10(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedkarma@6.4.4(transitive)
+ Addedkarma-chai@0.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlog4js@6.9.1(transitive)
+ Addedloupe@3.1.1(transitive)
+ Addedmedia-typer@0.3.0(transitive)
+ Addedmime@2.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednormalize-path@3.0.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedobject-inspect@1.13.2(transitive)
+ Addedon-finished@2.3.02.4.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedparseurl@1.3.3(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpathval@2.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedpunycode@1.4.1(transitive)
+ Addedqjobs@1.2.0(transitive)
+ Addedqs@6.13.0(transitive)
+ Addedrange-parser@1.2.1(transitive)
+ Addedraw-body@2.5.2(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequires-port@1.0.0(transitive)
+ Addedrfdc@1.4.1(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedsetprototypeof@1.2.0(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedsocket.io@4.8.0(transitive)
+ Addedsocket.io-adapter@2.5.5(transitive)
+ Addedsocket.io-parser@4.2.4(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedstatuses@1.5.02.0.1(transitive)
+ Addedstreamroller@3.1.5(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsvg-pathdata@0.0.5(transitive)
+ Addedtmp@0.2.3(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtoidentifier@1.0.1(transitive)
+ Addedtype-is@1.6.18(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedunpipe@1.0.0(transitive)
+ Addedutils-merge@1.0.1(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedvoid-elements@2.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedws@8.17.1(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@16.2.0(transitive)
+ Addedyargs-parser@20.2.9(transitive)
- Removedsvg-pathdata@0.0.4(transitive)
Updatedreadable-stream@^1.0.26-4
Updatedsvg-pathdata@0.0.5