From 6da3e904a1efc921030fdbe34070b981bf57524c Mon Sep 17 00:00:00 2001 From: Sven Baars Date: Thu, 5 Mar 2020 22:39:58 +0100 Subject: [PATCH] d3dx9: Handle clipping in ID3DXFont_DrawText. Signed-off-by: Sven Baars Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- 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 71cfddb0d46..9e9cb658db0 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 c6f5beff433..c79f5c1f728 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);