]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0216: MS-Windows: Rendering artifacts with DirectX v9.2.0216
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Fri, 20 Mar 2026 22:51:30 +0000 (22:51 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 20 Mar 2026 22:51:30 +0000 (22:51 +0000)
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 <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui.h
src/gui_w32.c
src/screen.c
src/version.c

index 875db148b59f64fa96047b92eaa478faf70dbf5f..76d588222131985076932e4ce9f5047e068117a5 100644 (file)
--- 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
index bb5add2d135a353ad23aa8cfc2f1c10afbccbe81..605897fb2b2c63cc5f4dd8b46ca159b4ff3f0c21 100644 (file)
@@ -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
index 9acfa7bc8c1660daa2eafed3a1b30808b47bb1fa..4f7fc35113433aefd028c3bd5597060cfc36b92b 100644 (file)
@@ -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)
                {
index 41386c35cdf82933df13468c7fcdb90ce58beffa..425834a43b782c9cb495cf2ed6c5fa842fb3ed27 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    216,
 /**/
     215,
 /**/