@@ -211,7 +211,7 @@ def DisplayText(
211211 y : int = 0 ,
212212 width : int = 0 ,
213213 height : int = 0 ,
214- font : str = "roboto-mono/RobotoMono-Regular.ttf" ,
214+ font : str = "./res/fonts/ roboto-mono/RobotoMono-Regular.ttf" ,
215215 font_size : int = 20 ,
216216 font_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
217217 background_color : Tuple [int , int , int ] = (255 , 255 , 255 ),
@@ -252,7 +252,7 @@ def DisplayText(
252252
253253 # Get text bounding box
254254 if (font , font_size ) not in self .font_cache :
255- self .font_cache [(font , font_size )] = ImageFont .truetype ("./res/fonts/" + font , font_size )
255+ self .font_cache [(font , font_size )] = ImageFont .truetype (font , font_size )
256256 font = self .font_cache [(font , font_size )]
257257 d = ImageDraw .Draw (text_image )
258258
@@ -354,6 +354,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
354354 line_width : int = 2 ,
355355 graph_axis : bool = True ,
356356 axis_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
357+ font : str = "./res/fonts/roboto/Roboto-Black.ttf" ,
358+ font_size : int = 10 ,
357359 background_color : Tuple [int , int , int ] = (255 , 255 , 255 ),
358360 background_image : str = None ):
359361 # Generate a plot graph and display it
@@ -432,16 +434,16 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
432434 # Draw Legend
433435 draw .line ([0 , 0 , 1 , 0 ], fill = axis_color )
434436 text = f"{ int (max_value )} "
435- font = ImageFont .truetype ("./res/fonts/" + "roboto/Roboto-Black.ttf" , 10 )
436- left , top , right , bottom = font .getbbox (text )
437+ ttfont = ImageFont .truetype (font , font_size )
438+ left , top , right , bottom = ttfont .getbbox (text )
437439 draw .text ((2 , 0 - top ), text ,
438- font = font , fill = axis_color )
440+ font = ttfont , fill = axis_color )
439441
440442 text = f"{ int (min_value )} "
441- font = ImageFont .truetype ("./res/fonts/" + "roboto/Roboto-Black.ttf" , 10 )
442- left , top , right , bottom = font .getbbox (text )
443+ ttfont = ImageFont .truetype (font , font_size )
444+ left , top , right , bottom = ttfont .getbbox (text )
443445 draw .text ((width - 1 - right , height - 2 - bottom ), text ,
444- font = font , fill = axis_color )
446+ font = ttfont , fill = axis_color )
445447
446448 self .DisplayPILImage (graph_image , x , y )
447449
@@ -479,7 +481,7 @@ def DisplayRadialProgressBar(self, xc: int, yc: int, radius: int, bar_width: int
479481 value : int = 50 ,
480482 text : str = None ,
481483 with_text : bool = True ,
482- font : str = "roboto/Roboto-Black.ttf" ,
484+ font : str = "./res/fonts/ roboto/Roboto-Black.ttf" ,
483485 font_size : int = 20 ,
484486 font_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
485487 bar_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
@@ -657,7 +659,7 @@ def DisplayRadialProgressBar(self, xc: int, yc: int, radius: int, bar_width: int
657659 if with_text :
658660 if text is None :
659661 text = f"{ int (pct * 100 + .5 )} %"
660- font = ImageFont .truetype ("./res/fonts/" + font , font_size )
662+ font = ImageFont .truetype (font , font_size )
661663 left , top , right , bottom = font .getbbox (text )
662664 w , h = right - left , bottom - top
663665 draw .text ((radius - w / 2 + text_offset [0 ], radius - top - h / 2 + text_offset [1 ]), text ,
0 commit comments