]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2127: MS-Windows: DirectX renders font too small v9.1.2127
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Mon, 2 Feb 2026 10:23:27 +0000 (10:23 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 2 Feb 2026 10:23:27 +0000 (10:23 +0000)
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 <mattn.jp@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui_dwrite.cpp
src/version.c

index b228d28f55a71c0c66516805c42894118f6edefe..5d4cb6c3aabf84c29c2b9a4c909f7357ce9a348e 100644 (file)
@@ -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
index def269c8f0d845f85227069179fcaafb2a100f4f..7e44624ff8c3b76b302b35818ef3548d482c82cc 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2127,
 /**/
     2126,
 /**/