From 7d90e8f8f84769ee2958f5f9f2ddd91285c5c6bb Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Apr 2023 08:19:47 -0700 Subject: [PATCH 1/2] V_DrawStretchyFixedPatch: multiply vertical scale in fixed-point Fixes 1px overshoot at some scales. --- src/v_video.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index afab505a7..b13cbdce2 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -886,12 +886,10 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca else pwidth = patch->width * dupx; - float fdupy = FIXED_TO_FLOAT(vdup); - float fx = x; float fy = y; float fx2 = fx + pwidth; - float fy2 = fy + static_cast(patch->height) * fdupy; + float fy2 = fy + ((patch->height * vdup) / FRACUNIT); float falpha = 1.f; float umin = 0.f; float umax = 1.f; From d7448bd59741ea6c5636822fded6dfb0a9f2ca21 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 23 Apr 2023 08:22:07 -0700 Subject: [PATCH 2/2] V_StringScaledWidth: always return full width of bunched fonts --- src/v_video.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/v_video.cpp b/src/v_video.cpp index b13cbdce2..8f49f9b39 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -2495,6 +2495,7 @@ fixed_t V_StringScaledWidth( boolean uppercase; fixed_t cx, cy; + fixed_t right; fixed_t cw; @@ -2697,6 +2698,7 @@ fixed_t V_StringScaledWidth( } cx = cy = 0; + right = 0; for (; ( c = *s ); ++s) { @@ -2714,6 +2716,12 @@ fixed_t V_StringScaledWidth( if (c >= 0 && c < font->size && font->font[c]) { cw = SHORT (font->font[c]->width) * dupx; + + // How bunched dims work is by incrementing cx slightly less than a full character width. + // This causes the next character to be drawn overlapping the previous. + // We need to count the full width to get the rightmost edge of the string though. + right = cx + (cw * scale); + (*dim_fn)(scale, chw, hchw, dupx, &cw); cx += cw; } @@ -2721,7 +2729,7 @@ fixed_t V_StringScaledWidth( cx += spacew; } - fullwidth = std::max(cx, fullwidth); + fullwidth = std::max(right, std::max(cx, fullwidth)); } return fullwidth;