Skip to content

Commit 9f6c9e9

Browse files
committed
TST: Fix pdf_use14corefonts by manually splitting lines
Since Helvetica may or may not be installed, the line height measurement may differ between systems, so multi-line text as in this test may change. This test doesn't care about line heights, but is about using PDF's "standard" fonts, so we'll just manually place the lines.
1 parent 2f8c518 commit 9f6c9e9

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

Binary file not shown.

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ def test_use14corefonts():
3232

3333
text = '''A three-line text positioned just above a blue line
3434
and containing some French characters and the euro symbol:
35-
"Merci pépé pour les 10 €"'''
35+
"Merci pépé pour les 10 €"'''.splitlines()
3636

3737
fig, ax = plt.subplots()
3838
ax.set_title('Test PDF backend with option use14corefonts=True')
39-
ax.text(0.5, 0.5, text, horizontalalignment='center',
40-
verticalalignment='bottom',
41-
fontsize=14)
39+
for i, line in enumerate(reversed(text)):
40+
# As Helvetica may or may not be installed, we place these lines manually, or
41+
# else they will move vertically depending on which font we measure for its
42+
# line height.
43+
ax.text(0.5, 0.5 + i * 0.05, line, fontsize=14,
44+
horizontalalignment='center', verticalalignment='bottom')
4245
ax.axhline(0.5, linewidth=0.5)
4346

4447

0 commit comments

Comments
 (0)