X Tutup
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
21 changes: 21 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,24 @@ def test_font_scaling():

for i, fs in enumerate(range(4, 43, 2)):
ax.text(0.1, i*30, "{fs} pt font size".format(fs=fs), fontsize=fs)


@pytest.mark.parametrize('spacing1, spacing2', [(0.4, 2), (2, 0.4), (2, 2)])
def test_two_2line_texts(spacing1, spacing2):
text_string = 'line1\nline2'
fig = plt.figure()
renderer = fig.canvas.get_renderer()

text1 = plt.text(0.25, 0.5, text_string, linespacing=spacing1)
text2 = plt.text(0.25, 0.5, text_string, linespacing=spacing2)
fig.canvas.draw()

box1 = text1.get_window_extent(renderer=renderer)
box2 = text2.get_window_extent(renderer=renderer)

# line spacing only affects height
assert box1.width == box2.width
if (spacing1 == spacing2):
assert box1.height == box2.height
else:
assert box1.height != box2.height
1 change: 1 addition & 0 deletions lib/matplotlib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ def get_prop_tup(self, renderer=None):
hash(self._fontproperties),
self._rotation, self._rotation_mode,
self.figure.dpi, id(renderer or self._renderer),
self._linespacing
)

def get_text(self):
Expand Down
X Tutup