8000 Merge pull request #17484 from anntzer/ismath_tex · QuLogic/matplotlib@69e651f · GitHub
[go: up one dir, main page]

Skip to content

Commit 69e651f

Browse files
authored
Merge pull request matplotlib#17484 from anntzer/ismath_tex
Deprecate ismath parameter to draw_tex and ismath="TeX!".
2 parents 51a1940 + f5e6f5d commit 69e651f

File tree

7 files changed

+27
-4
lines changed

7 files changed

+27
-4
lines changed

doc/api/api_changes_3.3/deprecations.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,3 +576,16 @@ Statusbar classes and attributes
576576
The ``statusbar`` attribute of `.FigureManagerBase`, `.StatusbarBase` and all
577577
its subclasses, and ``StatusBarWx``, are deprecated, as messages are now
578578
displayed in the toolbar instead.
579+
580+
``ismath`` parameter of ``draw_tex``
581+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
582+
The ``ismath`` parameter of the ``draw_tex`` method of all renderer classes is
583+
deprecated (as a call to ``draw_tex`` -- not to be confused with ``draw_text``!
584+
-- means that the entire string should be passed to the ``usetex`` machinery
585+
anyways). Likewise, the text machinery will no longer pass the ``ismath``
586+
parameter when calling ``draw_tex`` (this should only matter for backend
587+
implementers).
588+
589+
Passing ``ismath="TeX!"`` to `.RendererAgg.get_text_width_height_descent` is
590+
deprecated. Pass ``ismath="TeX"`` instead, consistently with other low-level
591+
APIs which support the values True, False, and "TeX" for ``ismath``.

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ def option_scale_image(self):
503503
"""
504504
return False
505505

506+
@cbook._delete_parameter("3.3", "ismath")
506507
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
507508
"""
508509
"""

lib/matplotlib/backends/backend_agg.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ def get_text_width_height_descent(self, s, prop, ismath):
216216
# docstring inherited
217217

218218
if ismath in ["TeX", "TeX!"]:
219+
if ismath == "TeX!":
220+
cbook._warn_deprecated(
221+
"3.3", message="Support for ismath='TeX!' is deprecated "
222+
"since %(since)s and will be removed %(removal)s; use "
223+
"ismath='TeX' instead.")
219224
# todo: handle props
220225
texmanager = self.get_texmanager()
221226
fontsize = prop.get_size_in_points()
@@ -238,6 +243,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
238243
d /= 64.0
239244
return w, h, d
240245

246+
@cbook._delete_parameter("3.2", "ismath")
241247
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
242248
# docstring inherited
243249
# todo, handle props, angle, origins
@@ -248,7 +254,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
248254
Z = texmanager.get_grey(s, size, self.dpi)
249255
Z = np.array(Z * 255.0, np.uint8)
250256

251-
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
257+
w, h, d = self.get_text_width_height_descent(s, prop, ismath="TeX")
252258
xd = d * sin(radians(angle))
253259
yd = d * cos(radians(angle))
254260
x = round(x + xd)

lib/matplotlib/backends/backend_pdf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
20032003
# Pop off the global transformation
20042004
self.file.output(Op.grestore)
20052005

2006+
@cbook._delete_parameter("3.3", "ismath")
20062007
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
20072008
# docstring inherited
20082009
texmanager = self.get_texmanager()

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
467467

468468
self._path_collection_id += 1
469469

470+
@cbook._delete_parameter("3.3", "ismath")
470471
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
471472
# docstring inherited
472473
if not hasattr(self, "psfrag"):
@@ -475,10 +476,10 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
475476
"rcParams['text.usetex'] and does not support having "
476477
"usetex=True only for some elements; this element will thus "
477478
"be rendered as if usetex=False.")
478-
self.draw_text(gc, x, y, s, prop, angle, ismath, mtext)
479+
self.draw_text(gc, x, y, s, prop, angle, False, mtext)
479480
return
480481

481-
w, h, bl = self.get_text_width_height_descent(s, prop, ismath)
482+
w, h, bl = self.get_text_width_height_descent(s, prop, ismath="TeX")
482483
fontsize = prop.get_size_in_points()
483484
thetext = 'psmarker%d' % self.textcnt
484485
color = '%1.3f,%1.3f,%1.3f' % gc.get_rgb()[:3]

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
11141114

11151115
writer.end('g')
11161116

1117+
@cbook._delete_parameter("3.3", "ismath")
11171118
def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
11181119
# docstring inherited
11191120
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")

lib/matplotlib/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def draw(self, renderer):
720720
if textobj.get_usetex():
721721
textrenderer.draw_tex(gc, x, y, clean_line,
722722
textobj._fontproperties, angle,
723-
ismath=ismath, mtext=mtext)
723+
mtext=mtext)
724724
else:
725725
textrenderer.draw_text(gc, x, y, clean_line,
726726
textobj._fontproperties, angle,

0 commit comments

Comments
 (0)
0