[PATCH v2 4/9] gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsFloatW.
Huw Davies
huw at codeweavers.com
Fri Aug 27 07:51:51 CDT 2021
From: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/gdi32/font.c | 91 ++++++++++++++++-------------------------------
dlls/gdi32/text.c | 9 +++++
2 files changed, 39 insertions(+), 61 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index e9071a571e3..07dcb77627a 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -5650,12 +5650,15 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
}
else
{
- /* unlike GetCharABCWidthsFloatW, this one is supposed to fail on non-scalable fonts */
- dev = GET_DC_PHYSDEV( dc, pGetTextMetrics );
- if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR))
+ if (flags & NTGDI_GETCHARABCWIDTHS_INT)
{
- release_dc_ptr( dc );
- return FALSE;
+ /* unlike float variant, this one is supposed to fail on non-scalable fonts */
+ dev = GET_DC_PHYSDEV( dc, pGetTextMetrics );
+ if (!dev->funcs->pGetTextMetrics( dev, &tm ) || !(tm.tmPitchAndFamily & TMPF_VECTOR))
+ {
+ release_dc_ptr( dc );
+ return FALSE;
+ }
}
if (!chars) count = last - first + 1;
@@ -5666,13 +5669,29 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
if (ret)
{
ABC *abc = buffer;
- /* convert device units to logical */
- for (i = 0; i < count; i++)
+ if (flags & NTGDI_GETCHARABCWIDTHS_INT)
{
- abc[i].abcA = width_to_LP( dc, abc[i].abcA );
- abc[i].abcB = width_to_LP( dc, abc[i].abcB );
- abc[i].abcC = width_to_LP( dc, abc[i].abcC );
- }
+ /* convert device units to logical */
+ for (i = 0; i < count; i++)
+ {
+ abc[i].abcA = width_to_LP( dc, abc[i].abcA );
+ abc[i].abcB = width_to_LP( dc, abc[i].abcB );
+ 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 );
@@ -6335,56 +6354,6 @@ BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT a
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 *
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index 1238a8f9f45..a119615e002 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -1708,6 +1708,15 @@ BOOL WINAPI GetCharABCWidthsA( HDC hdc, UINT first, UINT last, ABC *abc )
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.@)
*/
--
2.23.0
More information about the wine-devel
mailing list