[vim/vim] Fix DirectX font size to match GDI by implementing proper clipping (PR #19304)

5 views
Skip to first unread message

mattn

unread,
Feb 1, 2026, 9:29:23 AM (yesterday) Feb 1
to vim/vim, Subscribed

After the DirectX rendering improvements in patch 9.1.2125 (commit b39b065), users reported that fonts rendered with DirectX (set renderoptions=type:directx) appeared smaller than the same fonts rendered with GDI.

Root Cause

The original DirectX implementation (before patch 9.1.2125) had a clipping issue: The ETO_CLIPPED flag and clipping rectangle (lprc) passed from the GDI layer were not being respected. Without proper clipping, glyphs would extend beyond cell boundaries, causing rendering artifacts (visual "garbage") above and below the text cells.

In patch 9.1.2125, to work around this long-standing clipping issue (#19254), the font size was intentionally reduced by scaling to only the ascent height:

fontSize = ceil(fontSize * float(fontMetrics.ascent) / float(fontMetrics.designUnitsPerEm));

This prevented glyphs from overflowing their cells, but it also made the fonts appear smaller than their GDI counterparts—typically about 13% smaller (e.g., 13px instead of 15px for an 11pt font).

Solution

Instead of reducing the font size to avoid overflow, this patch fixes the root cause by implementing proper clipping support:

  1. Removed the ascent ratio scaling - Font size now matches GDI rendering
  2. Implemented ETO_CLIPPED support - Added PushAxisAlignedClip() and PopAxisAlignedClip() calls in DWriteContext::DrawText() to respect the clipping rectangle

With proper clipping in place, glyphs are prevented from rendering outside their cell boundaries, eliminating the need to artificially reduce the font size.

closes: #19254


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19304

Commit Summary

  • c3e5980 Fix DirectX font size to match GDI by implementing proper clipping

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304@github.com>

Christian Brabandt

unread,
Feb 1, 2026, 10:01:24 AM (yesterday) Feb 1
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In src/gui_dwrite.cpp:

> @@ -1080,6 +1086,11 @@ DWriteContext::DrawText(const WCHAR *text, int len,
     }
 
     SafeRelease(&textLayout);
+
+    if ((fuOptions & ETO_CLIPPED) && lprc != NULL)
+    {

you can drop the braces here


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/review/3735842932@github.com>

mattn

unread,
Feb 1, 2026, 10:04:42 AM (yesterday) Feb 1
to vim/vim, Push

@mattn pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/before/c3e59808e572dfe99e036a70ca000d62d42cb361/after/f6557407204aef3269e8e8738f35b98fee9ccdbf@github.com>

Christian Brabandt

unread,
5:30 AM (14 hours ago) 5:30 AM
to vim/vim, Subscribed

Closed #19304 via fccd6f9.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/issue_event/22461124782@github.com>

Maxim Kim

unread,
5:39 PM (2 hours ago) 5:39 PM
to vim/vim, Subscribed
habamax left a comment (vim/vim#19304)

Unicode Box (vertical) characters are now have gaps

directx enabled

image.png (view on web)

directx disabled and before this patch

image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/c3837656037@github.com>

mattn

unread,
6:51 PM (1 hour ago) 6:51 PM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19304)

@habamax Could you please show me part of your vimrc to reproduce it.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/c3837880682@github.com>

Maxim Kim

unread,
6:57 PM (1 hour ago) 6:57 PM
to vim/vim, Subscribed
habamax left a comment (vim/vim#19304)

@habamax Could you please show me part of your vimrc to reproduce it.

set fillchars=vert:│
set renderoptions=type:directx
set linespace=0
set guifont=:h17
image.png (view on web)


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/c3837899410@github.com>

mattn

unread,
7:50 PM (9 minutes ago) 7:50 PM
to vim/vim, Subscribed
mattn left a comment (vim/vim#19304)

Hmm, font related issue?
image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19304/c3838116475@github.com>

Reply all
Reply to author
Forward
0 new messages