Commit: patch 9.2.0216: MS-Windows: Rendering artifacts with DirectX

2 views
Skip to first unread message

Christian Brabandt

unread,
Mar 20, 2026, 7:02:13 PM (3 days ago) Mar 20
to vim...@googlegroups.com
patch 9.2.0216: MS-Windows: Rendering artifacts with DirectX

Commit: https://github.com/vim/vim/commit/b3d8a0f34908c4c4fbcea7703019079ed767ebbd
Author: Yasuhiro Matsumoto <matt...@gmail.com>
Date: Fri Mar 20 22:51:30 2026 +0000

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 <matt...@gmail.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/gui.h b/src/gui.h
index 875db148b..76d588222 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 bb5add2d1..605897fb2 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 9acfa7bc8..4f7fc3511 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 41386c35c..425834a43 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,
/**/
Reply all
Reply to author
Forward
0 new messages