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
16 changes: 16 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,22 @@ def test_wrap():
'times.')


def test_get_window_extent_wrapped():
# Test that a long title that wraps to two lines has the same vertical
# extent as an explicit two line title.

fig1 = plt.figure(figsize=(3, 3))
fig1.suptitle("suptitle that is clearly too long in this case", wrap=True)
window_extent_test = fig1._suptitle.get_window_extent()

fig2 = plt.figure(figsize=(3, 3))
fig2.suptitle("suptitle that is clearly\ntoo long in this case")
window_extent_ref = fig2._suptitle.get_window_extent()

assert window_extent_test.y0 == window_extent_ref.y0
assert window_extent_test.y1 == window_extent_ref.y1


def test_long_word_wrap():
fig = plt.figure(figsize=(6, 4))
text = fig.text(9.5, 8, 'Alonglineoftexttowrap', wrap=True)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def _get_layout(self, renderer):
of a rotated text when necessary.
"""
thisx, thisy = 0.0, 0.0
lines = self.get_text().split("\n") # Ensures lines is not empty.
lines = self._get_wrapped_text().split("\n") # Ensures lines is not empty.

ws = []
hs = []
Expand Down