55
66import numpy as np
77
8- from matplotlib import _text_helpers , dviread , font_manager
8+ from matplotlib import _api , _text_helpers , dviread , font_manager
99from matplotlib .font_manager import FontProperties , get_font
1010from matplotlib .ft2font import LOAD_NO_HINTING , LOAD_TARGET_LIGHT
1111from matplotlib .mathtext import MathTextParser
1212from matplotlib .path import Path
13+ from matplotlib .texmanager import TexManager
1314from matplotlib .transforms import Affine2D
1415
1516_log = logging .getLogger (__name__ )
@@ -44,14 +45,11 @@ def _get_char_id(self, font, ccode):
4445 return urllib .parse .quote (f"{ font .postscript_name } -{ ccode :x} " )
4546
4647 def get_text_width_height_descent (self , s , prop , ismath ):
48+ fontsize = prop .get_size_in_points ()
49+
4750 if ismath == "TeX" :
48- texmanager = self .get_texmanager ()
49- fontsize = prop .get_size_in_points ()
50- w , h , d = texmanager .get_text_width_height_descent (s , fontsize ,
51- renderer = None )
52- return w , h , d
51+ return TexManager ().get_text_width_height_descent (s , fontsize )
5352
54- fontsize = prop .get_size_in_points ()
5553 scale = fontsize / self .FONT_SCALE
5654
5755 if ismath :
@@ -215,10 +213,10 @@ def get_glyphs_mathtext(self, prop, s, glyph_map=None,
215213 return (list (zip (glyph_ids , xpositions , ypositions , sizes )),
216214 glyph_map_new , myrects )
217215
216+ @_api .deprecated ("3.6" , alternative = "TexManager()" )
218217 def get_texmanager (self ):
219218 """Return the cached `~.texmanager.TexManager` instance."""
220219 if self ._texmanager is None :
221- from matplotlib .texmanager import TexManager
222220 self ._texmanager = TexManager ()
223221 return self ._texmanager
224222
@@ -227,7 +225,7 @@ def get_glyphs_tex(self, prop, s, glyph_map=None,
227225 """Convert the string *s* to vertices and codes using usetex mode."""
228226 # Mostly borrowed from pdf backend.
229227
230- dvifile = self . get_texmanager ().make_dvi (s , self .FONT_SCALE )
228+ dvifile = TexManager ().make_dvi (s , self .FONT_SCALE )
231229 with dviread .Dvi (dvifile , self .DPI ) as dvi :
232230 page , = dvi
233231
0 commit comments