ReactOS  0.4.13-dev-544-gede3fdd
main.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2009 Austin English
4  *
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.
9  *
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.
14  *
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
18  */
19 
20 
21 #include "config.h"
22 
23 #include <stdarg.h>
24 
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"
31 
33 
35 {
36  switch (fdwReason)
37  {
38  case DLL_WINE_PREATTACH:
39  return FALSE; /* prefer native version */
40  case DLL_PROCESS_ATTACH:
41  DisableThreadLibraryCalls(hinstDLL);
42  break;
43  }
44 
45  return TRUE;
46 }
47 
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)
53 {
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);
58 
59  return E_API_NOTIMPL;
60 }
61 
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)
66 {
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);
71 
72  return E_API_NOTIMPL;
73 }
74 
76 {
78  WORD fsType;
79 
80  TRACE("(%p %p)\n", hDC, status);
81 
82  if (!hDC)
83  return E_HDCINVALID;
84 
85  otm.otmSize = sizeof(otm);
86  if (!GetOutlineTextMetricsW(hDC, otm.otmSize, &otm))
87  return E_NOTATRUETYPEFONT;
88 
89  if (!status)
90  return E_PERMISSIONSINVALID;
91 
92  otm.otmfsType = (fsType = otm.otmfsType) & 0xf;
93  if (otm.otmfsType == LICENSE_INSTALLABLE)
95  else if (otm.otmfsType & LICENSE_EDITABLE)
97  else if (otm.otmfsType & LICENSE_PREVIEWPRINT)
99  else if (otm.otmfsType & LICENSE_NOEMBEDDING)
101  else
102  {
103  WARN("unrecognized flags, %#x\n", otm.otmfsType);
105  }
106 
107  TRACE("fsType 0x%04x, status %u\n", fsType, *status);
108  return E_NONE;
109 }
110 
112 {
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;
118 
119  TRACE("(%s %p)\n", debugstr_a(facename), enabled);
120 
121  if (!facename)
122  return E_FACENAMEINVALID;
123 
124  if (!enabled)
125  return E_PBENABLEDINVALID;
126 
127  *enabled = TRUE;
128  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, exclusionlistW, 0, GENERIC_READ, &hkey))
129  goto out;
130 
131  *enabled = TRUE;
132  ret = ERROR_SUCCESS;
133  index = 0;
134  while (ret != ERROR_NO_MORE_ITEMS)
135  {
136  DWORD name_len, value_len, value, type;
138 
139  name_len = ARRAY_SIZE(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;
144 
145  if (!lstrcmpiA(name, facename))
146  {
147  *enabled = !!value;
148  break;
149  }
150  }
151  RegCloseKey(hkey);
152 
153 out:
154  TRACE("embedding %s for %s\n", *enabled ? "enabled" : "disabled", debugstr_a(facename));
155  return E_NONE;
156 }
157 
159 {
160  OUTLINETEXTMETRICA *otm;
161  LONG ret;
162  UINT len;
163 
164  TRACE("(%p %p)\n", hDC, enabled);
165 
166  if (!hDC)
167  return E_HDCINVALID;
168 
170  if (!len)
172 
173  otm = HeapAlloc(GetProcessHeap(), 0, len);
174  if (!otm)
175  return E_NOFREEMEMORY;
176 
179  HeapFree(GetProcessHeap(), 0, otm);
180  return ret;
181 }
182 
184 {
185  FIXME("(%p 0x%08x %p) stub\n", hFontReference, flags, status);
186  return E_API_NOTIMPL;
187 }
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
#define ERROR_SUCCESS
Definition: deptool.c:10
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
WINE_DEFAULT_DEBUG_CHANNEL(wmic)
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:111
LONG WINAPI TTGetEmbeddingType(HDC hDC, ULONG *status)
Definition: main.c:75
static HDC
Definition: imagelist.c:92
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
char * LPSTR
Definition: xmlstorage.h:182
#define E_NOTATRUETYPEFONT
Definition: t2embapi.h:50
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
static IN DWORD IN LPVOID lpvReserved
LONG WINAPI TTLoadEmbeddedFont(HANDLE *phFontReference, ULONG ulFlags, ULONG *pulPrivStatus, ULONG ulPrivs, ULONG *pulStatus, READEMBEDPROC lpfnReadFromStream, LPVOID lpvReadStream, LPWSTR szWinFamilyName, LPSTR szMacFamilyName, TTLOADINFO *pTTLoadInfo)
Definition: main.c:48
uint32_t ULONG_PTR
Definition: typedefs.h:63
unsigned long(WINAPIV * WRITEEMBEDPROC)(void *lpvWriteStream, const void *lpvBuffer, const unsigned long cbBuffer)
Definition: t2embapi.h:114
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define EMBED_INSTALLABLE
Definition: t2embapi.h:14
#define E_FACENAMEINVALID
Definition: t2embapi.h:83
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define EMBED_PREVIEWPRINT
Definition: t2embapi.h:12
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define E_HDCINVALID
Definition: t2embapi.h:47
const char * LPCSTR
Definition: xmlstorage.h:183
#define E_API_NOTIMPL
Definition: t2embapi.h:41
LONG WINAPI TTDeleteEmbeddedFont(HANDLE hFontReference, ULONG flags, ULONG *status)
Definition: main.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2691
#define E_ERRORACCESSINGFACENAME
Definition: t2embapi.h:52
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
#define E_NOFREEMEMORY
Definition: t2embapi.h:48
#define WINAPI
Definition: msvc.h:8
unsigned short WORD
Definition: ntddk_ex.h:93
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
#define LICENSE_PREVIEWPRINT
Definition: t2embapi.h:22
#define E_NONE
Definition: t2embapi.h:38
int ret
UINT WINAPI GetOutlineTextMetricsA(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICA potm)
LONG WINAPI TTIsEmbeddingEnabledForFacename(LPCSTR facename, BOOL *enabled)
Definition: main.c:111
#define index(s, c)
Definition: various.h:29
LONG WINAPI TTEmbedFont(HDC hDC, ULONG ulFlags, ULONG ulCharSet, ULONG *pulPrivStatus, ULONG *pulStatus, WRITEEMBEDPROC lpfnWriteToStream, LPVOID lpvWriteStream, USHORT *pusCharCodeSet, USHORT usCharCodeCount, USHORT usLanguage, TTEMBEDINFO *pTTEmbedInfo)
Definition: main.c:62
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
GLsizei const GLfloat * value
Definition: glext.h:6069
static HDC hDC
Definition: 3dtext.c:33
int type
Definition: main.c:85
#define LICENSE_EDITABLE
Definition: t2embapi.h:23
unsigned short USHORT
Definition: pedump.c:61
#define ARRAY_SIZE(a)
Definition: main.h:24
#define EMBED_NOEMBEDDING
Definition: t2embapi.h:15
unsigned int UINT
Definition: ndis.h:50
LONG WINAPI TTIsEmbeddingEnabled(HDC hDC, BOOL *enabled)
Definition: main.c:158
Definition: name.c:36
#define E_PBENABLEDINVALID
Definition: t2embapi.h:88
#define LICENSE_NOEMBEDDING
Definition: t2embapi.h:21
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
UINT WINAPI GetOutlineTextMetricsW(_In_ HDC hdc, _In_ UINT cjCopy, _Out_writes_bytes_opt_(cjCopy) LPOUTLINETEXTMETRICW potm)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define E_PERMISSIONSINVALID
Definition: t2embapi.h:87
#define REG_DWORD
Definition: sdbapi.c:596
#define LICENSE_INSTALLABLE
Definition: t2embapi.h:19
#define EMBED_EDITABLE
Definition: t2embapi.h:13
#define HeapFree(x, y, z)
Definition: compat.h:394
unsigned long(WINAPIV * READEMBEDPROC)(void *lpvReadStream, void *lpvBuffer, const unsigned long cbBuffer)
Definition: t2embapi.h:121
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: main.c:26
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
Definition: ps.c:97