Skip to content

Commit 49f4c48

Browse files
authored
Fix font width bug
1 parent 04e0005 commit 49f4c48

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

umplot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static void drawGrid(const Plot *plot, const ScreenTransform *transform, const F
284284
if (plot->grid.labelled)
285285
{
286286
const char *label = TextFormat((xStep > 0.01) ? "%.2f" : "%.4f", startPt.x + i * xStep);
287-
const int labelWidth = MeasureText(label, plot->grid.fontSize);
287+
const int labelWidth = MeasureTextEx(*font, label, plot->grid.fontSize, 1).x;
288288

289289
const int labelX = x - labelWidth / 2;
290290
const int labelY = clientRect.y + clientRect.height + plot->grid.fontSize;
@@ -304,7 +304,7 @@ static void drawGrid(const Plot *plot, const ScreenTransform *transform, const F
304304
if (plot->grid.labelled)
305305
{
306306
const char *label = TextFormat((yStep > 0.01) ? "%.2f" : "%.4f", startPt.y + j * yStep);
307-
const int labelWidth = MeasureText(label, plot->grid.fontSize);
307+
const int labelWidth = MeasureTextEx(*font, label, plot->grid.fontSize, 1).x;
308308

309309
const int labelX = clientRect.x - labelWidth - plot->grid.fontSize;
310310
const int labelY = y - plot->grid.fontSize / 2;
@@ -328,7 +328,7 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, const
328328
// Horizontal axis
329329
if (plot->titles.x && TextLength(plot->titles.x) > 0)
330330
{
331-
const int titleWidth = MeasureText(plot->titles.x, plot->titles.fontSize);
331+
const int titleWidth = MeasureTextEx(*font, plot->titles.x, plot->titles.fontSize, 1).x;
332332

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;
@@ -339,7 +339,7 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, const
339339
// Vertical axis
340340
if (plot->titles.y && TextLength(plot->titles.y) > 0)
341341
{
342-
const int titleWidth = MeasureText(plot->titles.y, plot->titles.fontSize);
342+
const int titleWidth = MeasureTextEx(*font, plot->titles.y, plot->titles.fontSize, 1).x;
343343

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;
@@ -350,7 +350,7 @@ static void drawTitles(const Plot *plot, const ScreenTransform *transform, const
350350
// Graph
351351
if (plot->titles.graph && TextLength(plot->titles.graph) > 0)
352352
{
353-
const int titleWidth = MeasureText(plot->titles.graph, plot->titles.fontSize);
353+
const int titleWidth = MeasureTextEx(*font, plot->titles.graph, plot->titles.fontSize, 1).x;
354354

355355
const int titleX = clientRect.x + clientRect.width / 2 - titleWidth / 2;
356356
const int titleY = clientRect.y - 2 * plot->titles.fontSize;

umplot.png

-11 Bytes
Loading

0 commit comments

Comments
 (0)