@@ -581,7 +581,7 @@ def embedType1(self, filename, fontinfo):
581581 'CapHeight' : 1000 , # default guess if missing from AFM file
582582 'XHeight' : afmdata .get_xheight (),
583583 'FontFile' : fontfileObject ,
584- 'FontFamily' : Name ( familyname ) ,
584+ 'FontFamily' : familyname ,
585585 #'FontWeight': a number where 400 = Regular, 700 = Bold
586586 }
587587 try :
@@ -1422,7 +1422,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
14221422 self .file .output (Op .grestore )
14231423
14241424 def _draw_tex (self , gc , x , y , s , prop , angle ):
1425- # Rename to draw_tex to enable, but it doesn't work at the moment
1425+ # Rename to draw_tex to enable
14261426
14271427 texmanager = self .get_texmanager ()
14281428 fontsize = prop .get_size_in_points ()
@@ -1606,6 +1606,19 @@ def draw_text_woven(chunks):
16061606 return draw_text_woven (chunks )
16071607
16081608 def get_text_width_height_descent (self , s , prop , ismath ):
1609+ if rcParams ['text.usetex' ]:
1610+ texmanager = self .get_texmanager ()
1611+ fontsize = prop .get_size_in_points ()
1612+ dvifile = texmanager .make_dvi (s , fontsize )
1613+ dvi = dviread .Dvi (dvifile , 72 )
1614+ text , boxes = iter (dvi ).next ()
1615+ # TODO: better bounding box -- this is not quite right:
1616+ l = min (p [0 ] for p in text + boxes )
1617+ r = max (p [0 ] for p in text + boxes ) + fontsize
1618+ b = min (p [1 ] for p in text + boxes )
1619+ t = max (p [1 ] for p in text + boxes ) + fontsize
1620+ # (not to even mention finding the baseline)
1621+ return r - l , t - b , t - b
16091622 if ismath :
16101623 w , h , d , glyphs , rects , used_characters = \
16111624 self .mathtext_parser .parse (s , 72 , prop )
0 commit comments