Nikolay Sivov : gdi32: Implement GetFontFileData().

Alexandre Julliard julliard at winehq.org
Wed Nov 21 16:08:07 CST 2018


Module: wine
Branch: master
Commit: 2d6a23bef69f6a29b997f81c8d3c7c31498f300e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=2d6a23bef69f6a29b997f81c8d3c7c31498f300e

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Nov 21 15:54:03 2018 +0300

gdi32: Implement GetFontFileData().

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/freetype.c   | 38 ++++++++++++++++++++++++++++++++++++++
 dlls/gdi32/gdi32.spec   |  1 +
 dlls/gdi32/tests/font.c |  9 +++------
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 96e8e30..5a47272 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -8575,6 +8575,36 @@ static BOOL freetype_GetFontRealizationInfo( PHYSDEV dev, void *ptr )
 }
 
 /*************************************************************************
+ *             GetFontFileData   (GDI32.@)
+ */
+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.@)
  */
 BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_fileinfo *info, SIZE_T size, SIZE_T *needed )
@@ -9041,6 +9071,14 @@ BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
 }
 
 /*************************************************************************
+ *             GetFontFileData   (GDI32.@)
+ */
+BOOL WINAPI GetFontFileData( DWORD instance_id, DWORD unknown, UINT64 offset, void *buff, DWORD buff_size )
+{
+    return FALSE;
+}
+
+/*************************************************************************
  *             GetFontFileInfo   (GDI32.@)
  */
 BOOL WINAPI GetFontFileInfo( DWORD instance_id, DWORD unknown, struct font_fileinfo *info, DWORD size, DWORD *needed)
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 2400a51..2dc8f0e 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 468e7d9..7569694 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} };
@@ -4402,14 +4402,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));
 
@@ -5144,8 +5142,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);
 
@@ -5177,11 +5173,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);




More information about the wine-cvs mailing list