[v2 PATCH 1/2] t2embed: Implement TTIsEmbeddingEnabledForFacename()
Nikolay Sivov
nsivov at codeweavers.com
Sat Apr 2 04:19:17 CDT 2016
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
v2: use lstrcmpiA() to compare face names
dlls/t2embed/Makefile.in | 2 +-
dlls/t2embed/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
dlls/t2embed/t2embed.spec | 4 ++--
dlls/t2embed/tests/t2embed.c | 23 ++++++++++++++++++++++
include/t2embapi.h | 3 +++
5 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/dlls/t2embed/Makefile.in b/dlls/t2embed/Makefile.in
index e585fe2..baa4757 100644
--- a/dlls/t2embed/Makefile.in
+++ b/dlls/t2embed/Makefile.in
@@ -1,6 +1,6 @@
MODULE = t2embed.dll
IMPORTLIB = t2embed
-IMPORTS = gdi32
+IMPORTS = gdi32 advapi32
C_SRCS = \
main.c
diff --git a/dlls/t2embed/main.c b/dlls/t2embed/main.c
index 2794f0f..9c807c7 100644
--- a/dlls/t2embed/main.c
+++ b/dlls/t2embed/main.c
@@ -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);
diff --git a/dlls/t2embed/t2embed.spec b/dlls/t2embed/t2embed.spec
index e3be15c..5375fee 100644
--- a/dlls/t2embed/t2embed.spec
+++ b/dlls/t2embed/t2embed.spec
@@ -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 at 24
@@ -17,7 +17,7 @@
@ stub _TTGetEmbeddedFontInfo at 28
@ stdcall _TTGetEmbeddingType at 8(long ptr) TTGetEmbeddingType
@ stdcall _TTIsEmbeddingEnabled at 8(long ptr) TTIsEmbeddingEnabled
-@ stub _TTIsEmbeddingEnabledForFacename at 8
+@ stdcall _TTIsEmbeddingEnabledForFacename at 8(str ptr) TTIsEmbeddingEnabledForFacename
@ stdcall _TTLoadEmbeddedFont at 40(ptr long ptr long ptr ptr ptr wstr str ptr) TTLoadEmbeddedFont
@ stub _TTRunValidationTests at 8
@ stub TTEmbedFontEx
diff --git a/dlls/t2embed/tests/t2embed.c b/dlls/t2embed/tests/t2embed.c
index cdc2f49..6efb231 100644
--- a/dlls/t2embed/tests/t2embed.c
+++ b/dlls/t2embed/tests/t2embed.c
@@ -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();
}
diff --git a/include/t2embapi.h b/include/t2embapi.h
index 60fda64..09067bd 100644
--- a/include/t2embapi.h
+++ b/include/t2embapi.h
@@ -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
}
--
2.8.0.rc3
More information about the wine-patches
mailing list