1111from matplotlib .ft2font import FT2Font , KERNING_UNFITTED , KERNING_DEFAULT , KERNING_UNSCALED
1212from matplotlib .mathtext import math_parse_s_ft2font_svg
1313
14+ from xml .sax .saxutils import escape as escape_xml_text
15+
1416backend_version = __version__
1517
1618def new_figure_manager (num , * args , ** kwargs ):
@@ -239,7 +241,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
239241
240242 font = self ._get_font (prop )
241243
242- thetext = '%s' % s
244+ thetext = escape_xml_text ( s )
243245 fontfamily = font .family_name
244246 fontstyle = font .style_name
245247 fontsize = prop .get_size_in_points ()
@@ -369,10 +371,7 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
369371 curr_x ,curr_y = 0.0 ,0.0
370372
371373 for font , fontsize , thetext , new_x , new_y_mtc , metrics in svg_glyphs :
372- if rcParams ["mathtext.mathtext2" ]:
373- new_y = new_y_mtc - height
374- else :
375- new_y = - new_y_mtc
374+ new_y = - new_y_mtc
376375
377376 svg .append ('<tspan style="font-size: %f; font-family: %s"' %
378377 (fontsize , font .family_name ))
@@ -387,6 +386,8 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
387386 if dy != 0.0 :
388387 svg .append (' dy="%f"' % dy )
389388
389+ thetext = escape_xml_text (thetext )
390+
390391 svg .append ('>%s</tspan>\n ' % thetext )
391392
392393 curr_x = new_x + xadvance
0 commit comments