Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b7a3209

Browse files
committed
fix: fallback warnings
1 parent 0d15f37 commit b7a3209

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

lib/matplotlib/mathtext.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ class BakomaFonts(TruetypeFonts):
660660

661661
def __init__(self, *args, **kwargs):
662662
self._stix_fallback = StixFonts(*args, **kwargs)
663+
self.name = "Computer Modern"
663664

664665
TruetypeFonts.__init__(self, *args, **kwargs)
665666
self.fontmap = {}
@@ -769,18 +770,19 @@ class UnicodeFonts(TruetypeFonts):
769770

770771
def __init__(self, *args, **kwargs):
771772
# This must come first so the backend's owner is set correctly
772-
_fallback_rc = rcParams['mathtext.fallback']
773+
fallback_rc = rcParams['mathtext.fallback']
773774
if rcParams['mathtext.fallback_to_cm'] is not None:
774775
if rcParams['mathtext.fallback_to_cm']:
775-
_fallback_rc = 'cm'
776+
fallback_rc = 'cm'
776777
else:
777-
_fallback_rc = None
778+
fallback_rc = None
778779

779-
if _fallback_rc == 'stix':
780+
781+
if fallback_rc == 'stix':
780782
self.cm_fallback = StixFonts(*args, **kwargs)
781-
elif _fallback_rc == 'stixsans':
783+
elif fallback_rc == 'stixsans':
782784
self.cm_fallback = StixSansFonts(*args, **kwargs)
783-
elif _fallback_rc == 'cm':
785+
elif fallback_rc == 'cm':
784786
self.cm_fallback = BakomaFonts(*args, **kwargs)
785787
else:
786788
self.cm_fallback = None
@@ -856,13 +858,9 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
856858

857859
if not found_symbol:
858860
if self.cm_fallback:
859-
if type(self.cm_fallback) is BakomaFonts:
860-
_log.warning("Substituting with a symbol from Computer "
861-
"Modern.")
862-
elif type(self.cm_fallback) is StixFonts:
863-
_log.warning("Substituting with a symbol from STIX.")
864-
elif type(self.cm_fallback) is StixSansFonts:
865-
_log.warning("Substituting with a symbol from STIX Sans.")
861+
_log.warning("Substituting with a symbol from {}".format(
862+
self.cm_fallback.name))
863+
866864
if (fontname in ('it', 'regular')
867865
and isinstance(self.cm_fallback, StixFonts)):
868866
fontname = 'rm'
@@ -1004,6 +1002,7 @@ class StixFonts(UnicodeFonts):
10041002
def __init__(self, *args, **kwargs):
10051003
TruetypeFonts.__init__(self, *args, **kwargs)
10061004
self.fontmap = {}
1005+
self.name = "STIX"
10071006
for key, name in self._fontmap.items():
10081007
fullpath = findfont(name)
10091008
self.fontmap[key] = fullpath
@@ -1080,6 +1079,9 @@ class StixSansFonts(StixFonts):
10801079
A font handling class for the STIX fonts (that uses sans-serif
10811080
characters by default).
10821081
"""
1082+
def __init__(self, *args, **kwargs):
1083+
StixFonts.__init__(self, *args, **kwargs)
1084+
self.name = "STIXSans"
10831085
_sans = True
10841086

10851087

0 commit comments

Comments
 (0)