From 0ea8c1d62e4993567e451ddcc25f4f0958e17266 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 2 Apr 2016 12:19:18 +0300 Subject: [PATCH] t2embed: Implement TTIsEmbeddingEnabled(). Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/t2embed/main.c | 24 ++++++++++++++++--- dlls/t2embed/tests/t2embed.c | 45 ++++++++++++++++++++++++++++++++++++ include/t2embapi.h | 3 +++ 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/dlls/t2embed/main.c b/dlls/t2embed/main.c index 9c807c71867..9fae0a833eb 100644 --- a/dlls/t2embed/main.c +++ b/dlls/t2embed/main.c @@ -148,9 +148,27 @@ LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled) LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled) { - FIXME("(%p %p) stub\n", hDC, enabled); - if (enabled) *enabled = FALSE; - return E_API_NOTIMPL; + OUTLINETEXTMETRICA *otm; + LONG ret; + UINT len; + + TRACE("(%p %p)\n", hDC, enabled); + + if (!hDC) + return E_HDCINVALID; + + len = GetOutlineTextMetricsA(hDC, 0, NULL); + if (!len) + return E_ERRORACCESSINGFACENAME; + + otm = HeapAlloc(GetProcessHeap(), 0, len); + if (!otm) + return E_NOFREEMEMORY; + + GetOutlineTextMetricsA(hDC, len, otm); + ret = TTIsEmbeddingEnabledForFacename(otm->otmpFaceName, enabled); + HeapFree(GetProcessHeap(), 0, otm); + return ret; } LONG WINAPI TTDeleteEmbeddedFont(HANDLE hFontReference, ULONG flags, ULONG *status) diff --git a/dlls/t2embed/tests/t2embed.c b/dlls/t2embed/tests/t2embed.c index 6efb231b240..79102a6f2ee 100644 --- a/dlls/t2embed/tests/t2embed.c +++ b/dlls/t2embed/tests/t2embed.c @@ -98,8 +98,53 @@ static void test_TTIsEmbeddingEnabledForFacename(void) ok(status != 123, "got %d\n", status); } +static void test_TTIsEmbeddingEnabled(void) +{ + HFONT old_font, hfont; + LONG ret, status; + LOGFONTA logfont; + HDC hdc; + + ret = TTIsEmbeddingEnabled(NULL, NULL); + ok(ret == E_HDCINVALID, "got %#x\n", ret); + + status = 123; + ret = TTIsEmbeddingEnabled(NULL, &status); + ok(ret == E_HDCINVALID, "got %#x\n", ret); + ok(status == 123, "got %d\n", status); + + hdc = CreateCompatibleDC(0); + + ret = TTIsEmbeddingEnabled(hdc, NULL); + ok(ret == E_ERRORACCESSINGFACENAME, "got %#x\n", ret); + + status = 123; + ret = TTIsEmbeddingEnabled(hdc, &status); + ok(ret == E_ERRORACCESSINGFACENAME, "got %#x\n", ret); + ok(status == 123, "got %u\n", status); + + memset(&logfont, 0, sizeof(logfont)); + logfont.lfHeight = 12; + logfont.lfWeight = FW_NORMAL; + strcpy(logfont.lfFaceName, "Tahoma"); + hfont = CreateFontIndirectA(&logfont); + ok(hfont != NULL, "got %p\n", hfont); + + old_font = SelectObject(hdc, hfont); + + status = 123; + ret = TTIsEmbeddingEnabled(hdc, &status); + ok(ret == E_NONE, "got %#x\n", ret); + ok(status != 123, "got %u\n", status); + + SelectObject(hdc, old_font); + DeleteObject(hfont); + DeleteDC(hdc); +} + START_TEST(t2embed) { test_TTGetEmbeddingType(); test_TTIsEmbeddingEnabledForFacename(); + test_TTIsEmbeddingEnabled(); } diff --git a/include/t2embapi.h b/include/t2embapi.h index 09067bd8d67..38d69007253 100644 --- a/include/t2embapi.h +++ b/include/t2embapi.h @@ -40,8 +40,10 @@ extern "C" { #define E_NONE __MSABI_LONG(0x0000) #define E_API_NOTIMPL __MSABI_LONG(0x0001) #define E_HDCINVALID __MSABI_LONG(0x0006) +#define E_NOFREEMEMORY __MSABI_LONG(0x0007) #define E_NOTATRUETYPEFONT __MSABI_LONG(0x000a) #define E_ERRORACCESSINGFONTDATA __MSABI_LONG(0x000c) +#define E_ERRORACCESSINGFACENAME __MSABI_LONG(0x000d) #define E_FACENAMEINVALID __MSABI_LONG(0x0113) #define E_PERMISSIONSINVALID __MSABI_LONG(0x0117) #define E_PBENABLEDINVALID __MSABI_LONG(0x0118) @@ -75,6 +77,7 @@ LONG WINAPI TTDeleteEmbeddedFont(HANDLE,ULONG,ULONG*); LONG WINAPI TTGetEmbeddingType(HDC, ULONG*); LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled); +LONG WINAPI TTIsEmbeddingEnabled(HDC hdc, BOOL *enabled); #ifdef __cplusplus }