From 2d6a23bef69f6a29b997f81c8d3c7c31498f300e Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 21 Nov 2018 15:54:03 +0300 Subject: [PATCH] gdi32: Implement GetFontFileData(). Signed-off-by: Nikolay Sivov Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- 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 96e8e30debe..5a4727239c1 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -8574,6 +8574,36 @@ static BOOL freetype_GetFontRealizationInfo( PHYSDEV dev, void *ptr ) return TRUE; } +/************************************************************************* + * 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.@) */ @@ -9040,6 +9070,14 @@ BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes) return TRUE; } +/************************************************************************* + * GetFontFileData (GDI32.@) + */ +BOOL WINAPI GetFontFileData( DWORD instance_id, DWORD unknown, UINT64 offset, void *buff, DWORD buff_size ) +{ + return FALSE; +} + /************************************************************************* * GetFontFileInfo (GDI32.@) */ diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec index 2400a510384..2dc8f0e8879 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 468e7d9db1b..75696946b27 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);