Jacek Caban : gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsI.
Alexandre Julliard
julliard at winehq.org
Fri Aug 27 15:03:34 CDT 2021
Module: wine
Branch: master
Commit: ce9b1ddc1a561e998a4540496af52c9654cb2edc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ce9b1ddc1a561e998a4540496af52c9654cb2edc
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Aug 27 13:51:50 2021 +0100
gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsI.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/font.c | 82 ++++++++++++++-----------------------------------------
dlls/gdi32/text.c | 11 ++++++++
2 files changed, 31 insertions(+), 62 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index d67f5f66467..e9071a571e3 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -4886,7 +4886,9 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first, UINT last, WCHAR *chars,
if (!(abc = HeapAlloc(GetProcessHeap(), 0, count * sizeof(ABC))))
return FALSE;
- if (!GetCharABCWidthsI( hdc, first, last, chars, abc ))
+ if (!NtGdiGetCharABCWidthsW( hdc, first, last, chars,
+ NTGDI_GETCHARABCWIDTHS_INT | NTGDI_GETCHARABCWIDTHS_INDICES,
+ abc ))
{
HeapFree( GetProcessHeap(), 0, abc );
return FALSE;
@@ -5641,18 +5643,26 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
return FALSE;
}
- if (!chars) count = last - first + 1;
-
- /* 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_INDICES)
{
- release_dc_ptr( dc );
- return FALSE;
+ dev = GET_DC_PHYSDEV( dc, pGetCharABCWidthsI );
+ ret = dev->funcs->pGetCharABCWidthsI( dev, first, count, chars, buffer );
+ }
+ 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))
+ {
+ release_dc_ptr( dc );
+ return FALSE;
+ }
+
+ if (!chars) count = last - first + 1;
+ dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
+ ret = dev->funcs->pGetCharABCWidths( dev, first, count, chars, buffer );
}
- dev = GET_DC_PHYSDEV( dc, pGetCharABCWidths );
- ret = dev->funcs->pGetCharABCWidths( dev, first, count, chars, buffer );
if (ret)
{
ABC *abc = buffer;
@@ -5670,58 +5680,6 @@ BOOL WINAPI NtGdiGetCharABCWidthsW( HDC hdc, UINT first, UINT last, WCHAR *chars
}
-/******************************************************************************
- * GetCharABCWidthsI [GDI32.@]
- *
- * Retrieves widths of characters in range.
- *
- * PARAMS
- * hdc [I] Handle of device context
- * firstChar [I] First glyphs in range to query
- * count [I] Last glyphs in range to query
- * pgi [i] Array of glyphs to query
- * abc [O] Address of character-width structure
- *
- * NOTES
- * Only works with TrueType fonts
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI GetCharABCWidthsI( HDC hdc, UINT firstChar, UINT count,
- LPWORD pgi, LPABC abc)
-{
- DC *dc = get_dc_ptr(hdc);
- PHYSDEV dev;
- unsigned int i;
- BOOL ret;
-
- if (!dc) return FALSE;
-
- if (!abc)
- {
- release_dc_ptr( dc );
- return FALSE;
- }
-
- dev = GET_DC_PHYSDEV( dc, pGetCharABCWidthsI );
- ret = dev->funcs->pGetCharABCWidthsI( dev, firstChar, count, pgi, abc );
- if (ret)
- {
- /* convert device units to logical */
- for( i = 0; i < count; i++, abc++ ) {
- abc->abcA = width_to_LP(dc, abc->abcA);
- abc->abcB = width_to_LP(dc, abc->abcB);
- abc->abcC = width_to_LP(dc, abc->abcC);
- }
- }
-
- release_dc_ptr( dc );
- return ret;
-}
-
-
/***********************************************************************
* GetGlyphOutlineA (GDI32.@)
*/
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index 469a74cc808..1238a8f9f45 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -1707,3 +1707,14 @@ BOOL WINAPI GetCharABCWidthsA( HDC hdc, UINT first, UINT last, ABC *abc )
HeapFree( GetProcessHeap(), 0, chars );
return ret;
}
+
+/***********************************************************************
+ * GetCharABCWidthsI (GDI32.@)
+ */
+BOOL WINAPI GetCharABCWidthsI( HDC hdc, UINT first, UINT count, WORD *glyphs, ABC *buffer )
+{
+ TRACE( "(%p, %d, %d, %p, %p)\n", hdc, first, count, glyphs, buffer );
+ return NtGdiGetCharABCWidthsW( hdc, first, count, glyphs,
+ NTGDI_GETCHARABCWIDTHS_INDICES | NTGDI_GETCHARABCWIDTHS_INT,
+ buffer );
+}
More information about the wine-cvs
mailing list