diff --git a/lib/matplotlib/backends/backend_agg.py b/lib/matplotlib/backends/backend_agg.py index f41478661e79..67e80611ef10 100644 --- a/lib/matplotlib/backends/backend_agg.py +++ b/lib/matplotlib/backends/backend_agg.py @@ -178,12 +178,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): if font is None: return None - if len(s) == 1 and ord(s) > 127: - font.load_char(ord(s), flags=flags) - else: - # We pass '0' for angle here, since it will be rotated (in raster - # space) in the following call to draw_text_image). - font.set_text(s, 0, flags=flags) + # We pass '0' for angle here, since it will be rotated (in raster + # space) in the following call to draw_text_image). + font.set_text(s, 0, flags=flags) font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased']) d = font.get_descent() / 64.0 # The descent needs to be adjusted for the angle. diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index fb2d62e075a3..20d3a3ee3d64 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -9,7 +9,7 @@ from matplotlib.backend_bases import MouseEvent import matplotlib.patches as mpatches import matplotlib.pyplot as plt -from matplotlib.testing.decorators import image_comparison +from matplotlib.testing.decorators import check_figures_equal, image_comparison needs_usetex = pytest.mark.skipif( @@ -621,3 +621,17 @@ def test_wrap_no_wrap(): text = fig.text(0, 0, 'non wrapped text', wrap=True) fig.canvas.draw() assert text._get_wrapped_text() == 'non wrapped text' + + +@check_figures_equal(extensions=["png"]) +def test_buffer_size(fig_test, fig_ref): + # On old versions of the Agg renderer, large non-ascii single-character + # strings (here, "€") would be rendered clipped because the rendering + # buffer would be set by the physical size of the smaller "a" character. + ax = fig_test.add_subplot() + ax.set_yticks([0, 1]) + ax.set_yticklabels(["€", "a"]) + ax.yaxis.majorTicks[1].label1.set_color("w") + ax = fig_ref.add_subplot() + ax.set_yticks([0, 1]) + ax.set_yticklabels(["€", ""])