V_StringScaledWidth fixes

- Don't calculate a cy that's not actually needed
- Ignore colorcodes
- Update `right` when space characters are printed, too
This commit is contained in:
toaster 2023-07-11 14:25:38 +01:00
parent fd4c1aeec3
commit fb0fa9ac53

View file

@ -2583,7 +2583,7 @@ fixed_t V_StringScaledWidth(
boolean uppercase; boolean uppercase;
fixed_t cx, cy; fixed_t cx;
fixed_t right; fixed_t right;
fixed_t cw; fixed_t cw;
@ -2630,7 +2630,7 @@ fixed_t V_StringScaledWidth(
dupx = 1; dupx = 1;
} }
cx = cy = 0; cx = 0;
right = 0; right = 0;
for (; ( c = *s ); ++s) for (; ( c = *s ); ++s)
@ -2638,10 +2638,12 @@ fixed_t V_StringScaledWidth(
switch (c) switch (c)
{ {
case '\n': case '\n':
cy += fontspec.lfh;
cx = 0; cx = 0;
break; break;
default: default:
if (( c & 0x80 ))
continue;
if (uppercase) if (uppercase)
{ {
c = toupper(c); c = toupper(c);
@ -2673,7 +2675,7 @@ fixed_t V_StringScaledWidth(
cx += cw; cx += cw;
} }
else else
cx += fontspec.spacew; right = (cx += fontspec.spacew);
} }
fullwidth = std::max(right, std::max(cx, fullwidth)); fullwidth = std::max(right, std::max(cx, fullwidth));