def _draw_mathtext(self, gc, x, y, s, prop, angle):
width, height, descent, svg_elements, used_characters =self.mathtext_parser.parse(s, <NUM_LIT>, prop)<EOL>svg_glyphs = svg_elements.svg_glyphs<EOL>svg_rects = svg_elements.svg_rects<EOL>color = rgb2hex(gc.get_rgb()[:<NUM_LIT:3>])<EOL>write = self._svgwriter.write<EOL>style = "<STR_LIT>" % color<EOL>if rcParams['<STR_LIT>']:<EOL><INDENT>new_chars = []<EOL>for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:<EOL><INDENT>path = self._add_char_def(font, thetext)<EOL>if path is not None:<EOL><INDENT>new_chars.append(path)<EOL><DEDENT><DEDENT>if len(new_chars):<EOL><INDENT>write('<STR_LIT>')<EOL>for path in new_chars:<EOL><INDENT>write(path)<EOL><DEDENT>write('<STR_LIT>')<EOL><DEDENT>svg = ['<STR_LIT>' % style]<EOL>if angle != <NUM_LIT:0>:<EOL><INDENT>svg.append('<STR_LIT>'<EOL>% (x,y,-angle) )<EOL><DEDENT>else:<EOL><INDENT>svg.append('<STR_LIT>' % (x, y))<EOL><DEDENT>svg.append('<STR_LIT>')<EOL>for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:<EOL><INDENT>charid = self._get_char_def_id(font, thetext)<EOL>svg.append('<STR_LIT>' %<EOL>(charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))<EOL><DEDENT>svg.append('<STR_LIT>')<EOL><DEDENT>else: <EOL><INDENT>svg = ['<STR_LIT>' % (style, x, y)]<EOL>if angle != <NUM_LIT:0>:<EOL><INDENT>svg.append('<STR_LIT>'<EOL>% (x,y,-angle,-x,-y) ) <EOL><DEDENT>svg.append('<STR_LIT>')<EOL>curr_x,curr_y = <NUM_LIT:0.0>,<NUM_LIT:0.0><EOL>for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:<EOL><INDENT>new_y = - new_y_mtc<EOL>style = "<STR_LIT>" % (fontsize, font.family_name)<EOL>svg.append('<STR_LIT>' % style)<EOL>xadvance = metrics.advance<EOL>svg.append('<STR_LIT>' % xadvance)<EOL>dx = new_x - curr_x<EOL>if dx != <NUM_LIT:0.0>:<EOL><INDENT>svg.append('<STR_LIT>' % dx)<EOL><DEDENT>dy = new_y - curr_y<EOL>if dy != <NUM_LIT:0.0>:<EOL><INDENT>svg.append('<STR_LIT>' % dy)<EOL><DEDENT>thetext = escape_xml_text(thetext)<EOL>svg.append('<STR_LIT>' % thetext)<EOL>curr_x = new_x + xadvance<EOL>curr_y = new_y<EOL><DEDENT>svg.append('<STR_LIT>')<EOL><DEDENT>if len(svg_rects):<EOL><INDENT>style = "<STR_LIT>" % color<EOL>svg.append('<STR_LIT>' % style)<EOL>if angle != <NUM_LIT:0>:<EOL><INDENT>svg.append('<STR_LIT>'<EOL>% (x,y,-angle) )<EOL><DEDENT>else:<EOL><INDENT>svg.append('<STR_LIT>' % (x, y))<EOL><DEDENT>svg.append('<STR_LIT>')<EOL>for x, y, width, height in svg_rects:<EOL><INDENT>svg.append('<STR_LIT>' % (x, -y + height, width, height))<EOL><DEDENT>svg.append("<STR_LIT>")<EOL><DEDENT>self.open_group("<STR_LIT>")<EOL>write ('<STR_LIT>'.join(svg))<EOL>self.close_group("<STR_LIT>")<EOL>
Draw math text using matplotlib.mathtext