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 ba3891d

Browse filesBrowse files
committed
When glyph is not found in cmr10, substitute from cmsy10.
1 parent c4082c1 commit ba3891d
Copy full SHA for ba3891d

File tree

Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-3
lines changed

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,14 @@ class UnicodeFonts(TruetypeFonts):
475475
symbol can not be found in the font.
476476
"""
477477

478+
# Some glyphs are not present in the `cmr10` font, and must be brought in
479+
# from `cmsy10`. Map the Unicode indices of those glyphs to the indices at
480+
# which they are found in `cmsy10`.
481+
cmr10_cmsy10_substitutions = {
482+
0x00D7: 0x00A3, # Multiplication sign.
483+
0x2212: 0x00A1, # Minus sign.
484+
}
485+
478486
def __init__(self, *args, **kwargs):
479487
# This must come first so the backend's owner is set correctly
480488
fallback_rc = mpl.rcParams['mathtext.fallback']
@@ -541,11 +549,11 @@ def _get_glyph(self, fontname, font_class, sym):
541549
found_symbol = False
542550
font = self._get_font(new_fontname)
543551
if font is not None:
544-
if font.family_name == "cmr10" and uniindex == 0x2212:
545-
# minus sign exists in cmsy10 (not cmr10)
552+
if (uniindex in self.cmr10_cmsy10_substitutions
553+
and font.family_name == "cmr10"):
546554
font = get_font(
547555
cbook._get_data_path("fonts/ttf/cmsy10.ttf"))
548-
uniindex = 0xa1
556+
uniindex = self.cmr10_cmsy10_substitutions[uniindex]
549557
glyphindex = font.get_char_index(uniindex)
550558
if glyphindex != 0:
551559
found_symbol = True

0 commit comments

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