@@ -172,7 +172,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
172172 """
173173 if __debug__ : verbose .report ('RendererAgg.draw_mathtext' ,
174174 'debug-annoying' )
175- ox , oy , width , height , fonts , used_characters = \
175+ ox , oy , width , height , descent , fonts , used_characters = \
176176 self .mathtext_parser .parse (s , self .dpi .get (), prop )
177177
178178 if angle == 90 :
@@ -186,7 +186,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
186186 for font in fonts :
187187 if angle == 90 :
188188 font .horiz_image_to_vert_image () # <-- Rotate
189- self ._renderer .draw_text ( font , x , y , gc )
189+ self ._renderer .draw_text ( font , x , y + 1 , gc )
190190 if 0 :
191191 self ._renderer .draw_rectangle (gc , None ,
192192 int (x ),
@@ -212,10 +212,10 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
212212
213213 #print x, y, int(x), int(y)
214214
215- self ._renderer .draw_text (font , int (x ), int (y ), gc )
215+ self ._renderer .draw_text (font , int (x ), int (y ) + 1 , gc )
216216
217217
218- def get_text_width_height (self , s , prop , ismath , rgb = (0 ,0 ,0 )):
218+ def get_text_width_height_descent (self , s , prop , ismath , rgb = (0 ,0 ,0 )):
219219 """
220220 get the width and height in display coords of the string s
221221 with FontPropertry prop
@@ -233,15 +233,17 @@ def get_text_width_height(self, s, prop, ismath, rgb=(0,0,0)):
233233 return n ,m
234234
235235 if ismath :
236- ox , oy , width , height , fonts , used_characters = \
236+ ox , oy , width , height , descent , fonts , used_characters = \
237237 self .mathtext_parser .parse (s , self .dpi .get (), prop )
238- return width , height
238+ return width , height , depth
239239 font = self ._get_agg_font (prop )
240240 font .set_text (s , 0.0 , flags = LOAD_DEFAULT ) # the width and height of unrotated string
241241 w , h = font .get_width_height ()
242+ d = font .get_descent ()
242243 w /= 64.0 # convert from subpixels
243244 h /= 64.0
244- return w , h
245+ d /= 64.0
246+ return w , h , d
245247
246248 def draw_tex (self , gc , x , y , s , prop , angle ):
247249 # todo, handle props, angle, origins
@@ -250,7 +252,7 @@ def draw_tex(self, gc, x, y, s, prop, angle):
250252 dpi = self .dpi .get ()
251253
252254 flip = angle == 90
253- w ,h = self .get_text_width_height (s , prop , 'TeX' , rgb )
255+ w ,h , d = self .get_text_width_height_descent (s , prop , 'TeX' , rgb )
254256 if flip :
255257 w ,h = h ,w
256258 x -= w
0 commit comments