Module: wine Branch: master Commit: 12fbfe838c2e6f41ead7445decc447b41921474a URL: http://source.winehq.org/git/wine.git/?a=commit;h=12fbfe838c2e6f41ead7445dec...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Mar 30 13:00:26 2016 +0300
t2embed: Implement TTGetEmbeddingType().
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
configure | 3 +- configure.ac | 3 +- dlls/t2embed/Makefile.in | 2 ++ dlls/t2embed/main.c | 28 +++++++++++++-- dlls/t2embed/tests/Makefile.in | 5 +++ dlls/t2embed/tests/t2embed.c | 82 ++++++++++++++++++++++++++++++++++++++++++ include/t2embapi.h | 4 +++ 7 files changed, 122 insertions(+), 5 deletions(-)
diff --git a/configure b/configure index 764ac45..c1abf1f 100755 --- a/configure +++ b/configure @@ -17969,7 +17969,8 @@ wine_fn_config_dll svrapi enable_svrapi wine_fn_config_dll sxs enable_sxs implib wine_fn_config_test dlls/sxs/tests sxs_test wine_fn_config_dll system.drv16 enable_win16 -wine_fn_config_dll t2embed enable_t2embed +wine_fn_config_dll t2embed enable_t2embed implib +wine_fn_config_test dlls/t2embed/tests t2embed_test wine_fn_config_dll tapi32 enable_tapi32 implib wine_fn_config_dll taskschd enable_taskschd clean wine_fn_config_test dlls/taskschd/tests taskschd_test diff --git a/configure.ac b/configure.ac index f63dd61..c89aa08 100644 --- a/configure.ac +++ b/configure.ac @@ -3266,7 +3266,8 @@ WINE_CONFIG_DLL(svrapi) WINE_CONFIG_DLL(sxs,,[implib]) WINE_CONFIG_TEST(dlls/sxs/tests) WINE_CONFIG_DLL(system.drv16,enable_win16) -WINE_CONFIG_DLL(t2embed) +WINE_CONFIG_DLL(t2embed,,[implib]) +WINE_CONFIG_TEST(dlls/t2embed/tests) WINE_CONFIG_DLL(tapi32,,[implib]) WINE_CONFIG_DLL(taskschd,,[clean]) WINE_CONFIG_TEST(dlls/taskschd/tests) diff --git a/dlls/t2embed/Makefile.in b/dlls/t2embed/Makefile.in index d123846..e585fe2 100644 --- a/dlls/t2embed/Makefile.in +++ b/dlls/t2embed/Makefile.in @@ -1,4 +1,6 @@ MODULE = t2embed.dll +IMPORTLIB = t2embed +IMPORTS = gdi32
C_SRCS = \ main.c diff --git a/dlls/t2embed/main.c b/dlls/t2embed/main.c index e1a880d..2794f0f 100644 --- a/dlls/t2embed/main.c +++ b/dlls/t2embed/main.c @@ -24,6 +24,7 @@
#include "windef.h" #include "winbase.h" +#include "wingdi.h" #include "t2embapi.h" #include "wine/debug.h"
@@ -73,9 +74,30 @@ LONG WINAPI TTEmbedFont(HDC hDC, ULONG ulFlags, ULONG ulCharSet, ULONG *pulPrivS
LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status) { - FIXME("(%p %p) stub\n", hDC, status); - if (status) *status = EMBED_NOEMBEDDING; - return E_API_NOTIMPL; + OUTLINETEXTMETRICW otm; + + TRACE("(%p %p)\n", hDC, status); + + if (!hDC) + return E_HDCINVALID; + + otm.otmSize = sizeof(otm); + if (!GetOutlineTextMetricsW(hDC, otm.otmSize, &otm)) + return E_NOTATRUETYPEFONT; + + if (!status) + return E_PERMISSIONSINVALID; + + if (otm.otmfsType == LICENSE_INSTALLABLE) + *status = EMBED_INSTALLABLE; + else if (otm.otmfsType & LICENSE_NOEMBEDDING) + *status = EMBED_NOEMBEDDING; + else if (otm.otmfsType & LICENSE_PREVIEWPRINT) + *status = EMBED_PREVIEWPRINT; + else if (otm.otmfsType & LICENSE_EDITABLE) + *status = EMBED_EDITABLE; + + return E_NONE; }
LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled) diff --git a/dlls/t2embed/tests/Makefile.in b/dlls/t2embed/tests/Makefile.in new file mode 100644 index 0000000..f7a5809 --- /dev/null +++ b/dlls/t2embed/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = t2embed.dll +IMPORTS = gdi32 t2embed + +C_SRCS = \ + t2embed.c diff --git a/dlls/t2embed/tests/t2embed.c b/dlls/t2embed/tests/t2embed.c new file mode 100644 index 0000000..cdc2f49 --- /dev/null +++ b/dlls/t2embed/tests/t2embed.c @@ -0,0 +1,82 @@ +/* + * Copyright 2016 Nikolay Sivov for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include "windef.h" +#include "wingdi.h" +#include "t2embapi.h" +#include "wine/test.h" + +static void test_TTGetEmbeddingType(void) +{ + HFONT hfont, old_font; + LOGFONTA logfont; + ULONG status; + LONG ret; + HDC hdc; + + ret = TTGetEmbeddingType(NULL, NULL); + ok(ret == E_HDCINVALID, "got %d\n", ret); + + status = 0xdeadbeef; + ret = TTGetEmbeddingType(NULL, &status); + ok(ret == E_HDCINVALID, "got %#x\n", ret); + ok(status == 0xdeadbeef, "got %u\n", status); + + status = 0xdeadbeef; + ret = TTGetEmbeddingType((HDC)0xdeadbeef, &status); + ok(ret == E_NOTATRUETYPEFONT || broken(ret == E_ERRORACCESSINGFONTDATA) /* xp, vista */, "got %#x\n", ret); + ok(status == 0xdeadbeef, "got %u\n", status); + + hdc = CreateCompatibleDC(0); + + ret = TTGetEmbeddingType(hdc, NULL); + ok(ret == E_NOTATRUETYPEFONT, "got %#x\n", ret); + + status = 0xdeadbeef; + ret = TTGetEmbeddingType(hdc, &status); + ok(ret == E_NOTATRUETYPEFONT, "got %#x\n", ret); + ok(status == 0xdeadbeef, "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 = 0; + ret = TTGetEmbeddingType(hdc, &status); + ok(ret == E_NONE, "got %#x\n", ret); + ok(status != 0, "got %u\n", status); + + ret = TTGetEmbeddingType(hdc, NULL); + ok(ret == E_PERMISSIONSINVALID, "got %#x\n", ret); + + SelectObject(hdc, old_font); + DeleteObject(hfont); + DeleteDC(hdc); +} + +START_TEST(t2embed) +{ + test_TTGetEmbeddingType(); +} diff --git a/include/t2embapi.h b/include/t2embapi.h index 16d68f3..60fda64 100644 --- a/include/t2embapi.h +++ b/include/t2embapi.h @@ -39,6 +39,10 @@ extern "C" { /* Possible return values. */ #define E_NONE __MSABI_LONG(0x0000) #define E_API_NOTIMPL __MSABI_LONG(0x0001) +#define E_HDCINVALID __MSABI_LONG(0x0006) +#define E_NOTATRUETYPEFONT __MSABI_LONG(0x000a) +#define E_ERRORACCESSINGFONTDATA __MSABI_LONG(0x000c) +#define E_PERMISSIONSINVALID __MSABI_LONG(0x0117)
typedef ULONG (WINAPIV * READEMBEDPROC)(void*,void*,ULONG); typedef ULONG (WINAPIV * WRITEEMBEDPROC)(void*,void*,ULONG);