@@ -211,7 +211,7 @@ def DisplayText(
211
211
y : int = 0 ,
212
212
width : int = 0 ,
213
213
height : int = 0 ,
214
- font : str = "roboto-mono/RobotoMono-Regular.ttf" ,
214
+ font : str = "./res/fonts/ roboto-mono/RobotoMono-Regular.ttf" ,
215
215
font_size : int = 20 ,
216
216
font_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
217
217
background_color : Tuple [int , int , int ] = (255 , 255 , 255 ),
@@ -252,7 +252,7 @@ def DisplayText(
252
252
253
253
# Get text bounding box
254
254
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 )
256
256
font = self .font_cache [(font , font_size )]
257
257
d = ImageDraw .Draw (text_image )
258
258
@@ -354,6 +354,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
354
354
line_width : int = 2 ,
355
355
graph_axis : bool = True ,
356
356
axis_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
357
+ font : str = "./res/fonts/roboto/Roboto-Black.ttf" ,
358
+ font_size : int = 10 ,
357
359
background_color : Tuple [int , int , int ] = (255 , 255 , 255 ),
358
360
background_image : str = None ):
359
361
# Generate a plot graph and display it
@@ -432,16 +434,16 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
432
434
# Draw Legend
433
435
draw .line ([0 , 0 , 1 , 0 ], fill = axis_color )
434
436
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 )
437
439
draw .text ((2 , 0 - top ), text ,
438
- font = font , fill = axis_color )
440
+ font = ttfont , fill = axis_color )
439
441
440
442
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 )
443
445
draw .text ((width - 1 - right , height - 2 - bottom ), text ,
444
- font = font , fill = axis_color )
446
+ font = ttfont , fill = axis_color )
445
447
446
448
self .DisplayPILImage (graph_image , x , y )
447
449
@@ -479,7 +481,7 @@ def DisplayRadialProgressBar(self, xc: int, yc: int, radius: int, bar_width: int
479
481
value : int = 50 ,
480
482
text : str = None ,
481
483
with_text : bool = True ,
482
- font : str = "roboto/Roboto-Black.ttf" ,
484
+ font : str = "./res/fonts/ roboto/Roboto-Black.ttf" ,
483
485
font_size : int = 20 ,
484
486
font_color : Tuple [int , int , int ] = (0 , 0 , 0 ),
485
487
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
657
659
if with_text :
658
660
if text is None :
659
661
text = f"{ int (pct * 100 + .5 )} %"
660
- font = ImageFont .truetype ("./res/fonts/" + font , font_size )
662
+ font = ImageFont .truetype (font , font_size )
661
663
left , top , right , bottom = font .getbbox (text )
662
664
w , h = right - left , bottom - top
663
665
draw .text ((radius - w / 2 + text_offset [0 ], radius - top - h / 2 + text_offset [1 ]), text ,
0 commit comments