Skip to content

Commit a517a99

Browse files
committed
Make font loading walk subdirectories
1 parent e6fc5fd commit a517a99

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/plugins/social/plugin.py

+12-4
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)