From 0fc9830fe946f6221e9ceff2910cd0c2118b0965 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 6 Oct 2011 11:55:41 -0400 Subject: [PATCH] Fix font sizes when displaying SVGs with fonttype "none" or "svgfont" in Firefox. Closes #510. --- lib/matplotlib/backends/backend_svg.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/backends/backend_svg.py b/lib/matplotlib/backends/backend_svg.py index 7ac7ce87b1c5..b6542eecba63 100644 --- a/lib/matplotlib/backends/backend_svg.py +++ b/lib/matplotlib/backends/backend_svg.py @@ -331,7 +331,7 @@ def _get_hatch(self, gc, rgbFace): else: _, oid = oid return oid - + def _write_hatches(self): if not len(self._hatchd): return @@ -445,7 +445,7 @@ def _write_clips(self): writer.element('rect', x=str(x), y=str(y), width=str(w), height=str(h)) writer.end('clipPath') writer.end('defs') - + def _write_svgfonts(self): if not rcParams['svg.fonttype'] == 'svgfont': return @@ -926,7 +926,8 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath): fontstyle = prop.get_style() attrib = {} - style['font-size'] = str(fontsize) + # Must add "px" to workaround a Firefox bug + style['font-size'] = str(fontsize) + 'px' style['font-family'] = str(fontfamily) style['font-style'] = prop.get_style().lower() attrib['style'] = generate_css(style) @@ -967,7 +968,8 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath): spans = {} for font, fontsize, thetext, new_x, new_y, metrics in svg_glyphs: style = generate_css({ - 'font-size': str(fontsize), + # Must add "px" to work around a Firefox bug + 'font-size': str(fontsize) + 'px', 'font-family': font.family_name, 'font-style': font.style_name.lower()}) if thetext == 32: