d3d8/tests: Add test for clip planes limits.
[wine.git] / dlls / t2embed / main.c
blob766926fbfa52f2e3eaeea790231008e46a65d004
1 /*
3 * Copyright 2009 Austin English
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winreg.h"
29 #include "t2embapi.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(t2embed);
34 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
36 switch (fdwReason)
38 case DLL_WINE_PREATTACH:
39 return FALSE; /* prefer native version */
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(hinstDLL);
42 break;
45 return TRUE;
48 LONG WINAPI TTLoadEmbeddedFont(HANDLE *phFontReference, ULONG ulFlags,
49 ULONG *pulPrivStatus, ULONG ulPrivs,
50 ULONG *pulStatus, READEMBEDPROC lpfnReadFromStream,
51 LPVOID lpvReadStream, LPWSTR szWinFamilyName,
52 LPSTR szMacFamilyName, TTLOADINFO *pTTLoadInfo)
54 FIXME("(%p 0x%08x %p 0x%08x %p %p %p %s %s %p) stub\n", phFontReference,
55 ulFlags, pulPrivStatus, ulPrivs, pulStatus, lpfnReadFromStream,
56 lpvReadStream, debugstr_w(szWinFamilyName), szMacFamilyName,
57 pTTLoadInfo);
59 return E_API_NOTIMPL;
62 LONG WINAPI TTEmbedFont(HDC hDC, ULONG ulFlags, ULONG ulCharSet, ULONG *pulPrivStatus,
63 ULONG *pulStatus, WRITEEMBEDPROC lpfnWriteToStream, LPVOID lpvWriteStream,
64 USHORT *pusCharCodeSet, USHORT usCharCodeCount, USHORT usLanguage,
65 TTEMBEDINFO *pTTEmbedInfo)
67 FIXME("(%p 0x%08x 0x%08x %p %p %p %p %p %u %u %p) stub\n", hDC,
68 ulFlags, ulCharSet, pulPrivStatus, pulStatus, lpfnWriteToStream,
69 lpvWriteStream, pusCharCodeSet, usCharCodeCount, usLanguage,
70 pTTEmbedInfo);
72 return E_API_NOTIMPL;
75 LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status)
77 OUTLINETEXTMETRICW otm;
78 WORD fsType;
80 TRACE("(%p %p)\n", hDC, status);
82 if (!hDC)
83 return E_HDCINVALID;
85 otm.otmSize = sizeof(otm);
86 if (!GetOutlineTextMetricsW(hDC, otm.otmSize, &otm))
87 return E_NOTATRUETYPEFONT;
89 if (!status)
90 return E_PERMISSIONSINVALID;
92 otm.otmfsType = (fsType = otm.otmfsType) & 0xf;
93 if (otm.otmfsType == LICENSE_INSTALLABLE)
94 *status = EMBED_INSTALLABLE;
95 else if (otm.otmfsType & LICENSE_EDITABLE)
96 *status = EMBED_EDITABLE;
97 else if (otm.otmfsType & LICENSE_PREVIEWPRINT)
98 *status = EMBED_PREVIEWPRINT;
99 else if (otm.otmfsType & LICENSE_NOEMBEDDING)
100 *status = EMBED_NOEMBEDDING;
101 else
103 WARN("unrecognized flags, %#x\n", otm.otmfsType);
104 *status = EMBED_INSTALLABLE;
107 TRACE("fsType 0x%04x, status %u\n", fsType, *status);
108 return E_NONE;
111 LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled)
113 static const WCHAR exclusionlistW[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
114 'S','h','a','r','e','d',' ','T','o','o','l','s','\\','t','2','e','m','b','e','d',0};
115 DWORD index;
116 HKEY hkey;
117 LONG ret;
119 TRACE("(%s %p)\n", debugstr_a(facename), enabled);
121 if (!facename)
122 return E_FACENAMEINVALID;
124 if (!enabled)
125 return E_PBENABLEDINVALID;
127 *enabled = TRUE;
128 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, exclusionlistW, 0, GENERIC_READ, &hkey))
129 goto out;
131 *enabled = TRUE;
132 ret = ERROR_SUCCESS;
133 index = 0;
134 while (ret != ERROR_NO_MORE_ITEMS)
136 DWORD name_len, value_len, value, type;
137 CHAR name[LF_FACESIZE];
139 name_len = sizeof(name)/sizeof(*name);
140 value_len = sizeof(value);
141 ret = RegEnumValueA(hkey, index++, name, &name_len, NULL, &type, (BYTE*)&value, &value_len);
142 if (ret || type != REG_DWORD)
143 continue;
145 if (!lstrcmpiA(name, facename))
147 *enabled = !!value;
148 break;
151 RegCloseKey(hkey);
153 out:
154 TRACE("embedding %s for %s\n", *enabled ? "enabled" : "disabled", debugstr_a(facename));
155 return E_NONE;
158 LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled)
160 OUTLINETEXTMETRICA *otm;
161 LONG ret;
162 UINT len;
164 TRACE("(%p %p)\n", hDC, enabled);
166 if (!hDC)
167 return E_HDCINVALID;
169 len = GetOutlineTextMetricsA(hDC, 0, NULL);
170 if (!len)
171 return E_ERRORACCESSINGFACENAME;
173 otm = HeapAlloc(GetProcessHeap(), 0, len);
174 if (!otm)
175 return E_NOFREEMEMORY;
177 GetOutlineTextMetricsA(hDC, len, otm);
178 ret = TTIsEmbeddingEnabledForFacename((LPCSTR)otm + (ULONG_PTR)otm->otmpFaceName, enabled);
179 HeapFree(GetProcessHeap(), 0, otm);
180 return ret;
183 LONG WINAPI TTDeleteEmbeddedFont(HANDLE hFontReference, ULONG flags, ULONG *status)
185 FIXME("(%p 0x%08x %p) stub\n", hFontReference, flags, status);
186 return E_API_NOTIMPL;