@@ -294,7 +294,6 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72,
294
294
self ._has_gouraud = False
295
295
self ._n_gradients = 0
296
296
self ._fonts = OrderedDict ()
297
- self .mathtext_parser = MathTextParser ('SVG' )
298
297
299
298
RendererBase .__init__ (self )
300
299
self ._glyph_map = dict ()
@@ -312,6 +311,11 @@ def __init__(self, width, height, svgwriter, basename=None, image_dpi=72,
312
311
self ._write_metadata (metadata )
313
312
self ._write_default_style ()
314
313
314
+ @cbook .deprecated ("3.4" )
315
+ @property
316
+ def mathtext_parser (self ):
317
+ return MathTextParser ('SVG' )
318
+
315
319
def finalize (self ):
316
320
self ._write_clips ()
317
321
self ._write_hatches ()
@@ -1162,26 +1166,23 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
1162
1166
else :
1163
1167
writer .comment (s )
1164
1168
1165
- width , height , descent , svg_elements , used_characters = \
1166
- self .mathtext_parser .parse (s , 72 , prop )
1167
- svg_glyphs = svg_elements .svg_glyphs
1168
- svg_rects = svg_elements .svg_rects
1169
-
1170
- attrib = {}
1171
- attrib ['style' ] = generate_css (style )
1172
- attrib ['transform' ] = generate_transform ([
1173
- ('translate' , (x , y )),
1174
- ('rotate' , (- angle ,))])
1169
+ width , height , descent , glyphs , rects = \
1170
+ self ._text2path .mathtext_parser .parse (s , 72 , prop )
1175
1171
1176
1172
# Apply attributes to 'g', not 'text', because we likely have some
1177
1173
# rectangles as well with the same style and transformation.
1178
- writer .start ('g' , attrib = attrib )
1174
+ writer .start ('g' ,
1175
+ style = generate_css (style ),
1176
+ transform = generate_transform ([
1177
+ ('translate' , (x , y )),
1178
+ ('rotate' , (- angle ,))]),
1179
+ )
1179
1180
1180
1181
writer .start ('text' )
1181
1182
1182
1183
# Sort the characters by font, and output one tspan for each.
1183
1184
spans = OrderedDict ()
1184
- for font , fontsize , thetext , new_x , new_y , metrics in svg_glyphs :
1185
+ for font , fontsize , thetext , new_x , new_y in glyphs :
1185
1186
style = generate_css ({
1186
1187
'font-size' : short_float_fmt (fontsize ) + 'px' ,
1187
1188
'font-family' : font .family_name ,
@@ -1212,15 +1213,14 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
1212
1213
1213
1214
writer .end ('text' )
1214
1215
1215
- if len (svg_rects ):
1216
- for x , y , width , height in svg_rects :
1217
- writer .element (
1218
- 'rect' ,
1219
- x = short_float_fmt (x ),
1220
- y = short_float_fmt (- y + height ),
1221
- width = short_float_fmt (width ),
1222
- height = short_float_fmt (height )
1223
- )
1216
+ for x , y , width , height in rects :
1217
+ writer .element (
1218
+ 'rect' ,
1219
+ x = short_float_fmt (x ),
1220
+ y = short_float_fmt (- y - 1 ),
1221
+ width = short_float_fmt (width ),
1222
+ height = short_float_fmt (height )
1223
+ )
1224
1224
1225
1225
writer .end ('g' )
1226
1226
0 commit comments