mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 14:00:03 +00:00
Make PPGeMeasureText() actually measure the text.
Specifically, it was skipping newlines and ignoring the last line, so always returning 0.
This commit is contained in:
parent
a76d1e26de
commit
a3610ec49e
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user