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 cb21d7d

Browse filesBrowse files
authored
Merge pull request #18397 from casperdcl/patch-1
FIX: cmr10 negative sign in cmsy10 (RuntimeWarning: Glyph 8722 missing)
2 parents 33e51a5 + 3d106ae commit cb21d7d
Copy full SHA for cb21d7d

File tree

Expand file treeCollapse file tree

2 files changed

+17
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-0
lines changed

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
519519
found_symbol = False
520520
font = self._get_font(new_fontname)
521521
if font is not None:
522+
if font.family_name == "cmr10" and uniindex == 0x2212:
523+
# minus sign exists in cmsy10 (not cmr10)
524+
font = get_font(
525+
cbook._get_data_path("fonts/ttf/cmsy10.ttf"))
526+
uniindex = 0xa1
522527
glyphindex = font.get_char_index(uniindex)
523528
if glyphindex != 0:
524529
found_symbol = True

‎lib/matplotlib/tests/test_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_mathtext.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,15 @@ def test_math_fontfamily():
385385
size=24, math_fontfamily='dejavusans')
386386
fig.text(0.2, 0.3, r"$This\ text\ should\ have\ another$",
387387
size=24, math_fontfamily='stix')
388+
389+
390+
def test_mathtext_cmr10_minus_sign():
391+
# cmr10 does not contain a minus sign and used to issue a warning
392+
# RuntimeWarning: Glyph 8722 missing from current font.
393+
mpl.rcParams['font.family'] = 'cmr10'
394+
mpl.rcParams['axes.formatter.use_mathtext'] = True
395+
fig, ax = plt.subplots()
396+
ax.plot(range(-1, 1), range(-1, 1))
397+
with pytest.warns(None) as record:
398+
fig.canvas.draw()
399+
assert len(record) == 0, "\n".join(str(e.message) for e in record)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.