@@ -256,11 +256,6 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
256
256
@lru_cache ()
257
257
def _call_fc_list ():
258
258
"""Cache and list the font filenames known to `fc-list`."""
259
- # Delay the warning by 5s.
260
- timer = Timer (5 , lambda : _log .warning (
261
- 'Matplotlib is building the font cache using fc-list. '
262
- 'This may take a moment.' ))
263
- timer .start ()
264
259
try :
265
260
if b'--format' not in subprocess .check_output (['fc-list' , '--help' ]):
266
261
_log .warning ( # fontconfig 2.7 implemented --format.
@@ -269,8 +264,6 @@ def _call_fc_list():
269
264
out = subprocess .check_output (['fc-list' , '--format=%{file}\\ n' ])
270
265
except (OSError , subprocess .CalledProcessError ):
271
266
return []
272
- finally :
273
- timer .cancel ()
274
267
return [os .fsdecode (fname ) for fname in out .split (b'\n ' )]
275
268
276
269
@@ -983,16 +976,24 @@ def __init__(self, size=None, weight='normal'):
983
976
984
977
self .afmlist = []
985
978
self .ttflist = []
986
- for fontext in ["afm" , "ttf" ]:
987
- for path in [* findSystemFonts (paths , fontext = fontext ),
988
- * findSystemFonts (fontext = fontext )]:
989
- try :
990
- self .addfont (path )
991
- except OSError as exc :
992
- _log .info ("Failed to open font file %s: %s" , path , exc )
993
- except Exception as exc :
994
- _log .info ("Failed to extract font properties from %s: %s" ,
995
- path , exc )
979
+
980
+ # Delay the warning by 5s.
981
+ timer = Timer (5 , lambda : _log .warning (
982
+ 'Matplotlib is building the font cache; this may take a moment.' ))
983
+ timer .start ()
984
+ try :
985
+ for fontext in ["afm" , "ttf" ]:
986
+ for path in [* findSystemFonts (paths , fontext = fontext ),
987
+ * findSystemFonts (fontext = fontext )]:
988
+ try :
989
+ self .addfont (path )
990
+ except OSError as exc :
991
+ _log .info ("Failed to open font file %s: %s" , path , exc )
992
+ except Exception as exc :
993
+ _log .info ("Failed to extract font properties from %s: "
994
+ "%s" , path , exc )
995
+ finally :
996
+ timer .cancel ()
996
997
997
998
def addfont (self , path ):
998
999
"""
0 commit comments