From 3775042b7da6c756ceb9c63a4d2853f06f33862f Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 23 May 2021 22:47:56 -0700 Subject: [PATCH] Calculate w/h of font measure properly. --- src/display/gui/font.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/display/gui/font.c b/src/display/gui/font.c index 158242c6..506ef0af 100644 --- a/src/display/gui/font.c +++ b/src/display/gui/font.c @@ -74,6 +74,7 @@ fontmeasure_t * fontTextMeasure(font_t *font, char *text, fonttextinfo_t *info, scale *= FONT_SCALE_ADJUST; measure = malloc(sizeof(fontmeasure_t)); + measure->width = 0, measure->height = 0; measure->scale = scale; measure->quads = malloc(sizeof(stbtt_aligned_quad) * info->realChars); @@ -101,6 +102,8 @@ fontmeasure_t * fontTextMeasure(font_t *font, char *text, fonttextinfo_t *info, ); quad->x0 *= scale, quad->x1 *= scale; quad->y0 *= scale, quad->y1 *= scale; + measure->width = mathMax(measure->width, quad->x1); + measure->height = mathMax(measure->height, quad->y1); j++; }