Skip to content

Commit e8e7854

Browse files
committed
Merge pull request #104 from plotly/firefox-toImage
Fix Firefox toImage failures
2 parents edcfe7e + 7e21ea7 commit e8e7854

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/plots/layout_attributes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var extendFlat = Plotly.Lib.extendFlat;
1818
module.exports = {
1919
font: {
2020
family: extendFlat({}, fontAttrs.family, {
21-
dflt: '"Open sans", verdana, arial, sans-serif'
21+
dflt: '"Open Sans", verdana, arial, sans-serif'
2222
}),
2323
size: extendFlat({}, fontAttrs.size, {
2424
dflt: 12

src/plots/plots.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ plots.addLinks = function(gd) {
288288
linkContainer.enter().append('text')
289289
.classed('js-plot-link-container', true)
290290
.style({
291-
'font-family':'"Open Sans",Arial,sans-serif',
292-
'font-size':'12px',
291+
'font-family':'"Open Sans", Arial, sans-serif',
292+
'font-size': '12px',
293293
'fill': Plotly.Color.defaultLine,
294294
'pointer-events': 'all'
295295
})

src/snapshot/tosvg.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,21 @@ module.exports = function toSVG(gd, format) {
113113
// serialized svg because the style attribute itself is double-quoted!
114114
// Is this an IE thing? Any other attributes or style elements that can have quotes in them?
115115
// TODO: this looks like a noop right now - what happened to it?
116+
117+
/*
118+
* Font-family styles with double quotes in them breaks the to-image
119+
* step in FF42 because the style attribute itself is wrapped in
120+
* double quotes. See:
121+
*
122+
* - http://codepen.io/etpinard/pen/bEdQWK
123+
* - https://github.com/plotly/plotly.js/pull/104
124+
*
125+
* for more info.
126+
*/
116127
var ff = txt.style('font-family');
117-
if(ff && ff.indexOf('"') !== -1) txt.style('font-family', ff.replace(/"/g, '"'));
128+
if(ff && ff.indexOf('"') !== -1) {
129+
txt.style('font-family', ff.replace(/"/g, '\\\''));
130+
}
118131
});
119132

120133
if(format === 'pdf' || format === 'eps') {

0 commit comments

Comments
 (0)