@@ -102,6 +102,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
102
102
d /= 64.0
103
103
return w * scale , h * scale , d * scale
104
104
105
+ @cbook ._delete_parameter ("3.1" , "usetex" )
105
106
def get_text_path (self , prop , s , ismath = False , usetex = False ):
106
107
"""
107
108
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):
116
117
s : str
117
118
The text to be converted.
118
119
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 .
121
122
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.
125
125
126
126
Returns
127
127
-------
@@ -146,16 +146,15 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
146
146
147
147
Also see `TextPath` for a more direct way to create a path from a text.
148
148
"""
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" :
158
152
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 )
159
158
160
159
verts , codes = [], []
161
160
@@ -448,6 +447,8 @@ def __init__(self, xy, s, size=None, prop=None,
448
447
449
448
Also see :doc:`/gallery/text_labels_and_annotations/demo_text_path`.
450
449
"""
450
+ # Circular import.
451
+ from matplotlib .text import Text
451
452
452
453
if args or kwargs :
453
454
cbook .warn_deprecated (
@@ -463,8 +464,13 @@ def __init__(self, xy, s, size=None, prop=None,
463
464
self .set_size (size )
464
465
465
466
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 )
468
474
self ._should_simplify = False
469
475
self ._simplify_threshold = rcParams ['path.simplify_threshold' ]
470
476
self ._interpolation_steps = _interpolation_steps
@@ -507,6 +513,7 @@ def _revalidate_path(self):
507
513
self ._cached_vertices = tr .transform (self ._vertices )
508
514
self ._invalid = False
509
515
516
+ @cbook .deprecated ("3.1" )
510
517
def is_math_text (self , s ):
511
518
"""
512
519
Returns True if the given string *s* contains any mathtext.
@@ -526,6 +533,7 @@ def is_math_text(self, s):
526
533
else :
527
534
return s .replace (r'\$' , '$' ), False
528
535
536
+ @cbook .deprecated ("3.1" , alternative = "TextPath" )
529
537
def text_get_vertices_codes (self , prop , s , usetex ):
530
538
"""
531
539
Convert string *s* to a (vertices, codes) pair using font property
0 commit comments