@@ -1310,8 +1310,8 @@ def findfont(self, prop, fontext='ttf', directory=None,
13101310 prop , fontext , directory , fallback_to_default , rebuild_if_missing ,
13111311 rc_params )
13121312
1313- def find_fontsprop (self , prop , fontext = 'ttf' , directory = None ,
1314- fallback_to_default = True , rebuild_if_missing = True ):
1313+ def find_fonts_by_props (self , prop , fontext = 'ttf' , directory = None ,
1314+ fallback_to_default = True , rebuild_if_missing = True ):
13151315 """
13161316 Find font families that most closely matches the given properties.
13171317
@@ -1362,29 +1362,29 @@ def find_fontsprop(self, prop, fontext='ttf', directory=None,
13621362 "font.monospace" ])
13631363
13641364 prop = FontProperties ._from_any (prop )
1365- ffamily = prop .get_family ()
13661365
13671366 fpaths = OrderedDict ()
1368- for fidx in range ( len ( ffamily ) ):
1367+ for family in prop . get_family ( ):
13691368 cprop = prop .copy ()
13701369
13711370 # set current prop's family
1372- cprop .set_family (ffamily [ fidx ] )
1371+ cprop .set_family (family )
13731372
13741373 # do not fall back to default font
13751374 fpath = self ._findfontsprop_cached (
1376- ffamily [ fidx ] , cprop , fontext , directory ,
1375+ family , cprop , fontext , directory ,
13771376 False , rebuild_if_missing , rc_params
13781377 )
13791378 if fpath :
1380- fpaths [ffamily [ fidx ] ] = fpath
1379+ fpaths [family ] = fpath
13811380
13821381 # only add default family if no other font was found
13831382 # and fallback_to_default is enabled
13841383 if not fpaths :
13851384 if fallback_to_default :
13861385 dfamily = self .defaultFamily [fontext ]
1387- cprop = prop .copy ().set_family (dfamily )
1386+ cprop = prop .copy ()
1387+ cprop .set_family (dfamily )
13881388 fpath = self ._findfontsprop_cached (
13891389 dfamily , cprop , fontext , directory ,
13901390 True , rebuild_if_missing , rc_params
@@ -1514,20 +1514,17 @@ def is_opentype_cff_font(filename):
15141514
15151515@lru_cache (64 )
15161516def _get_font (fpaths , hinting_factor , * , _kerning_factor , thread_id ):
1517- ftobjects = []
1518- for fpath in fpaths [1 :]:
1519- ftobject = ft2font .FT2Font (
1520- fpath , hinting_factor ,
1521- _kerning_factor = _kerning_factor
1522- )
1523- ftobjects .append (ftobject )
1524-
1525- ft2font_object = ft2font .FT2Font (
1517+ return ft2font .FT2Font (
15261518 fpaths [0 ], hinting_factor ,
1527- _fallback_list = ftobjects ,
1519+ _fallback_list = [
1520+ ft2font .FT2Font (
1521+ fpath , hinting_factor ,
1522+ _kerning_factor = _kerning_factor
1523+ )
1524+ for fpath in fpaths [1 :]
1525+ ],
15281526 _kerning_factor = _kerning_factor
15291527 )
1530- return ft2font_object
15311528
15321529
15331530# FT2Font objects cannot be used across fork()s because they reference the same
@@ -1573,4 +1570,4 @@ def _load_fontmanager(*, try_read_cache=True):
15731570
15741571fontManager = _load_fontmanager ()
15751572findfont = fontManager .findfont
1576- find_fontsprop = fontManager .find_fontsprop
1573+ find_fonts_by_props = fontManager .find_fonts_by_props
0 commit comments