[PATCH 3/5] d3dx9: Handle vertical alignment in ID3DXFont_DrawText.

Sven Baars sbaars at codeweavers.com
Mon Mar 16 05:15:25 CDT 2020


On 13-03-2020 17:22, Matteo Bruni wrote:
> On Tue, Mar 10, 2020 at 11:38 AM Sven Baars <sbaars at codeweavers.com> wrote:
>>
>> Signed-off-by: Sven Baars <sbaars at codeweavers.com>
>> ---
>>  dlls/d3dx9_36/font.c       | 30 ++++++++++++++++++++++++------
>>  dlls/d3dx9_36/tests/core.c | 14 ++++++++++++--
>>  2 files changed, 36 insertions(+), 8 deletions(-)
>>
>> diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c
>> index 3645903367..bd81a7044b 100644
>> --- a/dlls/d3dx9_36/font.c
>> +++ b/dlls/d3dx9_36/font.c
>> @@ -603,12 +603,12 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
>>          const WCHAR *string, INT count, RECT *rect, DWORD format, D3DCOLOR color)
>>  {
>>      struct d3dx_font *font = impl_from_ID3DXFont(iface);
>> +    RECT calcrect, textrect = {0};
>>      ID3DXSprite *target = sprite;
>> -    WCHAR *line;
>> -    RECT textrect = {0};
>>      int lh, x, y, width;
>>      int max_width = 0;
>>      int ret = 0;
>> +    WCHAR *line;
>>      SIZE size;
>>
>>      TRACE("iface %p, sprite %p, string %s, count %d, rect %s, format %#x, color 0x%08x.\n",
>> @@ -641,9 +641,27 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
>>          textrect = *rect;
>>      }
>>
>> -    x = textrect.left;
>> -    y = textrect.top;
>> -    width = textrect.right - textrect.left;
>> +    calcrect = textrect;
>> +
>> +    if (format & (DT_VCENTER | DT_BOTTOM))
>> +    {
>> +        y = ID3DXFont_DrawTextW(iface, NULL, string, count, &calcrect,
>> +                                format & ~DT_BOTTOM & ~DT_VCENTER, 0);
> 
> Was the idea here to add DT_CALCRECT to the format flags, by any
> chance? As it is now I think you end up drawing the text twice, once
> top-aligned and once with the "correct" vertical alignment flags.
> FWIW it doesn't look to me like it's necessary to do a recursive call
> to handle those flags.
> 
> Nitpick: indentation.
> 
In an earlier version there was a reason why I didn't need DT_CALCRECT
there for sure, but I don't see anymore why that would work right now.
What's weird is that I don't see the top-aligned draw of the text in my
test application. Anyhow, I added the DT_CALCRECT flag since it makes
sense to have it, and I also added some extra tests to show that the
recursive call is useful (MSDN says only single line drawing is
supported, but that is not true).



More information about the wine-devel mailing list