Skip to content

Commit 6a761ed

Browse files
committed
Improved interop of social plugin with other themes
1 parent 324ccdb commit 6a761ed

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

material/plugins/social/plugin.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def _load_logo(self, config):
408408
return Image.open(path).convert("RGBA")
409409

410410
# Handle icons
411-
icon = theme["icon"] or {}
411+
icon = theme.get("icon") or {}
412412
if "logo" in icon and icon["logo"]:
413413
logo = icon["logo"]
414414
else:
@@ -448,13 +448,7 @@ def _load_logo_svg(self, path, fill = None):
448448
def _load_font(self, config):
449449
name = self.config.cards_layout_options.get("font_family")
450450
if not name:
451-
452-
# Retrieve from theme (default: Roboto)
453-
theme = config.theme
454-
if isinstance(theme["font"], dict) and "text" in theme["font"]:
455-
name = theme["font"]["text"]
456-
else:
457-
name = "Roboto"
451+
name = config.theme.get("font", {}).get("text", "Roboto")
458452

459453
# Resolve relevant fonts
460454
font = {}

src/plugins/social/plugin.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def _load_logo(self, config):
408408
return Image.open(path).convert("RGBA")
409409

410410
# Handle icons
411-
icon = theme["icon"] or {}
411+
icon = theme.get("icon") or {}
412412
if "logo" in icon and icon["logo"]:
413413
logo = icon["logo"]
414414
else:
@@ -448,13 +448,7 @@ def _load_logo_svg(self, path, fill = None):
448448
def _load_font(self, config):
449449
name = self.config.cards_layout_options.get("font_family")
450450
if not name:
451-
452-
# Retrieve from theme (default: Roboto)
453-
theme = config.theme
454-
if isinstance(theme["font"], dict) and "text" in theme["font"]:
455-
name = theme["font"]["text"]
456-
else:
457-
name = "Roboto"
451+
name = config.theme.get("font", {}).get("text", "Roboto")
458452

459453
# Resolve relevant fonts
460454
font = {}

0 commit comments

Comments
 (0)