@@ -1113,6 +1113,12 @@ def set_default_weight(self, weight):
11131113 """
11141114 self .__default_weight = weight
11151115
1116+ @staticmethod
1117+ def _expand_aliases (family ):
1118+ if family in ('sans' , 'sans serif' ):
1119+ family = 'sans-serif'
1120+ return rcParams ['font.' + family ]
1121+
11161122 # Each of the scoring functions below should return a value between
11171123 # 0.0 (perfect match) and 1.0 (terrible match)
11181124 def score_family (self , families , family2 ):
@@ -1135,10 +1141,7 @@ def score_family(self, families, family2):
11351141 for i , family1 in enumerate (families ):
11361142 family1 = family1 .lower ()
11371143 if family1 in font_family_aliases :
1138- if family1 in ('sans' , 'sans serif' ):
1139- family1 = 'sans-serif'
1140- options = rcParams ['font.' + family1 ]
1141- options = [x .lower () for x in options ]
1144+ options = [* map (str .lower , self ._expand_aliases (family1 ))]
11421145 if family2 in options :
11431146 idx = options .index (family2 )
11441147 return (i + (idx / len (options ))) * step
@@ -1341,6 +1344,12 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
13411344 _log .warning (
13421345 'findfont: Font family %s not found. Falling back to %s.' ,
13431346 prop .get_family (), self .defaultFamily [fontext ])
1347+ for family in map (str .lower , prop .get_family ()):
1348+ if family in font_family_aliases :
1349+ _log .warning (
1350+ "findfont: Generic family %r not found because "
1351+ "none of the following families were found: %s" ,
1352+ family , ", " .join (self ._expand_aliases (family )))
13441353 default_prop = prop .copy ()
13451354 default_prop .set_family (self .defaultFamily [fontext ])
13461355 return self .findfont (default_prop , fontext , directory ,
0 commit comments