Skip to content

Commit c428aaa

Browse files
authored
Merge pull request matplotlib#31959 from meeseeksmachine/auto-backport-of-pr-31910-on-v3.11.x
Backport PR matplotlib#31910 on branch v3.11.x (FIX: Add mtext into RendererBase._draw_as_path() arguments)
2 parents 517a456 + 3ec62ff commit c428aaa

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
506506
mtext : `~matplotlib.text.Text`
507507
The original text object to be rendered.
508508
"""
509-
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
509+
self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX", mtext=mtext)
510510

511511
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
512512
"""

lib/matplotlib/tests/test_usetex.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ def test_usetex():
4343
ax.set_axis_off()
4444

4545

46+
def test_usetex_fallback(monkeypatch):
47+
# Smoke test that the base draw_tex implementation works.
48+
from matplotlib.backend_bases import RendererBase
49+
from matplotlib.backends.backend_agg import RendererAgg
50+
monkeypatch.setattr(RendererAgg, 'draw_tex', RendererBase.draw_tex)
51+
52+
plt.rcParams["text.usetex"] = True
53+
fig, ax = plt.subplots()
54+
ax.text(0, 0, "foo_bar")
55+
fig.canvas.draw()
56+
57+
4658
@check_figures_equal(extensions=['png', 'pdf', 'svg'])
4759
def test_empty(fig_test, fig_ref):
4860
mpl.rcParams['text.usetex'] = True

0 commit comments

Comments
 (0)