gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsFloatW.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-08-27 13:51:51 +01:00 committed by Alexandre Julliard
parent ce9b1ddc1a
commit fb5a3ba541
2 changed files with 39 additions and 61 deletions

View File

@ -5650,13 +5650,16 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
} }
else else
{ {
/* unlike GetCharABCWidthsFloatW, this one is supposed to fail on non-scalable fonts */ if (flags & NTGDI_GETCHARABCWIDTHS_INT)
{
/* unlike float variant, this one is supposed to fail on non-scalable fonts */
dev = GET_DC_PHYSDEV( dc, pGetTextMetrics ); dev = GET_DC_PHYSDEV( dc, pGetTextMetrics );
if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR)) if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR))
{ {
release_dc_ptr( dc ); release_dc_ptr( dc );
return FALSE; return FALSE;
} }
}
if (!chars) count = last - first + 1; if (!chars) count = last - first + 1;
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths ); dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
@ -5666,6 +5669,8 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
if (ret) if (ret)
{ {
ABC *abc = buffer; ABC *abc = buffer;
if (flags & NTGDI_GETCHARABCWIDTHS_INT)
{
/* convert device units to logical */ /* convert device units to logical */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
@ -5674,6 +5679,20 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
abc[i].abcC = width_to_LP( dc, abc[i].abcC ); abc[i].abcC = width_to_LP( dc, abc[i].abcC );
} }
} }
else
{
/* convert device units to logical */
FLOAT scale = fabs( dc->xformVport2World.eM11 );
ABCFLOAT *abcf = buffer;
for (i = 0; i < count; i++)
{
abcf[i].abcfA = abc[i].abcA * scale;
abcf[i].abcfB = abc[i].abcB * scale;
abcf[i].abcfC = abc[i].abcC * scale;
}
}
}
release_dc_ptr( dc ); release_dc_ptr( dc );
return ret; return ret;
@ -6335,56 +6354,6 @@ BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT a
return ret; return ret;
} }
/*************************************************************************
* GetCharABCWidthsFloatW [GDI32.@]
*
* Retrieves widths of a range of characters.
*
* PARAMS
* hdc [I] Handle to device context.
* first [I] First character in range to query.
* last [I] Last character in range to query.
* abcf [O] Array of LPABCFLOAT structures.
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI GetCharABCWidthsFloatW( HDC hdc, UINT first, UINT last, LPABCFLOAT abcf )
{
UINT i;
ABC *abc;
PHYSDEV dev;
BOOL ret = FALSE;
DC *dc = get_dc_ptr( hdc );
TRACE("%p, %d, %d, %p\n", hdc, first, last, abcf);
if (!dc) return FALSE;
if (!abcf) goto done;
if (!(abc = HeapAlloc( GetProcessHeap(), 0, (last - first + 1) * sizeof(*abc) ))) goto done;
dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
ret = dev->funcs->pGetCharABCWidths( dev, first, last - first + 1, NULL, abc );
if (ret)
{
/* convert device units to logical */
FLOAT scale = fabs( dc->xformVport2World.eM11 );
for (i = first; i <= last; i++, abcf++)
{
abcf->abcfA = abc[i - first].abcA * scale;
abcf->abcfB = abc[i - first].abcB * scale;
abcf->abcfC = abc[i - first].abcC * scale;
}
}
HeapFree( GetProcessHeap(), 0, abc );
done:
release_dc_ptr( dc );
return ret;
}
/*********************************************************************** /***********************************************************************
* * * *
* Font Resource API * * Font Resource API *

View File

@ -1708,6 +1708,15 @@ BOOL WINAPI GetCharABCWidthsA( HDC hdc, UINT first, UINT last, ABC *abc )
return ret; return ret;
} }
/***********************************************************************
* GetCharABCWidthsFloatW (GDI32.@)
*/
BOOL WINAPI GetCharABCWidthsFloatW( HDC hdc, UINT first, UINT last, ABCFLOAT *abcf )
{
TRACE( "%p, %d, %d, %p\n", hdc, first, last, abcf );
return NtGdiGetCharABCWidthsW( hdc, first, last, NULL, 0, abcf );
}
/*********************************************************************** /***********************************************************************
* GetCharABCWidthsI (GDI32.@) * GetCharABCWidthsI (GDI32.@)
*/ */