[PATCH v2 7/7] gdi32: Use NtGdiGetCharWidthW for GetCharWidthI.
Huw Davies
huw at codeweavers.com
Thu Aug 26 07:45:18 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 | 67 ++++++++++++++++-------------------------------
dlls/gdi32/text.c | 10 +++++++
2 files changed, 33 insertions(+), 44 deletions(-)
diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 4faaaacdfce..e80143066b5 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -4872,9 +4872,30 @@ BOOL WINAPI NtGdiGetCharWidthW( HDC hdc, UINT first, UINT last, WCHAR *chars,
UINT i, count = last;
BOOL ret;
PHYSDEV dev;
- DC * dc = get_dc_ptr( hdc );
+ DC *dc;
- if (!dc) return FALSE;
+ if (flags & NTGDI_GETCHARWIDTH_INDICES)
+ {
+ ABC *abc;
+ unsigned int i;
+
+ if (!(abc = HeapAlloc(GetProcessHeap(), 0, count * sizeof(ABC))))
+ return FALSE;
+
+ if (!GetCharABCWidthsI( hdc, first, last, chars, abc ))
+ {
+ HeapFree( GetProcessHeap(), 0, abc );
+ return FALSE;
+ }
+
+ for (i = 0; i < count; i++)
+ ((INT *)buf)[i] = abc[i].abcA + abc[i].abcB + abc[i].abcC;
+
+ HeapFree(GetProcessHeap(), 0, abc);
+ return TRUE;
+ }
+
+ if (!(dc = get_dc_ptr( hdc ))) return FALSE;
if (!chars) count = last - first + 1;
dev = GET_DC_PHYSDEV( dc, pGetCharWidth );
@@ -7114,48 +7135,6 @@ BOOL WINAPI EnableEUDC(BOOL fEnableEUDC)
return FALSE;
}
-/***********************************************************************
- * GetCharWidthI (GDI32.@)
- *
- * Retrieve widths of characters.
- *
- * PARAMS
- * hdc [I] Handle to a device context.
- * first [I] First glyph in range to query.
- * count [I] Number of glyph indices to query.
- * glyphs [I] Array of glyphs to query.
- * buffer [O] Buffer to receive character widths.
- *
- * NOTES
- * Only works with TrueType fonts.
- *
- * RETURNS
- * Success: TRUE
- * Failure: FALSE
- */
-BOOL WINAPI GetCharWidthI(HDC hdc, UINT first, UINT count, LPWORD glyphs, LPINT buffer)
-{
- ABC *abc;
- unsigned int i;
-
- TRACE("(%p, %d, %d, %p, %p)\n", hdc, first, count, glyphs, buffer);
-
- if (!(abc = HeapAlloc(GetProcessHeap(), 0, count * sizeof(ABC))))
- return FALSE;
-
- if (!GetCharABCWidthsI(hdc, first, count, glyphs, abc))
- {
- HeapFree(GetProcessHeap(), 0, abc);
- return FALSE;
- }
-
- for (i = 0; i < count; i++)
- buffer[i] = abc[i].abcA + abc[i].abcB + abc[i].abcC;
-
- HeapFree(GetProcessHeap(), 0, abc);
- return TRUE;
-}
-
/***********************************************************************
* GetFontUnicodeRanges (GDI32.@)
*
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index b31196252ad..c3d72938eba 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -1672,3 +1672,13 @@ BOOL WINAPI GetCharWidthFloatA( HDC hdc, UINT first, UINT last, float *buffer )
HeapFree( GetProcessHeap(), 0, chars );
return ret;
}
+
+/***********************************************************************
+ * GetCharWidthI (GDI32.@)
+ */
+BOOL WINAPI GetCharWidthI( HDC hdc, UINT first, UINT count, WORD *glyphs, INT *buffer )
+{
+ TRACE( "(%p, %d, %d, %p, %p)\n", hdc, first, count, glyphs, buffer );
+ return NtGdiGetCharWidthW( hdc, first, count, glyphs,
+ NTGDI_GETCHARWIDTH_INT | NTGDI_GETCHARWIDTH_INDICES, buffer );
+}
--
2.23.0
More information about the wine-devel
mailing list