From 6a761ed418f6daaeaae313971e7d653fe1599661 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Wed, 17 Apr 2024 11:43:48 +0700 Subject: [PATCH] Improved interop of social plugin with other themes --- material/plugins/social/plugin.py | 10 ++-------- src/plugins/social/plugin.py | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/material/plugins/social/plugin.py b/material/plugins/social/plugin.py index eb7e5ca35..ba914101a 100644 --- a/material/plugins/social/plugin.py +++ b/material/plugins/social/plugin.py @@ -408,7 +408,7 @@ class SocialPlugin(BasePlugin[SocialConfig]): return Image.open(path).convert("RGBA") # Handle icons - icon = theme["icon"] or {} + icon = theme.get("icon") or {} if "logo" in icon and icon["logo"]: logo = icon["logo"] else: @@ -448,13 +448,7 @@ class SocialPlugin(BasePlugin[SocialConfig]): def _load_font(self, config): name = self.config.cards_layout_options.get("font_family") if not name: - - # Retrieve from theme (default: Roboto) - theme = config.theme - if isinstance(theme["font"], dict) and "text" in theme["font"]: - name = theme["font"]["text"] - else: - name = "Roboto" + name = config.theme.get("font", {}).get("text", "Roboto") # Resolve relevant fonts font = {} diff --git a/src/plugins/social/plugin.py b/src/plugins/social/plugin.py index eb7e5ca35..ba914101a 100644 --- a/src/plugins/social/plugin.py +++ b/src/plugins/social/plugin.py @@ -408,7 +408,7 @@ class SocialPlugin(BasePlugin[SocialConfig]): return Image.open(path).convert("RGBA") # Handle icons - icon = theme["icon"] or {} + icon = theme.get("icon") or {} if "logo" in icon and icon["logo"]: logo = icon["logo"] else: @@ -448,13 +448,7 @@ class SocialPlugin(BasePlugin[SocialConfig]): def _load_font(self, config): name = self.config.cards_layout_options.get("font_family") if not name: - - # Retrieve from theme (default: Roboto) - theme = config.theme - if isinstance(theme["font"], dict) and "text" in theme["font"]: - name = theme["font"]["text"] - else: - name = "Roboto" + name = config.theme.get("font", {}).get("text", "Roboto") # Resolve relevant fonts font = {}