[PATCH v4 2/3] d3dx9: Handle clipping in ID3DXFont_DrawText.

Sven Baars sbaars at codeweavers.com
Thu Mar 5 15:39:58 CST 2020


Signed-off-by: Sven Baars <sbaars at codeweavers.com>
---
 dlls/d3dx9_36/font.c       | 5 +++++
 dlls/d3dx9_36/tests/core.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
index 71cfddb0d4..9e9cb658db 100644
--- a/dlls/d3dx9_36/font.c
+++ b/dlls/d3dx9_36/font.c
@@ -559,6 +559,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
     if (!count)
         return 0;
 
+    if (format & DT_CALCRECT)
+        format |= DT_NOCLIP;
+
     if (!rect)
     {
         y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0);
@@ -637,6 +640,8 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
             heap_free(results.lpGlyphs);
         }
         y += lh;
+        if (!(DT_NOCLIP & format) && (y > textrect.bottom))
+            break;
     }
 
     ret = y - textrect.top;
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c
index c6f5beff43..c79f5c1f72 100644
--- a/dlls/d3dx9_36/tests/core.c
+++ b/dlls/d3dx9_36/tests/core.c
@@ -780,7 +780,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
     todo_wine ok(height == 36, "Got unexpected height %d.\n", height);
 
     height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, 0, 0xff00ff);
-    todo_wine ok(height == 48, "Got unexpected height %d.\n", height);
+    ok(height == 48, "Got unexpected height %d.\n", height);
 
     height = ID3DXFont_DrawTextW(font, NULL, L"1\n2\n3\n4\n5\n6", -1, &rect, DT_NOCLIP, 0xff00ff);
     ok(height == 72, "Got unexpected height %d.\n", height);
-- 
2.24.0




More information about the wine-devel mailing list