[v2 PATCH 3/3] gdi32: Implement GetFontFileData().

Nikolay Sivov nsivov at codeweavers.com
Tue Nov 20 14:54:32 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/gdi32/freetype.c   | 27 +++++++++++++++++++++++++++
 dlls/gdi32/gdi32.spec   |  1 +
 dlls/gdi32/tests/font.c |  9 +++------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 96e8e30deb..56425a9feb 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -8574,6 +8574,33 @@ static BOOL freetype_GetFontRealizationInfo( PHYSDEV dev, void *ptr )
     return TRUE;
 }
 
+BOOL WINAPI GetFontFileData( DWORD instance_id, DWORD unknown, UINT64 offset, void *buff, DWORD buff_size )
+{
+    struct font_handle_entry *entry = handle_entry( instance_id );
+    DWORD tag = 0, size;
+    GdiFont *font;
+
+    if (!entry)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    font = entry->obj;
+    if (font->ttc_item_offset)
+        tag = MS_TTCF_TAG;
+
+    size = get_font_data( font, tag, 0, NULL, 0 );
+    if (size < buff_size || offset > size - buff_size)
+    {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
+
+    /* For now this only works for SFNT case. */
+    return get_font_data( font, tag, offset, buff, buff_size ) != 0;
+}
+
 /*************************************************************************
  *             GetFontFileInfo   (GDI32.@)
  */
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 2400a51038..2dc8f0e887 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -281,6 +281,7 @@
 @ stdcall GetEnhMetaFileW(wstr)
 # @ stub GetFontAssocStatus
 @ stdcall GetFontData(long long long ptr long)
+@ stdcall GetFontFileData(long long int64 ptr long)
 @ stdcall GetFontFileInfo(long long ptr long ptr)
 @ stdcall GetFontLanguageInfo(long)
 @ stdcall GetFontRealizationInfo(long ptr)
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index d8713f7669..0a4b77cc04 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -61,7 +61,7 @@ static INT   (WINAPI *pAddFontResourceExA)(LPCSTR, DWORD, PVOID);
 static BOOL  (WINAPI *pRemoveFontResourceExA)(LPCSTR, DWORD, PVOID);
 static BOOL  (WINAPI *pGetFontRealizationInfo)(HDC hdc, DWORD *);
 static BOOL  (WINAPI *pGetFontFileInfo)(DWORD, DWORD, void *, SIZE_T, SIZE_T *);
-static BOOL  (WINAPI *pGetFontFileData)(DWORD, DWORD, ULONGLONG, void *, DWORD);
+static BOOL  (WINAPI *pGetFontFileData)(DWORD, DWORD, UINT64, void *, DWORD);
 
 static HMODULE hgdi32 = 0;
 static const MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
@@ -4401,14 +4401,12 @@ static void test_RealizationInfo(void)
             ok(r == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "ret %d gle %d\n", r, GetLastError());
         }
 
-    if (pGetFontFileData) {
         /* Get bytes 2 - 16 using GetFontFileData */
         r = pGetFontFileData(fri->instance_id, 0, 2, data, sizeof(data));
         ok(r != 0, "ret 0 gle %d\n", GetLastError());
 
         ok(!memcmp(data, file + 2, sizeof(data)), "mismatch\n");
     }
-    }
 
     DeleteObject(SelectObject(hdc, hfont_old));
 
@@ -5143,8 +5141,6 @@ static void test_realization_info(const char *name, DWORD size, BOOL is_memory_r
             wine_dbgstr_w(file_info.path));
     }
 
-if (pGetFontFileData)
-{
     size = file_info.size.LowPart;
     data = HeapAlloc(GetProcessHeap(), 0, size + 16);
 
@@ -5176,11 +5172,12 @@ if (pGetFontFileData)
     /* Zero buffer size. */
     memset(data, 0xcc, size);
     ret = pGetFontFileData(info.instance_id, 0, 16, data, 0);
+todo_wine
     ok(ret == 0 && GetLastError() == ERROR_NOACCESS, "Unexpected return value %d, error %d\n", ret, GetLastError());
     ok(*(DWORD *)data == 0xcccccccc, "Unexpected buffer contents %#x.\n", *(DWORD *)data);
 
     HeapFree(GetProcessHeap(), 0, data);
-}
+
     SelectObject(hdc, hfont_prev);
     DeleteObject(hfont);
     ReleaseDC(NULL, hdc);
-- 
2.19.1




More information about the wine-devel mailing list