File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -393,14 +393,22 @@ def _load_font(self, config):
393393 name = "Roboto"
394394
395395 # Retrieve font files, if not already done
396- files = os .listdir (self .cache )
397- files = [file for file in files if file .endswith (".ttf" ) or file .endswith (".otf" )] or (
396+ all_files = []
397+ # Check for cached files - note these may be in subfolders
398+ for currentpath , folders , files in os .walk (self .cache ):
399+ for file in files :
400+ all_files .append (os .path .join (currentpath , file ))
401+
402+ # If none found, fetch from Google and try again
403+ if len (all_files ) == 0 :
398404 self ._load_font_from_google (name )
399- )
405+ for currentpath , folders , files in os .walk (self .cache ):
406+ for file in files :
407+ all_files .append (os .path .join (currentpath , file ))
400408
401409 # Map available font weights to file paths
402410 font = dict ()
403- for file in files :
411+ for file in all_files :
404412 match = re .search (r"-(\w+)\.[ot]tf$" , file )
405413 if match :
406414 font [match .group (1 )] = os .path .join (self .cache , file )
You can’t perform that action at this time.
0 commit comments