Hans Leidekker : gdi: better implementation for GetCharABCWidthsFloat{A, W}.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 16 14:37:45 CST 2006


Module: wine
Branch: refs/heads/master
Commit: f8125a98d8dbd1979021d69df6ebe701fe6c3e39
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=f8125a98d8dbd1979021d69df6ebe701fe6c3e39

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Mon Jan 16 20:38:17 2006 +0100

gdi: better implementation for GetCharABCWidthsFloat{A,W}.

---

 dlls/gdi/font.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 72 insertions(+), 10 deletions(-)

diff --git a/dlls/gdi/font.c b/dlls/gdi/font.c
index e6a00a3..ffebd7e 100644
--- a/dlls/gdi/font.c
+++ b/dlls/gdi/font.c
@@ -2785,22 +2785,84 @@ GetCharacterPlacementW(
 
 /*************************************************************************
  *      GetCharABCWidthsFloatA [GDI32.@]
+ *
+ * See GetCharABCWidthsFloatW.
  */
-BOOL WINAPI GetCharABCWidthsFloatA(HDC hdc, UINT iFirstChar, UINT iLastChar,
-		                        LPABCFLOAT lpABCF)
+BOOL WINAPI GetCharABCWidthsFloatA( HDC hdc, UINT first, UINT last, LPABCFLOAT abcf )
 {
-       FIXME_(gdi)("GetCharABCWidthsFloatA, stub\n");
-       return 0;
+    INT i, wlen, count = (INT)(last - first + 1);
+    LPSTR str;
+    LPWSTR wstr;
+    BOOL ret = TRUE;
+
+    if (count <= 0) return FALSE;
+
+    str = HeapAlloc(GetProcessHeap(), 0, count);
+
+    for(i = 0; i < count; i++)
+        str[i] = (BYTE)(first + i);
+
+    wstr = FONT_mbtowc( hdc, str, count, &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;
 }
 
 /*************************************************************************
  *      GetCharABCWidthsFloatW [GDI32.@]
- */
-BOOL WINAPI GetCharABCWidthsFloatW(HDC hdc, UINT iFirstChar,
-		                        UINT iLastChar, LPABCFLOAT lpABCF)
-{
-       FIXME_(gdi)("GetCharABCWidthsFloatW, stub\n");
-       return 0;
+ *
+ * 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
+ *
+ * BUGS
+ *    Only works with TrueType fonts. It also doesn't return real
+ *    floats but converted integers because it's implemented on
+ *    top of GetCharABCWidthsW.
+ */
+BOOL WINAPI GetCharABCWidthsFloatW( HDC hdc, UINT first, UINT last, LPABCFLOAT abcf )
+{
+    ABC *abc;
+    unsigned int i, size = sizeof(ABC) * (last - first + 1);
+    BOOL ret;
+
+    TRACE("%p, %d, %d, %p - partial stub\n", hdc, first, last, abcf);
+
+    abc = HeapAlloc( GetProcessHeap(), 0, size );
+    if (!abc) return FALSE;
+
+    ret = GetCharABCWidthsW( hdc, first, last, abc );
+    if (ret == TRUE)
+    {
+        for (i = first; i <= last; i++, abc++, abcf++)
+        {
+            abcf->abcfA = abc->abcA;
+            abcf->abcfB = abc->abcB;
+            abcf->abcfC = abc->abcC;
+        }
+    }
+    HeapFree( GetProcessHeap(), 0, abc );
+    return ret;
 }
 
 /*************************************************************************




More information about the wine-cvs mailing list