From fb0fa9ac53b59b3fded9b395f687733196b43bfa Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 11 Jul 2023 14:25:38 +0100 Subject: [PATCH] V_StringScaledWidth fixes - Don't calculate a cy that's not actually needed - Ignore colorcodes - Update `right` when space characters are printed, too --- src/v_video.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index c60159bf7..3e85a9938 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2583,7 +2583,7 @@ fixed_t V_StringScaledWidth( boolean uppercase; - fixed_t cx, cy; + fixed_t cx; fixed_t right; fixed_t cw; @@ -2630,7 +2630,7 @@ fixed_t V_StringScaledWidth( dupx = 1; } - cx = cy = 0; + cx = 0; right = 0; for (; ( c = *s ); ++s) @@ -2638,10 +2638,12 @@ fixed_t V_StringScaledWidth( switch (c) { case '\n': - cy += fontspec.lfh; cx = 0; break; default: + if (( c & 0x80 )) + continue; + if (uppercase) { c = toupper(c); @@ -2673,7 +2675,7 @@ fixed_t V_StringScaledWidth( cx += cw; } else - cx += fontspec.spacew; + right = (cx += fontspec.spacew); } fullwidth = std::max(right, std::max(cx, fullwidth));