gdi32: Use NtGdiGetCharWidthW for GetCharWidthFloatW.

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-26 13:45:16 +01:00 committed by Alexandre Julliard
parent 2c77643ee9
commit e5f5e7342d
2 changed files with 21 additions and 37 deletions

View File

@ -4882,10 +4882,19 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first, UINT last, WCHAR *chars,
if (ret)
{
INT *buffer = buf;
/* convert device units to logical */
for (i = 0; i < count; i++)
buffer[i] = width_to_LP( dc, buffer[i] );
if (flags & NTGDI_GETCHARWIDTH_INT)
{
INT *buffer = buf;
/* convert device units to logical */
for (i = 0; i < count; i++)
buffer[i] = width_to_LP( dc, buffer[i] );
}
else
{
float scale = fabs( dc->xformVport2World.eM11 ) / 16.0f;
for (i = 0; i < count; i++)
((float *)buf)[i] = ((int *)buf)[i] * scale;
}
}
release_dc_ptr( dc );
return ret;
@ -6460,39 +6469,6 @@ BOOL WINAPI GetCharWidthFloatA( HDC hdc, UINT first, UINT last, float *buffer )
return TRUE;
}
/*************************************************************************
* GetCharWidthFloatW [GDI32.@]
*/
BOOL WINAPI GetCharWidthFloatW( HDC hdc, UINT first, UINT last, float *buffer )
{
DC *dc = get_dc_ptr( hdc );
int *ibuffer;
PHYSDEV dev;
BOOL ret;
UINT i;
TRACE("dc %p, first %#x, last %#x, buffer %p\n", dc, first, last, buffer);
if (!dc) return FALSE;
if (!(ibuffer = heap_alloc( (last - first + 1) * sizeof(int) )))
{
release_dc_ptr( dc );
return FALSE;
}
dev = GET_DC_PHYSDEV( dc, pGetCharWidth );
if ((ret = dev->funcs->pGetCharWidth( dev, first, last - first + 1, NULL, ibuffer )))
{
float scale = fabs( dc->xformVport2World.eM11 ) / 16.0f;
for (i = first; i <= last; ++i)
buffer[i - first] = ibuffer[i - first] * scale;
}
heap_free(ibuffer);
return ret;
}
/***********************************************************************
* *
* Font Resource API *

View File

@ -1649,3 +1649,11 @@ BOOL WINAPI GetCharWidth32A( HDC hdc, UINT first, UINT last, INT *buffer )
HeapFree( GetProcessHeap(), 0, chars );
return ret;
}
/***********************************************************************
* GetCharWidthFloatW (GDI32.@)
*/
BOOL WINAPI GetCharWidthFloatW( HDC hdc, UINT first, UINT last, float *buffer )
{
return NtGdiGetCharWidthW( hdc, first, last, NULL, 0, buffer );
}