Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #23964 on branch v3.6.x (Fix issue with empty line in ps backend) #23994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,9 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
curr_stream[1].append(
(item.x, item.ft_object.get_glyph_name(item.glyph_idx))
)
# append the last entry
stream.append(curr_stream)
# append the last entry if exists
if curr_stream:
stream.append(curr_stream)

self.set_color(*gc.get_rgb())

Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ def test_linedash():
assert buf.tell() > 0


def test_empty_line():
# Smoke-test for gh#23954
figure = Figure()
figure.text(0.5, 0.5, "\nfoo\n\n")
buf = io.BytesIO()
figure.savefig(buf, format='eps')
figure.savefig(buf, format='ps')


def test_no_duplicate_definition():

fig = Figure()
Expand Down