@@ -68,6 +68,13 @@ class TexManager:
6868 'computer modern roman' : ('cmr' , r'\usepackage{type1ec}' ),
6969 'computer modern sans serif' : ('cmss' , r'\usepackage{type1ec}' ),
7070 'computer modern typewriter' : ('cmtt' , r'\usepackage{type1ec}' )}
71+ _font_types = {
72+ 'new century schoolbook' : 'serif' , 'bookman' : 'serif' ,
73+ 'times' : 'serif' , 'palatino' : 'serif' , 'charter' : 'serif' ,
74+ 'computer modern roman' : 'serif' , 'zapf chancery' : 'cursive' ,
75+ 'helvetica' : 'sans-serif' , 'avant garde' : 'sans-serif' ,
76+ 'computer modern sans serif' : 'sans-serif' ,
77+ 'courier' : 'monospace' , 'computer modern typewriter' : 'monospace' }
7178
7279 grey_arrayd = _api .deprecate_privatize_attribute ("3.5" )
7380 font_family = _api .deprecate_privatize_attribute ("3.5" )
@@ -81,8 +88,13 @@ def __new__(cls):
8188
8289 def get_font_config (self ):
8390 ff = rcParams ['font.family' ]
84- if len (ff ) == 1 and ff [0 ].lower () in self ._font_families :
85- self ._font_family = ff [0 ].lower ()
91+ ff_val = ff [0 ].lower () if len (ff ) == 1 else None
92+ reduced_notation = False
93+ if len (ff ) == 1 and ff_val in self ._font_families :
94+ self ._font_family = ff_val
95+ elif len (ff ) == 1 and ff_val in self ._font_info :
96+ reduced_notation = True
97+ self ._font_family = self ._font_types [ff_val ]
8698 else :
8799 _log .info ('font.family must be one of (%s) when text.usetex is '
88100 'True. serif will be used by default.' ,
@@ -92,19 +104,24 @@ def get_font_config(self):
92104 fontconfig = [self ._font_family ]
93105 fonts = {}
94106 for font_family in self ._font_families :
95- for font in rcParams ['font.' + font_family ]:
96- if font .lower () in self ._font_info :
97- fonts [font_family ] = self ._font_info [font .lower ()]
98- _log .debug (
99- 'family: %s, font: %s, info: %s' ,
100- font_family , font , self ._font_info [font .lower ()])
101- break
102- else :
103- _log .debug ('%s font is not compatible with usetex.' , font )
107+ if reduced_notation and self ._font_family == font_family :
108+ fonts [font_family ] = self ._font_info [ff_val ]
104109 else :
105- _log .info ('No LaTeX-compatible font found for the %s font '
106- 'family in rcParams. Using default.' , font_family )
107- fonts [font_family ] = self ._font_info [font_family ]
110+ for font in rcParams ['font.' + font_family ]:
111+ if font .lower () in self ._font_info :
112+ fonts [font_family ] = self ._font_info [font .lower ()]
113+ _log .debug (
114+ 'family: %s, font: %s, info: %s' ,
115+ font_family , font , self ._font_info [font .lower ()])
116+ break
117+ else :
118+ _log .debug ('%s font is not compatible with usetex.' ,
119+ font )
120+ else :
121+ _log .info ('No LaTeX-compatible font found for the %s font'
122+ 'family in rcParams. Using default.' ,
123+ font_family )
124+ fonts [font_family ] = self ._font_info [font_family ]
108125 fontconfig .append (fonts [font_family ][0 ])
109126 # Add a hash of the latex preamble to fontconfig so that the
110127 # correct png is selected for strings rendered with same font and dpi
0 commit comments