@@ -246,7 +246,7 @@ static void drawGraph(const Plot *plot, const ScreenTransform *transform)
246246}
247247
248248
249- static void drawGrid (const Plot * plot , const ScreenTransform * transform , int * maxYLabelWidth )
249+ static void drawGrid (const Plot * plot , const ScreenTransform * transform , const Font * font , int * maxYLabelWidth )
250250{
251251 if (maxYLabelWidth )
252252 * maxYLabelWidth = 0 ;
@@ -289,7 +289,7 @@ static void drawGrid(const Plot *plot, const ScreenTransform *transform, int *ma
289289 const int labelX = x - labelWidth / 2 ;
290290 const int labelY = clientRect .y + clientRect .height + plot -> grid .fontSize ;
291291
292- DrawText ( label , labelX , labelY , plot -> grid .fontSize , * (Color * )& plot -> grid .color );
292+ DrawTextEx ( * font , label , ( Vector2 ){ labelX , labelY } , plot -> grid .fontSize , 1 , * (Color * )& plot -> grid .color );
293293 }
294294 }
295295
@@ -309,7 +309,7 @@ static void drawGrid(const Plot *plot, const ScreenTransform *transform, int *ma
309309 const int labelX = clientRect .x - labelWidth - plot -> grid .fontSize ;
310310 const int labelY = y - plot -> grid .fontSize / 2 ;
311311
312- DrawText ( label , labelX , labelY , plot -> grid .fontSize , * (Color * )& plot -> grid .color );
312+ DrawTextEx ( * font , label , ( Vector2 ){ labelX , labelY } , plot -> grid .fontSize , 1 , * (Color * )& plot -> grid .color );
313313
314314 if (maxYLabelWidth && labelWidth > * maxYLabelWidth )
315315 * maxYLabelWidth = labelWidth ;
@@ -318,7 +318,7 @@ static void drawGrid(const Plot *plot, const ScreenTransform *transform, int *ma
318318}
319319
320320
321- static void drawTitles (const Plot * plot , const ScreenTransform * transform , int maxYLabelWidth )
321+ static void drawTitles (const Plot * plot , const ScreenTransform * transform , const Font * font , int maxYLabelWidth )
322322{
323323 if (!plot -> titles .visible )
324324 return ;
@@ -333,7 +333,7 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, int m
333333 const int titleX = clientRect .x + clientRect .width / 2 - titleWidth / 2 ;
334334 const int titleY = clientRect .y + clientRect .height + 2 * plot -> grid .fontSize + plot -> titles .fontSize ;
335335
336- DrawText ( plot -> titles .x , titleX , titleY , plot -> titles .fontSize , * (Color * )& plot -> titles .color );
336+ DrawTextEx ( * font , plot -> titles .x , ( Vector2 ){ titleX , titleY } , plot -> titles .fontSize , 1 , * (Color * )& plot -> titles .color );
337337 }
338338
339339 // Vertical axis
@@ -344,7 +344,7 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, int m
344344 const int titleX = clientRect .x - 2 * plot -> grid .fontSize - plot -> titles .fontSize - maxYLabelWidth ;
345345 const int titleY = clientRect .y + clientRect .height / 2 + titleWidth / 2 ;
346346
347- DrawTextPro (GetFontDefault () , plot -> titles .y , (Vector2 ){titleX , titleY }, (Vector2 ){0 , 0 }, -90.0 , plot -> titles .fontSize , 1 , * (Color * )& plot -> titles .color );
347+ DrawTextPro (* font , plot -> titles .y , (Vector2 ){titleX , titleY }, (Vector2 ){0 , 0 }, -90.0 , plot -> titles .fontSize , 1 , * (Color * )& plot -> titles .color );
348348 }
349349
350350 // Graph
@@ -355,12 +355,12 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, int m
355355 const int titleX = clientRect .x + clientRect .width / 2 - titleWidth / 2 ;
356356 const int titleY = clientRect .y - 2 * plot -> titles .fontSize ;
357357
358- DrawText ( plot -> titles .graph , titleX , titleY , plot -> titles .fontSize , * (Color * )& plot -> titles .color );
358+ DrawTextEx ( * font , plot -> titles .graph , ( Vector2 ){ titleX , titleY } , plot -> titles .fontSize , 1 , * (Color * )& plot -> titles .color );
359359 }
360360}
361361
362362
363- static void drawLegend (const Plot * plot )
363+ static void drawLegend (const Plot * plot , const Font * font )
364364{
365365 if (!plot -> legend .visible )
366366 return ;
@@ -401,7 +401,8 @@ static void drawLegend(const Plot *plot)
401401 const int labelX = legendRect .x + dashLength + 2 * margin ;
402402 const int labelY = legendRect .y + iSeries * (plot -> grid .fontSize + margin );
403403
404- DrawText (series -> name , labelX , labelY , plot -> grid .fontSize , * (Color * )& plot -> grid .color );
404+ DrawTextEx (* font , series -> name , (Vector2 ){labelX , labelY }, plot -> grid .fontSize , 1 , * (Color * )& plot -> grid .color );
405+
405406 }
406407}
407408
@@ -429,9 +430,13 @@ void umplot_plot(UmkaStackSlot *params, UmkaStackSlot *result)
429430
430431 SetTraceLogLevel (LOG_ERROR );
431432 SetConfigFlags (FLAG_WINDOW_RESIZABLE );
432- InitWindow (640 , 480 , "UmPlot" );
433+ InitWindow (800 , 600 , "UmPlot" );
433434 SetTargetFPS (30 );
434435
436+ const char * fontName = "liberation.ttf" ;
437+ Font gridFont = LoadFontEx (fontName , plot -> grid .fontSize , NULL , 256 );
438+ Font titlesFont = LoadFontEx (fontName , plot -> titles .fontSize , NULL , 256 );
439+
435440 Rectangle clientRect = getClientRect (plot );
436441 Rectangle zoomRect = clientRect ;
437442 bool showZoomRect = false;
@@ -487,16 +492,16 @@ void umplot_plot(UmkaStackSlot *params, UmkaStackSlot *result)
487492
488493 // Grid
489494 int maxYLabelWidth = 0 ;
490- drawGrid (plot , & transform , & maxYLabelWidth );
495+ drawGrid (plot , & transform , & gridFont , & maxYLabelWidth );
491496
492497 // Graph
493498 drawGraph (plot , & transform );
494499
495500 // Titles
496- drawTitles (plot , & transform , maxYLabelWidth );
501+ drawTitles (plot , & transform , & titlesFont , maxYLabelWidth );
497502
498503 // Legend
499- drawLegend (plot );
504+ drawLegend (plot , & gridFont );
500505
501506 // Zoom rectangle
502507 if (showZoomRect )
0 commit comments