@@ -68,6 +68,13 @@ class TexManager:
68
68
'computer modern roman' : ('cmr' , r'\usepackage{type1ec}' ),
69
69
'computer modern sans serif' : ('cmss' , r'\usepackage{type1ec}' ),
70
70
'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' }
71
78
72
79
grey_arrayd = _api .deprecate_privatize_attribute ("3.5" )
73
80
font_family = _api .deprecate_privatize_attribute ("3.5" )
@@ -81,8 +88,13 @@ def __new__(cls):
81
88
82
89
def get_font_config (self ):
83
90
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 ]
86
98
else :
87
99
_log .info ('font.family must be one of (%s) when text.usetex is '
88
100
'True. serif will be used by default.' ,
@@ -92,19 +104,24 @@ def get_font_config(self):
92
104
fontconfig = [self ._font_family ]
93
105
fonts = {}
94
106
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 ]
104
109
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 ]
108
125
fontconfig .append (fonts [font_family ][0 ])
109
126
# Add a hash of the latex preamble to fontconfig so that the
110
127
# correct png is selected for strings rendered with same font and dpi
0 commit comments