mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Make font loading walk subdirectories
This commit is contained in:
@@ -393,14 +393,22 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]):
|
|||||||
name = "Roboto"
|
name = "Roboto"
|
||||||
|
|
||||||
# Retrieve font files, if not already done
|
# Retrieve font files, if not already done
|
||||||
files = os.listdir(self.cache)
|
all_files=[]
|
||||||
files = [file for file in files if file.endswith(".ttf") or file.endswith(".otf")] or (
|
# Check for cached files - note these may be in subfolders
|
||||||
|
for currentpath, folders, files in os.walk(self.cache):
|
||||||
|
for file in files:
|
||||||
|
all_files.append(os.path.join(currentpath, file))
|
||||||
|
|
||||||
|
# If none found, fetch from Google and try again
|
||||||
|
if len(all_files) == 0:
|
||||||
self._load_font_from_google(name)
|
self._load_font_from_google(name)
|
||||||
)
|
for currentpath, folders, files in os.walk(self.cache):
|
||||||
|
for file in files:
|
||||||
|
all_files.append(os.path.join(currentpath, file))
|
||||||
|
|
||||||
# Map available font weights to file paths
|
# Map available font weights to file paths
|
||||||
font = dict()
|
font = dict()
|
||||||
for file in files:
|
for file in all_files:
|
||||||
match = re.search(r"-(\w+)\.[ot]tf$", file)
|
match = re.search(r"-(\w+)\.[ot]tf$", file)
|
||||||
if match:
|
if match:
|
||||||
font[match.group(1)] = os.path.join(self.cache, file)
|
font[match.group(1)] = os.path.join(self.cache, file)
|
||||||
|
|||||||
Reference in New Issue
Block a user