@@ -769,7 +769,18 @@ class UnicodeFonts(TruetypeFonts):
769769
770770 def __init__ (self , * args , ** kwargs ):
771771 # This must come first so the backend's owner is set correctly
772- if rcParams ['mathtext.fallback_to_cm' ]:
772+ fallback_rc = rcParams ['mathtext.fallback' ]
773+ 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
778+
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' :
773784 self .cm_fallback = BakomaFonts (* args , ** kwargs )
774785 else :
775786 self .cm_fallback = None
@@ -783,6 +794,21 @@ def __init__(self, *args, **kwargs):
783794 font = findfont (prop )
784795 self .fontmap ['ex' ] = font
785796
797+ # include STIX sized alternatives for glyphs if fallback is STIX
798+ if isinstance (self .cm_fallback , StixFonts ):
799+ stixsizedaltfonts = {
800+ 0 : 'STIXGeneral' ,
801+ 1 : 'STIXSizeOneSym' ,
802+ 2 : 'STIXSizeTwoSym' ,
803+ 3 : 'STIXSizeThreeSym' ,
804+ 4 : 'STIXSizeFourSym' ,
805+ 5 : 'STIXSizeFiveSym' }
806+
807+ for size , name in stixsizedaltfonts .items ():
808+ fullpath = findfont (name )
809+ self .fontmap [size ] = fullpath
810+ self .fontmap [name ] = fullpath
811+
786812 _slanted_symbols = set (r"\int \oint" .split ())
787813
788814 def _map_virtual_font (self , fontname , font_class , uniindex ):
@@ -830,16 +856,19 @@ def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
830856
831857 if not found_symbol :
832858 if self .cm_fallback :
833- if isinstance (self .cm_fallback , BakomaFonts ):
834- _log .warning (
835- "Substituting with a symbol from Computer Modern." )
836- if (fontname in ('it' , 'regular' ) and
837- isinstance (self .cm_fallback , StixFonts )):
838- return self .cm_fallback ._get_glyph (
839- 'rm' , font_class , sym , fontsize )
840- else :
841- return self .cm_fallback ._get_glyph (
842- fontname , font_class , sym , fontsize )
859+ if (fontname in ('it' , 'regular' )
860+ and isinstance (self .cm_fallback , StixFonts )):
861+ fontname = 'rm'
862+
863+ g = self .cm_fallback ._get_glyph (fontname , font_class ,
864+ sym , fontsize )
865+ fname = g [0 ].family_name
866+ if fname in list (BakomaFonts ._fontmap .values ()):
867+ fname = "Computer Modern"
868+ _log .warning ("Substituting symbol {} "
869+ "from {}" .format (sym , fname ))
870+ return g
871+
843872 else :
844873 if (fontname in ('it' , 'regular' )
845874 and isinstance (self , StixFonts )):
0 commit comments