[PATCH] t2embed: Fix embedding type resolution order
Nikolay Sivov
nsivov at codeweavers.com
Wed Aug 10 16:19:21 CDT 2016
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/t2embed/main.c | 15 ++++++++----
dlls/t2embed/tests/Makefile.in | 2 +-
dlls/t2embed/tests/t2embed.c | 55 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/dlls/t2embed/main.c b/dlls/t2embed/main.c
index 9fae0a8..48e20f5 100644
--- a/dlls/t2embed/main.c
+++ b/dlls/t2embed/main.c
@@ -33,7 +33,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(t2embed);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
-
switch (fdwReason)
{
case DLL_WINE_PREATTACH:
@@ -89,14 +88,20 @@ LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status)
if (!status)
return E_PERMISSIONSINVALID;
+ otm.otmfsType &= 0xf;
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;
+ else if (otm.otmfsType & LICENSE_PREVIEWPRINT)
+ *status = EMBED_PREVIEWPRINT;
+ else if (otm.otmfsType & LICENSE_NOEMBEDDING)
+ *status = EMBED_NOEMBEDDING;
+ else
+ {
+ WARN("unrecognized flags, %#x\n", otm.otmfsType);
+ *status = EMBED_INSTALLABLE;
+ }
return E_NONE;
}
diff --git a/dlls/t2embed/tests/Makefile.in b/dlls/t2embed/tests/Makefile.in
index f7a5809..c4f49a3 100644
--- a/dlls/t2embed/tests/Makefile.in
+++ b/dlls/t2embed/tests/Makefile.in
@@ -1,5 +1,5 @@
TESTDLL = t2embed.dll
-IMPORTS = gdi32 t2embed
+IMPORTS = user32 gdi32 t2embed
C_SRCS = \
t2embed.c
diff --git a/dlls/t2embed/tests/t2embed.c b/dlls/t2embed/tests/t2embed.c
index 79102a6..9f278a5 100644
--- a/dlls/t2embed/tests/t2embed.c
+++ b/dlls/t2embed/tests/t2embed.c
@@ -19,10 +19,59 @@
#include <stdarg.h>
#include "windef.h"
+#include "winbase.h"
#include "wingdi.h"
+#include "winuser.h"
#include "t2embapi.h"
#include "wine/test.h"
+static int CALLBACK enum_font_proc(ENUMLOGFONTEXA *enumlf, NEWTEXTMETRICEXA *ntm, DWORD type, LPARAM lParam)
+{
+ OUTLINETEXTMETRICA otm;
+ HDC hdc = GetDC(NULL);
+ HFONT hfont, old_font;
+ ULONG status;
+ LONG ret;
+
+ hfont = CreateFontIndirectA(&enumlf->elfLogFont);
+ old_font = SelectObject(hdc, hfont);
+
+ otm.otmSize = sizeof(otm);
+ if (GetOutlineTextMetricsA(hdc, otm.otmSize, &otm))
+ {
+ ULONG expected = 0xffff;
+ UINT fsType = otm.otmfsType & 0xf;
+
+ ret = TTGetEmbeddingType(hdc, &status);
+ ok(ret == E_NONE, "got %d\n", ret);
+
+ if (fsType == LICENSE_INSTALLABLE)
+ expected = EMBED_INSTALLABLE;
+ else if (fsType & LICENSE_EDITABLE)
+ expected = EMBED_EDITABLE;
+ else if (fsType & LICENSE_PREVIEWPRINT)
+ expected = EMBED_PREVIEWPRINT;
+ else if (fsType & LICENSE_NOEMBEDDING)
+ expected = EMBED_NOEMBEDDING;
+
+ ok(expected == status, "%s: status %d, expected %d, fsType %#x\n", enumlf->elfLogFont.lfFaceName, status,
+ expected, otm.otmfsType);
+ }
+ else
+ {
+ status = 0xdeadbeef;
+ ret = TTGetEmbeddingType(hdc, &status);
+ ok(ret == E_NOTATRUETYPEFONT, "%s: got %d\n", enumlf->elfLogFont.lfFaceName, ret);
+ ok(status == 0xdeadbeef, "%s: got status %d\n", enumlf->elfLogFont.lfFaceName, status);
+ }
+
+ SelectObject(hdc, old_font);
+ DeleteObject(hfont);
+ ReleaseDC(NULL, hdc);
+
+ return 1;
+}
+
static void test_TTGetEmbeddingType(void)
{
HFONT hfont, old_font;
@@ -73,6 +122,12 @@ static void test_TTGetEmbeddingType(void)
SelectObject(hdc, old_font);
DeleteObject(hfont);
+
+ /* repeat for all system fonts */
+ logfont.lfCharSet = DEFAULT_CHARSET;
+ logfont.lfFaceName[0] = 0;
+ EnumFontFamiliesExA(hdc, &logfont, (FONTENUMPROCA)enum_font_proc, 0, 0);
+
DeleteDC(hdc);
}
--
2.8.1
More information about the wine-patches
mailing list