Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static load(svgNode) {
let inputPaths = svgNode.querySelectorAll('path'),
currentPath = {},
paths = [];
currentPath.points = []
// Scrape all points from all points, and record breakpoints
for(let inputPath of inputPaths) {
let pathData = new SVGPathData(inputPath.getAttribute('d'));
let previousCoords = {
x: 0,
y: 0
};
for(let [index, command] of pathData.commands.entries()) {
switch(command.type) {
// Move ('M') and line ('L') commands have both X and Y
case SVGPathData.MOVE_TO:
case SVGPathData.LINE_TO:
currentPath.points.push([
command.x,
command.y
]);
this.glyphs.forEach(glyph => {
const ratio = this._options.normalize
? fontHeight / glyph.height
: fontHeight / maxGlyphHeight;
if (!isFinite(ratio)) throw new Error('foo');
glyph.width *= ratio;
glyph.height *= ratio;
const glyphPath = new SVGPathData('');
if (this._options.fixedWidth) {
glyph.width = fontWidth;
}
const yOffset = glyph.height - this._options.descent;
const glyphPathTransform = new Matrix().transform(
1,
0,
0,
-1,
0,
yOffset
); // ySymmetry
if (1 !== ratio) {
glyphPathTransform.scale(ratio, ratio);
}
function applyTransform(d) {
return new SVGPathData(d).matrix(
...transformStack[transformStack.length - 1].toArray()
);
}
const glyph = svgIconStream.metadata || {};