From: Sven Baars Subject: [PATCH v4 5/5] d3dx9: Implement clipping of glyphs in ID3DXFont_DrawText. Message-Id: <20200327164836.14244-5-sbaars@codeweavers.com> Date: Fri, 27 Mar 2020 17:48:36 +0100 In-Reply-To: <20200327164836.14244-1-sbaars@codeweavers.com> References: <20200327164836.14244-1-sbaars@codeweavers.com> Signed-off-by: Sven Baars --- dlls/d3dx9_36/font.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index 4835732931..5adb2f3a89 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -621,7 +621,6 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, } else if (format & DT_SINGLELINE) { - seg_len = num_fit; *count = 0; word_broken = TRUE; } @@ -844,6 +843,21 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, pos.x = cell_inc.x + x + results.lpCaretPos[i]; pos.y = cell_inc.y + y; + if (!(format & DT_NOCLIP)) + { + if (pos.x > rect->right) + { + IDirect3DTexture9_Release(texture); + continue; + } + + if (pos.x + black_box.right - black_box.left > rect->right) + black_box.right = black_box.left + rect->right - pos.x; + + if (pos.y + black_box.bottom - black_box.top > rect->bottom) + black_box.bottom = black_box.top + rect->bottom - pos.y; + } + ID3DXSprite_Draw(target, texture, &black_box, NULL, &pos, color); IDirect3DTexture9_Release(texture); } -- 2.24.0