diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 27c3752858a7..633ce987269d 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -506,7 +506,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): mtext : `~matplotlib.text.Text` The original text object to be rendered. """ - self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX") + self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX", mtext=mtext) def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): """ diff --git a/lib/matplotlib/tests/test_usetex.py b/lib/matplotlib/tests/test_usetex.py index 6d7506055ce5..55bd72ade5bf 100644 --- a/lib/matplotlib/tests/test_usetex.py +++ b/lib/matplotlib/tests/test_usetex.py @@ -44,6 +44,18 @@ def test_usetex(): ax.set_axis_off() +def test_usetex_fallback(monkeypatch): + # Smoke test that the base draw_tex implementation works. + from matplotlib.backend_bases import RendererBase + from matplotlib.backends.backend_agg import RendererAgg + monkeypatch.setattr(RendererAgg, 'draw_tex', RendererBase.draw_tex) + + plt.rcParams["text.usetex"] = True + fig, ax = plt.subplots() + ax.text(0, 0, "foo_bar") + fig.canvas.draw() + + @check_figures_equal(extensions=['png', 'pdf', 'svg']) def test_empty(fig_test, fig_ref): mpl.rcParams['text.usetex'] = True