[PATCH v2 5/9] gdi32: Use NtGdiGetCharABCWidthsW for GetCharABCWidthsFloatA.

Huw Davies huw at codeweavers.com
Fri Aug 27 07:51:52 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 | 88 -----------------------------------------------
 dlls/gdi32/text.c | 15 ++++++++
 2 files changed, 15 insertions(+), 88 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 07dcb77627a..59438939474 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -4813,60 +4813,6 @@ UINT WINAPI NtGdiGetOutlineTextMetricsInternalW( HDC hdc, UINT cbData,
     return ret;
 }
 
-static LPSTR FONT_GetCharsByRangeA(HDC hdc, UINT firstChar, UINT lastChar, PINT pByteLen)
-{
-    INT i, count = lastChar - firstChar + 1;
-    UINT mbcp;
-    UINT c;
-    LPSTR str;
-
-    if (count <= 0)
-        return NULL;
-
-    mbcp = GdiGetCodePage(hdc);
-    switch (mbcp)
-    {
-    case 932:
-    case 936:
-    case 949:
-    case 950:
-    case 1361:
-        if (lastChar > 0xffff)
-            return NULL;
-        if ((firstChar ^ lastChar) > 0xff)
-            return NULL;
-        break;
-    default:
-        if (lastChar > 0xff)
-            return NULL;
-        mbcp = 0;
-        break;
-    }
-
-    str = HeapAlloc(GetProcessHeap(), 0, count * 2 + 1);
-    if (str == NULL)
-        return NULL;
-
-    for(i = 0, c = firstChar; c <= lastChar; i++, c++)
-    {
-        if (mbcp) {
-            if (c > 0xff)
-                str[i++] = (BYTE)(c >> 8);
-            if (c <= 0xff && IsDBCSLeadByteEx(mbcp, c))
-                str[i] = 0x1f; /* FIXME: use default character */
-            else
-                str[i] = (BYTE)c;
-        }
-        else
-            str[i] = (BYTE)c;
-    }
-    str[i] = '\0';
-
-    *pByteLen = i;
-
-    return str;
-}
-
 /***********************************************************************
  *           NtGdiGetCharWidthW    (win32u.@)
  */
@@ -6320,40 +6266,6 @@ DWORD WINAPI GetGlyphIndicesW(HDC hdc, LPCWSTR lpstr, INT count,
     return ret;
 }
 
-/*************************************************************************
- *      GetCharABCWidthsFloatA [GDI32.@]
- *
- * See GetCharABCWidthsFloatW.
- */
-BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT abcf )
-{
-    INT i, wlen;
-    LPSTR str;
-    LPWSTR wstr;
-    BOOL ret = TRUE;
-
-    str = FONT_GetCharsByRangeA(hdc, first, last, &i);
-    if (str == NULL)
-        return FALSE;
-
-    wstr = FONT_mbtowc( hdc, str, i, &wlen, NULL );
-
-    for (i = 0; i < wlen; i++)
-    {
-        if (!GetCharABCWidthsFloatW( hdc, wstr[i], wstr[i], abcf ))
-        {
-            ret = FALSE;
-            break;
-        }
-        abcf++;
-    }
-
-    HeapFree( GetProcessHeap(), 0, str );
-    HeapFree( GetProcessHeap(), 0, wstr );
-
-    return ret;
-}
-
 /***********************************************************************
  *								       *
  *           Font Resource API					       *
diff --git a/dlls/gdi32/text.c b/dlls/gdi32/text.c
index a119615e002..beb9908f6ce 100644
--- a/dlls/gdi32/text.c
+++ b/dlls/gdi32/text.c
@@ -1717,6 +1717,21 @@ BOOL WINAPI GetCharABCWidthsFloatW( HDC hdc, UINT first, UINT last, ABCFLOAT *ab
     return NtGdiGetCharABCWidthsW( hdc, first, last, NULL, 0, abcf );
 }
 
+/***********************************************************************
+ *      GetCharABCWidthsFloatA    (GDI32.@)
+ */
+BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, ABCFLOAT *abcf )
+{
+    WCHAR *chars;
+    INT count;
+    BOOL ret;
+
+    if (!(chars = get_chars_by_range( hdc, first, last, &count ))) return FALSE;
+    ret = NtGdiGetCharABCWidthsW( hdc, 0, count, chars, 0, abcf );
+    HeapFree( GetProcessHeap(), 0, chars );
+    return ret;
+}
+
 /***********************************************************************
  *           GetCharABCWidthsI    (GDI32.@)
  */
-- 
2.23.0




More information about the wine-devel mailing list