@@ -178,16 +178,17 @@ def create_social_card_objects(
178178 site_url_color = "#2f363d" ,
179179 background_color = "white" ,
180180 line_color = "#5A626B" ,
181- font = "Roboto" ,
181+ font = None ,
182182):
183183 """Create the Matplotlib objects for the first time."""
184- # Load the Roboto font
185- # TODO: Currently the `font` parameter above does nothing
186- # Should instead make it possible to load remote fonts or local fonts
187- # if a user specifies.
188- path_font = Path (__file__ ).parent / "_static/Roboto-flex.ttf"
189- font = matplotlib .font_manager .FontEntry (fname = str (path_font ), name = "Roboto" )
190- matplotlib .font_manager .fontManager .ttflist .append (font )
184+ # If no font specified, load the Roboto Flex font as a fallback
185+ if font is None :
186+ path_font = Path (__file__ ).parent / "_static/Roboto-flex.ttf"
187+ roboto_font = matplotlib .font_manager .FontEntry (
188+ fname = str (path_font ), name = "Roboto"
189+ )
190+ matplotlib .font_manager .fontManager .ttflist .append (roboto_font )
191+ font = roboto_font .name
191192
192193 # Because Matplotlib doesn't let you specify figures in pixels, only inches
193194 # This `multiple` results in a scale of about 1146px by 600px
@@ -214,7 +215,7 @@ def create_social_card_objects(
214215
215216 # Axes configuration
216217 left_margin = 0.05
217- with plt .rc_context ({"font.family" : font . name }):
218+ with plt .rc_context ({"font.family" : font }):
218219 # Site title
219220 # Smaller font, just above page title
220221 site_title_y_offset = 0.87
0 commit comments