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

Sign up
Appearance settings

Commit ba8980c

Browse files
committed
When glyph is not found in cmr10, substitute from cmsy10.
1 parent 76a5711 commit ba8980c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎lib/matplotlib/_mathtext.py‎

Lines 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_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"anduniindex ==0x2212:
545-
# minus sign exists in cmsy10 (not cmr10)
552+
if (uniindex inself._cmr10_substitutions
553+
andfont.family_name=="cmr10"):
546554
font = get_font(
547555
cbook._get_data_path("fonts/ttf/cmsy10.ttf"))
548-
uniindex = 0xa1
556+
uniindex = self._cmr10_substitutions[uniindex]
549557
glyphindex = font.get_char_index(uniindex)
550558
if glyphindex != 0:
551559
found_symbol = True

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /