From cb485499eb5035c3f7c653a077f09bea2fe7a622 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Fri, 28 Apr 2023 11:46:16 +0200 Subject: [PATCH] Fixed social plugin crashing for Inter font --- material/plugins/social/plugin.py | 4 +++- src/plugins/social/plugin.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index 06b43714e..e70758268 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -28,6 +28,7 @@ import requests import sys from collections import defaultdict +from glob import glob from hashlib import md5 from io import BytesIO from mkdocs.commands.build import DuplicateFilter @@ -393,7 +394,8 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): name = "Roboto" # Retrieve font files, if not already done - files = os.listdir(self.cache) + files = glob(f"{self.cache}/**/*.[ot]tf") + files = [os.path.relpath(file, self.cache) for file in files] files = [file for file in files if file.endswith(".ttf") or file.endswith(".otf")] or ( self._load_font_from_google(name) ) diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index 06b43714e..e70758268 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -28,6 +28,7 @@ import requests import sys from collections import defaultdict +from glob import glob from hashlib import md5 from io import BytesIO from mkdocs.commands.build import DuplicateFilter @@ -393,7 +394,8 @@ class SocialPlugin(BasePlugin[SocialPluginConfig]): name = "Roboto" # Retrieve font files, if not already done - files = os.listdir(self.cache) + files = glob(f"{self.cache}/**/*.[ot]tf") + files = [os.path.relpath(file, self.cache) for file in files] files = [file for file in files if file.endswith(".ttf") or file.endswith(".otf")] or ( self._load_font_from_google(name) )