Skip to content
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_patheffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,16 @@ def test_tickedstroke():

ax3.set_xlim(0, 4)
ax3.set_ylim(0, 4)


@image_comparison(['spaces_and_newlines.png'], remove_text=True)
def test_patheffects_spaces_and_newlines():
ax = plt.subplot()
s1 = " "
s2 = "\nNewline also causes problems"
text1 = ax.text(0.5, 0.75, s1, ha='center', va='center', size=20,
bbox={'color': 'salmon'})
text2 = ax.text(0.5, 0.25, s2, ha='center', va='center', size=20,
bbox={'color': 'thistle'})
text1.set_path_effects([path_effects.Normal()])
text2.set_path_effects([path_effects.Normal()])
5 changes: 5 additions & 0 deletions lib/matplotlib/textpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ def get_text_path(self, prop, s, ismath=False):
verts.extend(verts1)
codes.extend(codes1)

# Make sure an empty string or one with nothing to print
# (e.g. only spaces & newlines) will be valid/empty path
if not verts:
verts = np.empty((0, 2))

return verts, codes

def get_glyphs_with_font(self, font, s, glyph_map=None,
Expand Down