@@ -102,6 +102,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
102102 d /= 64.0
103103 return w * scale , h * scale , d * scale
104104
105+ @cbook ._delete_parameter ("3.1" , "usetex" )
105106 def get_text_path (self , prop , s , ismath = False , usetex = False ):
106107 """
107108 Convert text *s* to path (a tuple of vertices and codes for
@@ -116,12 +117,11 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
116117 s : str
117118 The text to be converted.
118119
119- usetex : bool, optional
120- Whether to use tex rendering. Defaults to ``False`` .
120+ ismath : {False, True, "TeX"}
121+ If True, use mathtext parser. If "TeX", use tex for renderering .
121122
122- ismath : bool, optional
123- If True, use mathtext parser. Effective only if
124- ``usetex == False``.
123+ usetex : bool, optional
124+ If set, forces *ismath* to True. This parameter is deprecated.
125125
126126 Returns
127127 -------
@@ -146,16 +146,15 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
146146
147147 Also see `TextPath` for a more direct way to create a path from a text.
148148 """
149- if not usetex :
150- if not ismath :
151- font = self ._get_font (prop )
152- glyph_info , glyph_map , rects = self .get_glyphs_with_font (
153- font , s )
154- else :
155- glyph_info , glyph_map , rects = self .get_glyphs_mathtext (
156- prop , s )
157- else :
149+ if usetex :
150+ ismath = "TeX"
151+ if ismath == "TeX" :
158152 glyph_info , glyph_map , rects = self .get_glyphs_tex (prop , s )
153+ elif not ismath :
154+ font = self ._get_font (prop )
155+ glyph_info , glyph_map , rects = self .get_glyphs_with_font (font , s )
156+ else :
157+ glyph_info , glyph_map , rects = self .get_glyphs_mathtext (prop , s )
159158
160159 verts , codes = [], []
161160
@@ -448,6 +447,8 @@ def __init__(self, xy, s, size=None, prop=None,
448447
449448 Also see :doc:`/gallery/text_labels_and_annotations/demo_text_path`.
450449 """
450+ # Circular import.
451+ from matplotlib .text import Text
451452
452453 if args or kwargs :
453454 cbook .warn_deprecated (
@@ -463,8 +464,13 @@ def __init__(self, xy, s, size=None, prop=None,
463464 self .set_size (size )
464465
465466 self ._cached_vertices = None
466- self ._vertices , self ._codes = \
467- self .text_get_vertices_codes (prop , s , usetex = usetex )
467+ s , ismath = Text (usetex = usetex )._preprocess_math (s )
468+ if ismath == "TeX" :
469+ self ._vertices , self ._codes = text_to_path .get_text_path (
470+ prop , s , usetex = True )
471+ else :
472+ self ._vertices , self ._codes = text_to_path .get_text_path (
473+ prop , s , ismath = ismath )
468474 self ._should_simplify = False
469475 self ._simplify_threshold = rcParams ['path.simplify_threshold' ]
470476 self ._interpolation_steps = _interpolation_steps
@@ -507,6 +513,7 @@ def _revalidate_path(self):
507513 self ._cached_vertices = tr .transform (self ._vertices )
508514 self ._invalid = False
509515
516+ @cbook .deprecated ("3.1" )
510517 def is_math_text (self , s ):
511518 """
512519 Returns True if the given string *s* contains any mathtext.
@@ -526,6 +533,7 @@ def is_math_text(self, s):
526533 else :
527534 return s .replace (r'\$' , '$' ), False
528535
536+ @cbook .deprecated ("3.1" , alternative = "TextPath" )
529537 def text_get_vertices_codes (self , prop , s , usetex ):
530538 """
531539 Convert string *s* to a (vertices, codes) pair using font property
0 commit comments