patch 9.1.2127: MS-Windows: DirectX renders font too small

Commit: 
https://github.com/vim/vim/commit/fccd6f9b1457cb8ccf9326f7083e1d60cf37b1ce
Author: Yasuhiro Matsumoto <[email protected]>
Date:   Mon Feb 2 10:23:27 2026 +0000

    patch 9.1.2127: MS-Windows: DirectX renders font too small
    
    Problem:  MS-Windows: DirectX renders font too small in comparison to
              the GDI rendering (Linwei, after v9.1.2125)
    Solution: Implement proper font clipping (Yasuhiro Matsumoto)
    
    related: #19254
    closes:  #19304
    
    Signed-off-by: Yasuhiro Matsumoto <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/gui_dwrite.cpp b/src/gui_dwrite.cpp
index b228d28f5..5d4cb6c3a 100644
--- a/src/gui_dwrite.cpp
+++ b/src/gui_dwrite.cpp
@@ -820,9 +820,6 @@ DWriteContext::CreateTextFormatFromLOGFONT(const LOGFONTW 
&logFont,
            fontSize = fontSize * float(fontMetrics.designUnitsPerEm)
                / float(fontMetrics.ascent + fontMetrics.descent);
        }
-
-       // Scale by ascent ratio to match GDI rendering size
-       fontSize = ceil(fontSize * float(fontMetrics.ascent) / 
float(fontMetrics.designUnitsPerEm));
     }
 
     // The text format includes a locale name. Ideally, this would be the
@@ -1055,6 +1052,15 @@ DWriteContext::DrawText(const WCHAR *text, int len,
 
     SetDrawingMode(DM_DIRECTX);
 
+    // Apply clipping if ETO_CLIPPED is specified
+    if ((fuOptions & ETO_CLIPPED) && lprc != NULL)
+    {
+       mRT->PushAxisAlignedClip(
+           D2D1::RectF(FLOAT(lprc->left), FLOAT(lprc->top),
+                       FLOAT(lprc->right), FLOAT(lprc->bottom)),
+           D2D1_ANTIALIAS_MODE_ALIASED);
+    }
+
     hr = mDWriteFactory->CreateTextLayout(text, len, mTextFormat,
            FLOAT(w), FLOAT(h), &textLayout);
 
@@ -1080,6 +1086,9 @@ DWriteContext::DrawText(const WCHAR *text, int len,
     }
 
     SafeRelease(&textLayout);
+
+    if ((fuOptions & ETO_CLIPPED) && lprc != NULL)
+       mRT->PopAxisAlignedClip();
 }
 
     void
diff --git a/src/version.c b/src/version.c
index def269c8f..7e44624ff 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 */
+/**/
+    2127,
 /**/
     2126,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vmrC0-008sp5-MF%40256bit.org.

Raspunde prin e-mail lui