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

Skip to content

Commit 3253a3e

Browse files
committed
fix: simplify
1 parent 5424ff5 commit 3253a3e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/matplotlib/mathtext.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -768,22 +768,17 @@ class UnicodeFonts(TruetypeFonts):
768768
use_cmex = True
769769

770770
def __init__(self, *args, **kwargs):
771-
# This must come first so the backend's owner is set correctly
772771
fallback_rc = rcParams['mathtext.fallback']
773772
if rcParams['mathtext.fallback_to_cm'] is not None:
774-
if rcParams['mathtext.fallback_to_cm']:
775-
fallback_rc = 'cm'
776-
else:
777-
fallback_rc = None
773+
fallback_rc = ('cm' if rcParams['mathtext.fallback_to_cm']
774+
else None)
775+
776+
font_class = {'stix': StixFonts,
777+
'stixsans': StixSansFonts,
778+
'cm': BakomaFonts
779+
}.get(fallback_rc)
780+
self.cm_fallback = font_class(*args, **kwargs) if font_class else None
778781

779-
if fallback_rc == 'stix':
780-
self.cm_fallback = StixFonts(*args, **kwargs)
781-
elif fallback_rc == 'stixsans':
782-
self.cm_fallback = StixSansFonts(*args, **kwargs)
783-
elif fallback_rc == 'cm':
784-
self.cm_fallback = BakomaFonts(*args, **kwargs)
785-
else:
786-
self.cm_fallback = None
787782
TruetypeFonts.__init__(self, *args, **kwargs)
788783
self.fontmap = {}
789784
for texfont in "cal rm tt it bf sf".split():

0 commit comments

Comments
 (0)