From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/font.c | 50 ++++++++++++----------------------------------- dlls/gdi32/text.c | 8 ++++++++ 2 files changed, 21 insertions(+), 37 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c index 7e4d67af8ae..cbf3f6fb555 100644 --- a/dlls/gdi32/font.c +++ b/dlls/gdi32/font.c @@ -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 * diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c index 0bb47f00c24..b753dac7052 100644 --- a/dlls/gdi32/text.c +++ b/dlls/gdi32/text.c @@ -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 ); +}