Skip to content

Commit

Permalink
Fix font sizes when displaying SVGs with fonttype "none" or "svgfont"…
Browse files Browse the repository at this point in the history
… in Firefox. Closes matplotlib#510.
  • Loading branch information
mdboom committed Oct 6, 2011
1 parent 4f71782 commit 0fc9830
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0fc9830

Please sign in to comment.