From: Yasuhiro Matsumoto Date: Fri, 20 Mar 2026 22:51:30 +0000 (+0000) Subject: patch 9.2.0216: MS-Windows: Rendering artifacts with DirectX X-Git-Tag: v9.2.0216^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3d8a0f34908c4c4fbcea7703019079ed767ebbd;p=thirdparty%2Fvim.git patch 9.2.0216: MS-Windows: Rendering artifacts with DirectX Problem: MS-Windows: Rendering artifacts with DirectX (Alexander Zhura) Solution: Force redraw (Yasuhiro Matsumoto) DirectWrite subpixel rendering (especially with CFF/OTF fonts) can extend glyph pixels beyond cell boundaries. Vim already handles the forward direction (redraw the next character when the current one changes) for MS-Windows antialiasing, but the backward direction was missing. Add gui.directx_enabled flag accessible from screen.c and extend the existing spill-over handling to: - Redraw the current character when the previous one changed (backward) - Force redraw of the next character in screen_puts_len() and screen_fill() paths fixes: #19586 closes: #19761 Signed-off-by: Yasuhiro Matsumoto Signed-off-by: Christian Brabandt --- diff --git a/src/gui.h b/src/gui.h index 875db148b5..76d5882221 100644 --- a/src/gui.h +++ b/src/gui.h @@ -260,6 +260,9 @@ typedef struct Gui int left_sbar_x; // Calculated x coord for left scrollbar int right_sbar_x; // Calculated x coord for right scrollbar int force_redraw; // Force a redraw even e.g. not resized +#ifdef FEAT_DIRECTX + int directx_enabled; // DirectX (DirectWrite) rendering active +#endif #ifdef FEAT_MENU # ifndef FEAT_GUI_GTK diff --git a/src/gui_w32.c b/src/gui_w32.c index bb5add2d13..605897fb2b 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -242,6 +242,7 @@ gui_mch_set_rendering_options(char_u *s) } } s_directx_enabled = dx_enable; + gui.directx_enabled = IS_ENABLE_DIRECTX(); return OK; # else diff --git a/src/screen.c b/src/screen.c index 9acfa7bc8c..4f7fc35113 100644 --- a/src/screen.c +++ b/src/screen.c @@ -920,6 +920,14 @@ skip_opacity: // redraw that one if this one changed, no matter attributes. if (gui.in_use && changed_this) redraw_next = TRUE; +# ifdef FEAT_DIRECTX + // DirectWrite subpixel rendering (especially with CFF/OTF + // fonts) can extend pixels beyond cell boundaries to the + // left. Redraw the current character if the previous one + // changed. + if (gui.directx_enabled && changed_this) + redraw_this = TRUE; +# endif #endif ScreenAttrs[off_to] = ScreenAttrs[off_from]; @@ -1731,6 +1739,12 @@ screen_puts_len( if (n & HL_BOLD) force_redraw_next = TRUE; } +#endif +#ifdef FEAT_DIRECTX + // DirectWrite subpixel rendering can extend pixels beyond + // cell boundaries. Redraw the next character too. + if (gui.directx_enabled && need_redraw) + force_redraw_next = TRUE; #endif // When at the end of the text and overwriting a two-cell // character with a one-cell character, need to clear the next @@ -2663,6 +2677,12 @@ skip_opacity_fill: force_next = FALSE; } #endif // FEAT_GUI || defined(UNIX) +#ifdef FEAT_DIRECTX + // DirectWrite subpixel rendering can extend pixels + // beyond cell boundaries. Redraw the next character. + if (gui.directx_enabled) + force_next = TRUE; +#endif ScreenLines[off] = c; if (enc_utf8) { diff --git a/src/version.c b/src/version.c index 41386c35cd..425834a43b 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 216, /**/ 215, /**/