include: Add transact.idl to oledb.idl.
[wine.git] / dlls / t2embed / main.c
blobf79d4d69eb5de26ba584f8f1a9f341e43d5aaac3
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
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "wingdi.h"
25 #include "winreg.h"
26 #include "t2embapi.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(t2embed);
31 LONG WINAPI TTLoadEmbeddedFont(HANDLE *phFontReference, ULONG ulFlags,
32 ULONG *pulPrivStatus, ULONG ulPrivs,
33 ULONG *pulStatus, READEMBEDPROC lpfnReadFromStream,
34 LPVOID lpvReadStream, LPWSTR szWinFamilyName,
35 LPSTR szMacFamilyName, TTLOADINFO *pTTLoadInfo)
37 FIXME("(%p 0x%08x %p 0x%08x %p %p %p %s %s %p) stub\n", phFontReference,
38 ulFlags, pulPrivStatus, ulPrivs, pulStatus, lpfnReadFromStream,
39 lpvReadStream, debugstr_w(szWinFamilyName), szMacFamilyName,
40 pTTLoadInfo);
42 return E_API_NOTIMPL;
45 LONG WINAPI TTEmbedFont(HDC hDC, ULONG ulFlags, ULONG ulCharSet, ULONG *pulPrivStatus,
46 ULONG *pulStatus, WRITEEMBEDPROC lpfnWriteToStream, LPVOID lpvWriteStream,
47 USHORT *pusCharCodeSet, USHORT usCharCodeCount, USHORT usLanguage,
48 TTEMBEDINFO *pTTEmbedInfo)
50 FIXME("(%p 0x%08x 0x%08x %p %p %p %p %p %u %u %p) stub\n", hDC,
51 ulFlags, ulCharSet, pulPrivStatus, pulStatus, lpfnWriteToStream,
52 lpvWriteStream, pusCharCodeSet, usCharCodeCount, usLanguage,
53 pTTEmbedInfo);
55 return E_API_NOTIMPL;
58 LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status)
60 OUTLINETEXTMETRICW otm;
61 WORD fsType;
63 TRACE("(%p %p)\n", hDC, status);
65 if (!hDC)
66 return E_HDCINVALID;
68 otm.otmSize = sizeof(otm);
69 if (!GetOutlineTextMetricsW(hDC, otm.otmSize, &otm))
70 return E_NOTATRUETYPEFONT;
72 if (!status)
73 return E_PERMISSIONSINVALID;
75 otm.otmfsType = (fsType = otm.otmfsType) & 0xf;
76 if (otm.otmfsType == LICENSE_INSTALLABLE)
77 *status = EMBED_INSTALLABLE;
78 else if (otm.otmfsType & LICENSE_EDITABLE)
79 *status = EMBED_EDITABLE;
80 else if (otm.otmfsType & LICENSE_PREVIEWPRINT)
81 *status = EMBED_PREVIEWPRINT;
82 else if (otm.otmfsType & LICENSE_NOEMBEDDING)
83 *status = EMBED_NOEMBEDDING;
84 else
86 WARN("unrecognized flags, %#x\n", otm.otmfsType);
87 *status = EMBED_INSTALLABLE;
90 TRACE("fsType 0x%04x, status %u\n", fsType, *status);
91 return E_NONE;
94 LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled)
96 DWORD index;
97 HKEY hkey;
98 LONG ret;
100 TRACE("(%s %p)\n", debugstr_a(facename), enabled);
102 if (!facename)
103 return E_FACENAMEINVALID;
105 if (!enabled)
106 return E_PBENABLEDINVALID;
108 *enabled = TRUE;
109 if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Shared Tools\\t2embed", 0, GENERIC_READ, &hkey))
110 goto out;
112 *enabled = TRUE;
113 ret = ERROR_SUCCESS;
114 index = 0;
115 while (ret != ERROR_NO_MORE_ITEMS)
117 DWORD name_len, value_len, value, type;
118 CHAR name[LF_FACESIZE];
120 name_len = ARRAY_SIZE(name);
121 value_len = sizeof(value);
122 ret = RegEnumValueA(hkey, index++, name, &name_len, NULL, &type, (BYTE*)&value, &value_len);
123 if (ret || type != REG_DWORD)
124 continue;
126 if (!lstrcmpiA(name, facename))
128 *enabled = !!value;
129 break;
132 RegCloseKey(hkey);
134 out:
135 TRACE("embedding %s for %s\n", *enabled ? "enabled" : "disabled", debugstr_a(facename));
136 return E_NONE;
139 LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled)
141 OUTLINETEXTMETRICA *otm;
142 LONG ret;
143 UINT len;
145 TRACE("(%p %p)\n", hDC, enabled);
147 if (!hDC)
148 return E_HDCINVALID;
150 len = GetOutlineTextMetricsA(hDC, 0, NULL);
151 if (!len)
152 return E_ERRORACCESSINGFACENAME;
154 otm = HeapAlloc(GetProcessHeap(), 0, len);
155 if (!otm)
156 return E_NOFREEMEMORY;
158 GetOutlineTextMetricsA(hDC, len, otm);
159 ret = TTIsEmbeddingEnabledForFacename((LPCSTR)otm + (ULONG_PTR)otm->otmpFaceName, enabled);
160 HeapFree(GetProcessHeap(), 0, otm);
161 return ret;
164 LONG WINAPI TTDeleteEmbeddedFont(HANDLE hFontReference, ULONG flags, ULONG *status)
166 FIXME("(%p 0x%08x %p) stub\n", hFontReference, flags, status);
167 return E_API_NOTIMPL;