Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commite6a3d16

Browse files
authored
Merge pull request#15577 from meeseeksmachine/auto-backport-of-pr-14705-on-v3.2.x
Backport PR#14705 on branch v3.2.x (Correctly size non-ASCII characters in agg backend.)
2 parents3c578f6 +f1c50ac commite6a3d16

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

‎lib/matplotlib/backends/backend_agg.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
178178

179179
iffontisNone:
180180
returnNone
181-
iflen(s)==1andord(s)>127:
182-
font.load_char(ord(s),flags=flags)
183-
else:
184-
# We pass '0' for angle here, since it will be rotated (in raster
185-
# space) in the following call to draw_text_image).
186-
font.set_text(s,0,flags=flags)
181+
# We pass '0' for angle here, since it will be rotated (in raster
182+
# space) in the following call to draw_text_image).
183+
font.set_text(s,0,flags=flags)
187184
font.draw_glyphs_to_bitmap(antialiased=rcParams['text.antialiased'])
188185
d=font.get_descent()/64.0
189186
# The descent needs to be adjusted for the angle.

‎lib/matplotlib/tests/test_text.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
frommatplotlib.backend_basesimportMouseEvent
1010
importmatplotlib.patchesasmpatches
1111
importmatplotlib.pyplotasplt
12-
frommatplotlib.testing.decoratorsimportimage_comparison
12+
frommatplotlib.testing.decoratorsimportcheck_figures_equal,image_comparison
1313

1414

1515
needs_usetex=pytest.mark.skipif(
@@ -621,3 +621,17 @@ def test_wrap_no_wrap():
621621
text=fig.text(0,0,'non wrapped text',wrap=True)
622622
fig.canvas.draw()
623623
asserttext._get_wrapped_text()=='non wrapped text'
624+
625+
626+
@check_figures_equal(extensions=["png"])
627+
deftest_buffer_size(fig_test,fig_ref):
628+
# On old versions of the Agg renderer, large non-ascii single-character
629+
# strings (here, "€") would be rendered clipped because the rendering
630+
# buffer would be set by the physical size of the smaller "a" character.
631+
ax=fig_test.add_subplot()
632+
ax.set_yticks([0,1])
633+
ax.set_yticklabels(["€","a"])
634+
ax.yaxis.majorTicks[1].label1.set_color("w")
635+
ax=fig_ref.add_subplot()
636+
ax.set_yticks([0,1])
637+
ax.set_yticklabels(["€",""])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp