t2embed: Implement TTIsEmbeddingEnabledForFacename().

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:17 +03:00 committed by Alexandre Julliard
parent 33765285c5
commit 847da79cf8
5 changed files with 75 additions and 3 deletions

View File

@ -1,6 +1,6 @@
MODULE = t2embed.dll
IMPORTLIB = t2embed
IMPORTS = gdi32
IMPORTS = gdi32 advapi32
C_SRCS = \
main.c

View File

@ -25,6 +25,7 @@
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "t2embapi.h"
#include "wine/debug.h"
@ -100,6 +101,51 @@ LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status)
return E_NONE;
}
LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled)
{
static const WCHAR exclusionlistW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'S','h','a','r','e','d',' ','T','o','o','l','s','\\','t','2','e','m','b','e','d',0};
DWORD index;
HKEY hkey;
LONG ret;
TRACE("(%s %p)\n", debugstr_a(facename), enabled);
if (!facename)
return E_FACENAMEINVALID;
if (!enabled)
return E_PBENABLEDINVALID;
*enabled = TRUE;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, exclusionlistW, 0, GENERIC_READ, &hkey))
return E_NONE;
*enabled = TRUE;
ret = ERROR_SUCCESS;
index = 0;
while (ret != ERROR_NO_MORE_ITEMS)
{
DWORD name_len, value_len, value, type;
CHAR name[LF_FACESIZE];
name_len = sizeof(name)/sizeof(*name);
value_len = sizeof(value);
ret = RegEnumValueA(hkey, index++, name, &name_len, NULL, &type, (BYTE*)&value, &value_len);
if (ret || type != REG_DWORD)
continue;
if (!lstrcmpiA(name, facename))
{
*enabled = !!value;
break;
}
}
RegCloseKey(hkey);
return E_NONE;
}
LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled)
{
FIXME("(%p %p) stub\n", hDC, enabled);

View File

@ -6,7 +6,7 @@
@ stub TTGetEmbeddedFontInfo
@ stdcall TTGetEmbeddingType(long ptr)
@ stdcall TTIsEmbeddingEnabled(long ptr)
@ stub TTIsEmbeddingEnabledForFacename
@ stdcall TTIsEmbeddingEnabledForFacename(str ptr)
@ stdcall TTLoadEmbeddedFont(ptr long ptr long ptr ptr ptr wstr str ptr)
@ stub TTRunValidationTests
@ stub _TTCharToUnicode@24
@ -17,7 +17,7 @@
@ stub _TTGetEmbeddedFontInfo@28
@ stdcall _TTGetEmbeddingType@8(long ptr) TTGetEmbeddingType
@ stdcall _TTIsEmbeddingEnabled@8(long ptr) TTIsEmbeddingEnabled
@ stub _TTIsEmbeddingEnabledForFacename@8
@ stdcall _TTIsEmbeddingEnabledForFacename@8(str ptr) TTIsEmbeddingEnabledForFacename
@ stdcall _TTLoadEmbeddedFont@40(ptr long ptr long ptr ptr ptr wstr str ptr) TTLoadEmbeddedFont
@ stub _TTRunValidationTests@8
@ stub TTEmbedFontEx

View File

@ -76,7 +76,30 @@ static void test_TTGetEmbeddingType(void)
DeleteDC(hdc);
}
static void test_TTIsEmbeddingEnabledForFacename(void)
{
BOOL status;
LONG ret;
ret = TTIsEmbeddingEnabledForFacename(NULL, NULL);
ok(ret == E_FACENAMEINVALID, "got %#x\n", ret);
status = 123;
ret = TTIsEmbeddingEnabledForFacename(NULL, &status);
ok(ret == E_FACENAMEINVALID, "got %#x\n", ret);
ok(status == 123, "got %d\n", status);
ret = TTIsEmbeddingEnabledForFacename("Arial", NULL);
ok(ret == E_PBENABLEDINVALID, "got %#x\n", ret);
status = 123;
ret = TTIsEmbeddingEnabledForFacename("Arial", &status);
ok(ret == E_NONE, "got %#x\n", ret);
ok(status != 123, "got %d\n", status);
}
START_TEST(t2embed)
{
test_TTGetEmbeddingType();
test_TTIsEmbeddingEnabledForFacename();
}

View File

@ -42,7 +42,9 @@ extern "C" {
#define E_HDCINVALID __MSABI_LONG(0x0006)
#define E_NOTATRUETYPEFONT __MSABI_LONG(0x000a)
#define E_ERRORACCESSINGFONTDATA __MSABI_LONG(0x000c)
#define E_FACENAMEINVALID __MSABI_LONG(0x0113)
#define E_PERMISSIONSINVALID __MSABI_LONG(0x0117)
#define E_PBENABLEDINVALID __MSABI_LONG(0x0118)
typedef ULONG (WINAPIV * READEMBEDPROC)(void*,void*,ULONG);
typedef ULONG (WINAPIV * WRITEEMBEDPROC)(void*,void*,ULONG);
@ -72,6 +74,7 @@ LONG WINAPI TTDeleteEmbeddedFont(HANDLE,ULONG,ULONG*);
#define EMBED_NOEMBEDDING 4
LONG WINAPI TTGetEmbeddingType(HDC, ULONG*);
LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled);
#ifdef __cplusplus
}