Calculate w/h of font measure properly.

This commit is contained in:
2021-05-23 22:47:56 -07:00
parent 76307d2746
commit 3775042b7d

View File

@ -74,6 +74,7 @@ fontmeasure_t * fontTextMeasure(font_t *font, char *text, fonttextinfo_t *info,
scale *= FONT_SCALE_ADJUST; scale *= FONT_SCALE_ADJUST;
measure = malloc(sizeof(fontmeasure_t)); measure = malloc(sizeof(fontmeasure_t));
measure->width = 0, measure->height = 0;
measure->scale = scale; measure->scale = scale;
measure->quads = malloc(sizeof(stbtt_aligned_quad) * info->realChars); 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->x0 *= scale, quad->x1 *= scale;
quad->y0 *= scale, quad->y1 *= scale; quad->y0 *= scale, quad->y1 *= scale;
measure->width = mathMax(measure->width, quad->x1);
measure->height = mathMax(measure->height, quad->y1);
j++; j++;
} }