8000 Merge pull request #14484 from anntzer/minusafm · matplotlib/matplotlib@5fc44ee · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fc44ee

Browse files
authored
Merge pull request #14484 from anntzer/minusafm
Support unicode minus with ps.useafm.
2 parents c67a29f + cd6f9d8 commit 5fc44ee

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/matplotlib/afm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ def _parse_char_metrics(fh):
244244
# Reference).
245245
if name == 'Euro':
246246
num = 128
247+
elif name == 'minus':
248+
num = ord("\N{MINUS SIGN}") # 0x2212
247249
if num != -1:
248250
ascii_d[num] = metrics
249251
name_d[name] = metrics

lib/matplotlib/tests/test_backend_ps.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@
4545
'eps afm',
4646
'eps with usetex'
4747
])
48-
def test_savefig_to_stringio(format, use_log, rcParams):
48+
def test_savefig_to_stringio(format, use_log, rcParams, monkeypatch):
4949
mpl.rcParams.update(rcParams)
50+
monkeypatch.setenv("SOURCE_DATE_EPOCH", "0") # For reproducibility.
5051

5152
fig, ax = plt.subplots()
5253

@@ -56,17 +57,16 @@ def test_savefig_to_stringio(format, use_log, rcParams):
5657
ax.set_yscale('log')
5758

5859
ax.plot([1, 2], [1, 2])
59-
ax.set_title("Déjà vu")
60+
title = "Déjà vu"
61+
if not mpl.rcParams["text.usetex"]:
62+
title += " \N{MINUS SIGN}\N{EURO SIGN}"
63+
ax.set_title(title)
6064
fig.savefig(s_buf, format=format)
6165
fig.savefig(b_buf, format=format)
6266

6367
s_val = s_buf.getvalue().encode('ascii')
6468
b_val = b_buf.getvalue()
6569

66-
# Remove comments from the output. This includes things that could
67-
# change from run to run, such as the time.
68-
s_val, b_val = [re.sub(b'%%.*?\n', b'', x) for x in [s_val, b_val]]
69-
7070
assert s_val == b_val.replace(b'\r\n', b'\n')
7171

7272

0 commit comments

Comments
 (0)
0