From a3610ec49eecc890ca7a6977c530005aea610c29 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 11 Feb 2013 00:38:08 -0800 Subject: [PATCH] Make PPGeMeasureText() actually measure the text. Specifically, it was skipping newlines and ignoring the last line, so always returning 0. --- Core/Util/PPGeDraw.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 980a7e014e..4a77375ac2 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -249,16 +249,17 @@ static void PPGeMeasureText(const char *text, float scale, float *w, float *h) { float maxw = 0; int lines = 1; while ((cval = *text++) != '\0') { - if (cval < 32) continue; - if (cval > 127) continue; if (cval == '\n') { if (wacc > maxw) maxw = wacc; wacc = 0; lines++; } + if (cval < 32) continue; + if (cval > 127) continue; AtlasChar c = atlasfont.chars[cval - 32]; wacc += c.wx * scale; } + if (wacc > maxw) maxw = wacc; if (w) *w = maxw; if (h) *h = atlasfont.height * scale * lines; }