t2embed: Implement TTIsEmbeddingEnabled().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-04-02 12:19:18 +03:00 committed by Alexandre Julliard
parent 847da79cf8
commit 0ea8c1d62e
3 changed files with 69 additions and 3 deletions

View File

@ -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)

View File

@ -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();
}

View File

@ -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
}