[PATCH 3/4] d3dx9: Implement clipping of glyphs in ID3DXFont_DrawText.
Sven Baars
sbaars at codeweavers.com
Wed Nov 18 06:31:16 CST 2020
On 18-11-2020 13:23, Matteo Bruni wrote:
> On Tue, Nov 17, 2020 at 3:34 PM Sven Baars <sbaars at codeweavers.com> wrote:
>>
>> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49546
>> Signed-off-by: Sven Baars <sbaars at codeweavers.com>
>> ---
>> 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 235ae11072b..f5775384da3 100644
>> --- a/dlls/d3dx9_36/font.c
>> +++ b/dlls/d3dx9_36/font.c
>> @@ -583,7 +583,6 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, unsigned int *count,
>> }
>> else if (format & DT_SINGLELINE)
>> {
>> - *dest_len = num_fit;
>> *count = 0;
>> }
>> }
>
> IIUC this is to allow drawing partial glyphs in the DT_SINGLELINE
> case, is that right?
That is true.
>
>> @@ -768,6 +767,21 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
>> pos.y = cell_inc.y + y;
>> pos.z = 0;
>>
>> + 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);
>> }
>
> This certainly looks correct. I'm curious how this fixes bug 49546
> though. I'm not questioning that it does, just wondering how not
> clipping to the rect makes the text disappear altogether...
>
Because it passes DT_SINGLELINE | DT_NOCLIP with a 0x0 rect. This means
that previously the number of characters that fit was 0. Now we don't
set dest_len anymore, so we actually draw something.
More information about the wine-devel
mailing list