From a7341b9edcec579f2aa0be2a6d27b39fb194cedf Mon Sep 17 00:00:00 2001 From: etpinard Date: Fri, 11 Dec 2015 12:33:26 -0500 Subject: [PATCH 1/3] make "Open Sans" (with two capital letters) standard --- src/plots/layout_attributes.js | 2 +- src/plots/plots.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plots/layout_attributes.js b/src/plots/layout_attributes.js index 3362a1b0526..cf6684b6a04 100644 --- a/src/plots/layout_attributes.js +++ b/src/plots/layout_attributes.js @@ -18,7 +18,7 @@ var extendFlat = Plotly.Lib.extendFlat; module.exports = { font: { family: extendFlat({}, fontAttrs.family, { - dflt: '"Open sans", verdana, arial, sans-serif' + dflt: '"Open Sans", verdana, arial, sans-serif' }), size: extendFlat({}, fontAttrs.size, { dflt: 12 diff --git a/src/plots/plots.js b/src/plots/plots.js index ecf1bf8cafd..f83e424769b 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -288,8 +288,8 @@ plots.addLinks = function(gd) { linkContainer.enter().append('text') .classed('js-plot-link-container', true) .style({ - 'font-family':'"Open Sans",Arial,sans-serif', - 'font-size':'12px', + 'font-family':'"Open Sans", Arial, sans-serif', + 'font-size': '12px', 'fill': Plotly.Color.defaultLine, 'pointer-events': 'all' }) From b729a596a0bef1e46af6981f3461b604ebeda5d1 Mon Sep 17 00:00:00 2001 From: etpinard Date: Fri, 11 Dec 2015 12:34:46 -0500 Subject: [PATCH 2/3] replace " for \' when wrapping font-family in to-svg step --- src/snapshot/tosvg.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snapshot/tosvg.js b/src/snapshot/tosvg.js index 4ba8396a829..148f204cf24 100644 --- a/src/snapshot/tosvg.js +++ b/src/snapshot/tosvg.js @@ -114,7 +114,7 @@ module.exports = function toSVG(gd, format) { // Is this an IE thing? Any other attributes or style elements that can have quotes in them? // TODO: this looks like a noop right now - what happened to it? var ff = txt.style('font-family'); - if(ff && ff.indexOf('"') !== -1) txt.style('font-family', ff.replace(/"/g, '"')); + if(ff && ff.indexOf('"') !== -1) txt.style('font-family', ff.replace(/"/g, '\\\'')); }); if(format === 'pdf' || format === 'eps') { From 7e21ea7cebdf55789c15dd356da300c8a610fd40 Mon Sep 17 00:00:00 2001 From: etpinard Date: Mon, 14 Dec 2015 09:57:59 -0500 Subject: [PATCH 3/3] add comment about font-family "\' \'" --- src/snapshot/tosvg.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/snapshot/tosvg.js b/src/snapshot/tosvg.js index 148f204cf24..bc2c779241e 100644 --- a/src/snapshot/tosvg.js +++ b/src/snapshot/tosvg.js @@ -113,8 +113,21 @@ module.exports = function toSVG(gd, format) { // serialized svg because the style attribute itself is double-quoted! // Is this an IE thing? Any other attributes or style elements that can have quotes in them? // TODO: this looks like a noop right now - what happened to it? + + /* + * Font-family styles with double quotes in them breaks the to-image + * step in FF42 because the style attribute itself is wrapped in + * double quotes. See: + * + * - http://codepen.io/etpinard/pen/bEdQWK + * - https://github.com/plotly/plotly.js/pull/104 + * + * for more info. + */ var ff = txt.style('font-family'); - if(ff && ff.indexOf('"') !== -1) txt.style('font-family', ff.replace(/"/g, '\\\'')); + if(ff && ff.indexOf('"') !== -1) { + txt.style('font-family', ff.replace(/"/g, '\\\'')); + } }); if(format === 'pdf' || format === 'eps') {