Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f5e6f5d

Browse filesBrowse files
committed
Deprecate ismath parameter to draw_tex and ismath="TeX!".
This parameter is a bit confusing for backend implementers and actually effectively ignored (because draw_tex() already means "pass the entire string to usetex). Calling through draw_tex() was the only way, previously, to get `ismath="TeX!"` passed to `get_text_width_height_descent` (other than calling it manually), but that was handled identically to `ismath="TeX"` by some backends and just not supported by others. Again, folding "TeX!" into "TeX" makes the required API simpler for backend implementers.
1 parent 5ab1352 commit f5e6f5d
Copy full SHA for f5e6f5d

File tree

7 files changed

+27
-4
lines changed
Filter options

7 files changed

+27
-4
lines changed

‎doc/api/api_changes_3.3/deprecations.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes_3.3/deprecations.rst
+13Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_agg.py
+7-1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+3-2Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/text.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def draw(self, renderer):
726726
if textobj.get_usetex():
727727
textrenderer.draw_tex(gc, x, y, clean_line,
728728
textobj._fontproperties, angle,
729-
ismath=ismath, mtext=mtext)
729+
mtext=mtext)
730730
else:
731731
textrenderer.draw_text(gc, x, y, clean_line,
732732
textobj._fontproperties, angle,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.