@@ -13,6 +13,9 @@ class RendererModel
1313 /** @var string $font Font family */
1414 public $ font ;
1515
16+ /** @var string $font Font weight */
17+ public $ weight ;
18+
1619 /** @var string $color Font color */
1720 public $ color ;
1821
@@ -52,6 +55,7 @@ class RendererModel
5255 /** @var array<string, string> $DEFAULTS */
5356 private $ DEFAULTS = [
5457 "font " => "monospace " ,
58+ "weight " => "400 " ,
5559 "color " => "#36BCF7 " ,
5660 "background " => "#00000000 " ,
5761 "size " => "20 " ,
@@ -75,6 +79,7 @@ public function __construct($template, $params)
7579 $ this ->template = $ template ;
7680 $ this ->lines = $ this ->checkLines ($ params ["lines " ] ?? "" );
7781 $ this ->font = $ this ->checkFont ($ params ["font " ] ?? $ this ->DEFAULTS ["font " ]);
82+ $ this ->weight = $ this ->checkNumberPositive ($ params ["weight " ] ?? $ this ->DEFAULTS ["weight " ], "Font weight " );
7883 $ this ->color = $ this ->checkColor ($ params ["color " ] ?? $ this ->DEFAULTS ["color " ], "color " );
7984 $ this ->background = $ this ->checkColor ($ params ["background " ] ?? $ this ->DEFAULTS ["background " ], "background " );
8085 $ this ->size = $ this ->checkNumberPositive ($ params ["size " ] ?? $ this ->DEFAULTS ["size " ], "Font size " );
@@ -85,7 +90,7 @@ public function __construct($template, $params)
8590 $ this ->multiline = $ this ->checkBoolean ($ params ["multiline " ] ?? $ this ->DEFAULTS ["multiline " ]);
8691 $ this ->duration = $ this ->checkNumberPositive ($ params ["duration " ] ?? $ this ->DEFAULTS ["duration " ], "duration " );
8792 $ this ->pause = $ this ->checkNumberNonNegative ($ params ["pause " ] ?? $ this ->DEFAULTS ["pause " ], "pause " );
88- $ this ->fontCSS = $ this ->fetchFontCSS ($ this ->font , $ params ["lines " ]);
93+ $ this ->fontCSS = $ this ->fetchFontCSS ($ this ->font , $ this -> weight , $ params ["lines " ]);
8994 }
9095
9196 /**
@@ -185,12 +190,12 @@ private function checkBoolean($bool)
185190 * @param string $text Text to display in font
186191 * @return string The CSS for displaying the font
187192 */
188- private function fetchFontCSS ($ font , $ text )
193+ private function fetchFontCSS ($ font , $ weight , $ text )
189194 {
190195 // skip checking if left as default
191196 if ($ font != $ this ->DEFAULTS ["font " ]) {
192197 // fetch and convert from Google Fonts
193- $ from_google_fonts = GoogleFontConverter::fetchFontCSS ($ font , $ text );
198+ $ from_google_fonts = GoogleFontConverter::fetchFontCSS ($ font , $ weight , $ text );
194199 if ($ from_google_fonts ) {
195200 // return the CSS for displaying the font
196201 return "<style> \n{$ from_google_fonts }</style> \n" ;
0 commit comments