Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 539b5d6

Browse filesBrowse files
committed
Support unicode minus with ps.useafm.
Really, the whole postscript font encoding system should be rethought, but for now, given that there's already special casing for \N{EURO SIGN}, I don't feel too bad adding another special case for \N{MINUS SIGN}. Note that the test has a `if not mpl.rcParams["text.usetex"]` clause because `\N{MINUS SIGN}` + usetex + useafm doesn't work yet...
1 parent 1c06de3 commit 539b5d6
Copy full SHA for 539b5d6

File tree

Expand file treeCollapse file tree

2 files changed

+8
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-6
lines changed

‎lib/matplotlib/afm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/afm.py
+2Lines 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+
if 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_ps.py
+6-6Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.