Skip to content

Commit a7c7348

Browse files
committed
Rename confusingly-named cm_fallback.
mathtext can now do fallbacks to fonts other than computer modern, so the name cm_fallback is outdated. The module is private, so we can rename the attribute without deprecation.
1 parent 2e921df commit a7c7348

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/matplotlib/_mathtext.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def __init__(self, *args, **kwargs):
411411
'stixsans': StixSansFonts,
412412
'cm': BakomaFonts
413413
}.get(fallback_rc)
414-
self.cm_fallback = font_cls(*args, **kwargs) if font_cls else None
414+
self._fallback_font = font_cls(*args, **kwargs) if font_cls else None
415415

416416
super().__init__(*args, **kwargs)
417417
self.fontmap = {}
@@ -424,7 +424,7 @@ def __init__(self, *args, **kwargs):
424424
self.fontmap['ex'] = font
425425

426426
# include STIX sized alternatives for glyphs if fallback is STIX
427-
if isinstance(self.cm_fallback, StixFonts):
427+
if isinstance(self._fallback_font, StixFonts):
428428
stixsizedaltfonts = {
429429
0: 'STIXGeneral',
430430
1: 'STIXSizeOneSym',
@@ -480,13 +480,13 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
480480
found_symbol = True
481481

482482
if not found_symbol:
483-
if self.cm_fallback:
483+
if self._fallback_font:
484484
if (fontname in ('it', 'regular')
485-
and isinstance(self.cm_fallback, StixFonts)):
485+
and isinstance(self._fallback_font, StixFonts)):
486486
fontname = 'rm'
487487

488-
g = self.cm_fallback._get_glyph(fontname, font_class,
489-
sym, fontsize)
488+
g = self._fallback_font._get_glyph(fontname, font_class,
489+
sym, fontsize)
490490
fname = g[0].family_name
491491
if fname in list(BakomaFonts._fontmap.values()):
492492
fname = "Computer Modern"
@@ -507,8 +507,8 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
507507
return font, uniindex, fontsize, slanted
508508

509509
def get_sized_alternatives_for_symbol(self, fontname, sym):
510-
if self.cm_fallback:
511-
return self.cm_fallback.get_sized_alternatives_for_symbol(
510+
if self._fallback_font:
511+
return self._fallback_font.get_sized_alternatives_for_symbol(
512512
fontname, sym)
513513
return [(fontname, sym)]
514514

@@ -518,9 +518,9 @@ class DejaVuFonts(UnicodeFonts):
518518
def __init__(self, *args, **kwargs):
519519
# This must come first so the backend's owner is set correctly
520520
if isinstance(self, DejaVuSerifFonts):
521-
self.cm_fallback = StixFonts(*args, **kwargs)
521+
self._fallback_font = StixFonts(*args, **kwargs)
522522
else:
523-
self.cm_fallback = StixSansFonts(*args, **kwargs)
523+
self._fallback_font = StixSansFonts(*args, **kwargs)
524524
self.bakoma = BakomaFonts(*args, **kwargs)
525525
TruetypeFonts.__init__(self, *args, **kwargs)
526526
self.fontmap = {}
@@ -616,7 +616,7 @@ class StixFonts(UnicodeFonts):
616616
4: 'STIXSizeFourSym',
617617
5: 'STIXSizeFiveSym',
618618
}
619-
cm_fallback = False
619+
_fallback_font = False
620620
_sans = False
621621

622622
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)