diff --git a/src/components/modebar/modebar.js b/src/components/modebar/modebar.js index 9eaf443cdc7..71b82cd6fd1 100644 --- a/src/components/modebar/modebar.js +++ b/src/components/modebar/modebar.js @@ -14,7 +14,7 @@ var isNumeric = require('fast-isnumeric'); var Lib = require('../../lib'); var Icons = require('../../../build/ploticon'); - +var Parser = new DOMParser(); /** * UI controller for interactive plots @@ -192,8 +192,6 @@ proto.createIcon = function(thisIcon) { if(thisIcon.path) { icon = document.createElementNS(svgNS, 'svg'); - icon.setAttribute('height', '1em'); - icon.setAttribute('width', (thisIcon.width / iconHeight) + 'em'); icon.setAttribute('viewBox', [0, 0, thisIcon.width, iconHeight].join(' ')); var path = document.createElementNS(svgNS, 'path'); @@ -215,10 +213,13 @@ proto.createIcon = function(thisIcon) { } if(thisIcon.svg) { - icon = document.createElement('div'); - icon.innerHTML = '' + thisIcon.svg + ''; + var svgDoc = Parser.parseFromString(thisIcon.svg, 'application/xml'); + icon = svgDoc.childNodes[0]; } + icon.setAttribute('height', '1em'); + icon.setAttribute('width', '1em'); + return icon; }; diff --git a/src/fonts/ploticon/ploticon.svg b/src/fonts/ploticon/ploticon.svg index e8fbfcd1e50..663b45ee7a3 100644 --- a/src/fonts/ploticon/ploticon.svg +++ b/src/fonts/ploticon/ploticon.svg @@ -28,18 +28,36 @@ - + diff --git a/tasks/util/pull_font_svg.js b/tasks/util/pull_font_svg.js index 2903153badc..5fe807d6de4 100644 --- a/tasks/util/pull_font_svg.js +++ b/tasks/util/pull_font_svg.js @@ -2,7 +2,7 @@ var fs = require('fs'); var xml2js = require('xml2js'); var parser = new xml2js.Parser(); -var builder = new xml2js.Builder({ headless: true, rootName: 'g', renderOpts: {'newline': ''}}); +var builder = new xml2js.Builder({ headless: true, rootName: 'svg', renderOpts: {'newline': ''}}); module.exports = function pullFontSVG(data, pathOut) { parser.parseString(data, function(err, result) { @@ -29,17 +29,13 @@ module.exports = function pullFontSVG(data, pathOut) { }); // Load SVG - var svgs = result.svg.defs[0].g; - svgs.forEach(function(g) { - var name = g.$.id, - width = parseFloat(g.$['data-width']), - height = parseFloat(g.$['data-height']); - delete g.$; + var svgs = result.svg.defs[0].svg; + svgs.forEach(function(svg) { + var name = svg.$.id; + delete svg.$.id; chars[name] = { name: name, - width: width, - height: height, - svg: builder.buildObject(g) + svg: builder.buildObject(svg) }; });