d3dx9: Handle clipping in ID3DXFont_DrawText.

Signed-off-by: Sven Baars <sbaars@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Sven Baars 2020-03-05 22:39:58 +01:00 committed by Alexandre Julliard
parent 330c3f9108
commit 6da3e904a1
2 changed files with 6 additions and 1 deletions

View File

@ -559,6 +559,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
if (!count) if (!count)
return 0; return 0;
if (format & DT_CALCRECT)
format |= DT_NOCLIP;
if (!rect) if (!rect)
{ {
y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); 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); heap_free(results.lpGlyphs);
} }
y += lh; y += lh;
if (!(DT_NOCLIP & format) && (y > textrect.bottom))
break;
} }
ret = y - textrect.top; ret = y - textrect.top;

View File

@ -780,7 +780,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
todo_wine ok(height == 36, "Got unexpected height %d.\n", height); 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); 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); 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); ok(height == 72, "Got unexpected height %d.\n", height);