@@ -253,9 +253,9 @@ def _update_bbox(self, x1, y1, x2, y2):
253
253
254
254
def render_glyph (self , ox , oy , info ):
255
255
self ._update_bbox (ox + info .metrics .xmin ,
256
- oy + info .metrics .ymin ,
256
+ oy - info .metrics .ymax ,
257
257
ox + info .metrics .xmax ,
258
- oy + info .metrics .ymax )
258
+ oy - info .metrics .ymin )
259
259
260
260
def render_rect_filled (self , x1 , y1 , x2 , y2 ):
261
261
self ._update_bbox (x1 , y1 , x2 , y2 )
@@ -265,7 +265,8 @@ def get_results(self, box):
265
265
bbox = self .bbox
266
266
bbox = [bbox [0 ] - 2 , bbox [1 ] - 2 , bbox [2 ] + 2 , bbox [3 ] + 2 ]
267
267
self ._switch_to_real_backend ()
268
- self .fonts_object .set_canvas_size (bbox [2 ] - bbox [0 ], bbox [3 ] - bbox [1 ])
268
+ self .fonts_object .set_canvas_size (
269
+ bbox [2 ] - bbox [0 ], bbox [3 ] - bbox [1 ])
269
270
ship (- bbox [0 ], - bbox [1 ], box )
270
271
return self .fonts_object .get_results (box )
271
272
@@ -321,6 +322,8 @@ def render_glyph(self, ox, oy, info):
321
322
fontsize = info .fontsize
322
323
symbol_name = info .symbol_name
323
324
325
+ # TODO: Optimize out the font changes
326
+
324
327
ps = """/%(postscript_name)s findfont
325
328
%(fontsize)s scalefont
326
329
setfont
@@ -928,7 +931,7 @@ def _get_info (self, fontname, sym, fontsize, dpi):
928
931
xmin , ymin , xmax , ymax = [val * scale
929
932
for val in font .get_bbox_char (glyph )]
930
933
metrics = Bunch (
931
- advance = ( xmax - xmin ) ,
934
+ advance = font . get_width_char ( glyph ) * scale ,
932
935
width = font .get_width_char (glyph ) * scale ,
933
936
height = font .get_height_char (glyph ) * scale ,
934
937
xmin = xmin ,
@@ -2439,6 +2442,7 @@ def parse(self, s, dpi, prop):
2439
2442
cacheKey = (s , dpi , hash (prop ))
2440
2443
result = self ._cache .get (cacheKey )
2441
2444
if result is not None :
2445
+ del self ._cache [cacheKey ]
2442
2446
return result
2443
2447
2444
2448
if self ._output == 'PS' and rcParams ['ps.useafm' ]:
0 commit comments