mlang: Rename IMultiLanguage3 method implementation functions to match interface...
[wine] / dlls / dwrite / main.c
1 /*
2  *    DWrite
3  *
4  * Copyright 2012 Nikolay Sivov for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25
26 #include "initguid.h"
27 #include "dwrite.h"
28
29 #include "dwrite_private.h"
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
33
34 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
35 {
36     switch (reason)
37     {
38     case DLL_WINE_PREATTACH:
39         return FALSE;  /* prefer native version */
40     case DLL_PROCESS_ATTACH:
41         DisableThreadLibraryCalls( hinstDLL );
42         break;
43     }
44     return TRUE;
45 }
46
47 static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj)
48 {
49     TRACE("(%s %p)\n", debugstr_guid(riid), obj);
50
51     if (IsEqualIID(riid, &IID_IUnknown) ||
52         IsEqualIID(riid, &IID_IDWriteFactory))
53     {
54         *obj = iface;
55         return S_OK;
56     }
57
58     *obj = NULL;
59
60     return E_NOINTERFACE;
61 }
62
63 static ULONG WINAPI dwritefactory_AddRef(IDWriteFactory *iface)
64 {
65     return 2;
66 }
67
68 static ULONG WINAPI dwritefactory_Release(IDWriteFactory *iface)
69 {
70     return 1;
71 }
72
73 static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory *iface,
74     IDWriteFontCollection **collection, BOOL check_for_updates)
75 {
76     FIXME("(%p %d): stub\n", collection, check_for_updates);
77     return E_NOTIMPL;
78 }
79
80 static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory *iface,
81     IDWriteFontCollectionLoader *loader, void const *key, UINT32 key_size, IDWriteFontCollection **collection)
82 {
83     FIXME("(%p %p %u %p): stub\n", loader, key, key_size, collection);
84     return E_NOTIMPL;
85 }
86
87 static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory *iface,
88     IDWriteFontCollectionLoader *loader)
89 {
90     FIXME("(%p): stub\n", loader);
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory *iface,
95     IDWriteFontCollectionLoader *loader)
96 {
97     FIXME("(%p): stub\n", loader);
98     return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory *iface,
102     WCHAR const *path, FILETIME const *writetime, IDWriteFontFile **font_file)
103 {
104     FIXME("(%s %p %p): stub\n", debugstr_w(path), writetime, font_file);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory *iface,
109     void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file)
110 {
111     FIXME("(%p %u %p %p): stub\n", reference_key, key_size, loader, font_file);
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory *iface,
116     DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDWriteFontFile* const* font_files,
117     UINT32 index, DWRITE_FONT_SIMULATIONS sim_flags, IDWriteFontFace **font_face)
118 {
119     FIXME("(%d %u %p %u 0x%x %p): stub\n", facetype, files_number, font_files, index, sim_flags, font_face);
120     return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory *iface, IDWriteRenderingParams **params)
124 {
125     FIXME("(%p): stub\n", params);
126     return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI dwritefactory_CreateMonitorRenderingParams(IDWriteFactory *iface, HMONITOR monitor,
130     IDWriteRenderingParams **params)
131 {
132     FIXME("(%p %p): stub\n", monitor, params);
133     return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory *iface, FLOAT gamma, FLOAT enhancedContrast,
137     FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
138 {
139     FIXME("(%f %f %f %d %d %p): stub\n", gamma, enhancedContrast, cleartype_level, geometry, mode, params);
140     return E_NOTIMPL;
141 }
142
143 static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
144 {
145     FIXME("(%p): stub\n", loader);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
150 {
151     FIXME("(%p): stub\n", loader);
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory *iface, WCHAR const* family_name,
156     IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
157     DWRITE_FONT_STRETCH stretch, FLOAT size, WCHAR const *locale, IDWriteTextFormat **format)
158 {
159     FIXME("(%s %p %d %d %d %f %s %p): stub\n", debugstr_w(family_name), collection, weight, style, stretch,
160         size, debugstr_w(locale), format);
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory *iface, IDWriteTypography **typography)
165 {
166     FIXME("(%p): stub\n", typography);
167     return E_NOTIMPL;
168 }
169
170 static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory *iface, IDWriteGdiInterop **gdi_interop)
171 {
172     TRACE("(%p)\n", gdi_interop);
173     return create_gdiinterop(gdi_interop);
174 }
175
176 static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHAR const* string,
177     UINT32 len, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout)
178 {
179     FIXME("(%s %u %p %f %f %p): stub\n", debugstr_w(string), len, format, max_width, max_height, layout);
180
181     if (!format) return E_INVALIDARG;
182     return create_textlayout(layout);
183 }
184
185 static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
186     UINT32 len, IDWriteTextFormat *format, FLOAT layout_width, FLOAT layout_height, FLOAT pixels_per_dip,
187     DWRITE_MATRIX const* transform, BOOL use_gdi_natural, IDWriteTextLayout **layout)
188 {
189     FIXME("(%s:%u %p %f %f %f %p %d %p): semi-stub\n", debugstr_wn(string, len), len, format, layout_width, layout_height,
190         pixels_per_dip, transform, use_gdi_natural, layout);
191
192     if (!format) return E_INVALIDARG;
193     return create_textlayout(layout);
194 }
195
196 static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
197     IDWriteInlineObject **trimming_sign)
198 {
199     FIXME("(%p %p): stub\n", format, trimming_sign);
200     return E_NOTIMPL;
201 }
202
203 static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory *iface, IDWriteTextAnalyzer **analyzer)
204 {
205     FIXME("(%p): stub\n", analyzer);
206     return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory *iface, DWRITE_NUMBER_SUBSTITUTION_METHOD method,
210     WCHAR const* locale, BOOL ignore_user_override, IDWriteNumberSubstitution **substitution)
211 {
212     FIXME("(%d %s %d %p): stub\n", method, debugstr_w(locale), ignore_user_override, substitution);
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory *iface, DWRITE_GLYPH_RUN const *glyph_run,
217     FLOAT pixels_per_dip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
218     DWRITE_MEASURING_MODE measuring_mode, FLOAT baseline_x, FLOAT baseline_y, IDWriteGlyphRunAnalysis **analysis)
219 {
220     FIXME("(%p %f %p %d %d %f %f %p): stub\n", glyph_run, pixels_per_dip, transform, rendering_mode,
221         measuring_mode, baseline_x, baseline_y, analysis);
222     return E_NOTIMPL;
223 }
224
225 static const struct IDWriteFactoryVtbl dwritefactoryvtbl = {
226     dwritefactory_QueryInterface,
227     dwritefactory_AddRef,
228     dwritefactory_Release,
229     dwritefactory_GetSystemFontCollection,
230     dwritefactory_CreateCustomFontCollection,
231     dwritefactory_RegisterFontCollectionLoader,
232     dwritefactory_UnregisterFontCollectionLoader,
233     dwritefactory_CreateFontFileReference,
234     dwritefactory_CreateCustomFontFileReference,
235     dwritefactory_CreateFontFace,
236     dwritefactory_CreateRenderingParams,
237     dwritefactory_CreateMonitorRenderingParams,
238     dwritefactory_CreateCustomRenderingParams,
239     dwritefactory_RegisterFontFileLoader,
240     dwritefactory_UnregisterFontFileLoader,
241     dwritefactory_CreateTextFormat,
242     dwritefactory_CreateTypography,
243     dwritefactory_GetGdiInterop,
244     dwritefactory_CreateTextLayout,
245     dwritefactory_CreateGdiCompatibleTextLayout,
246     dwritefactory_CreateEllipsisTrimmingSign,
247     dwritefactory_CreateTextAnalyzer,
248     dwritefactory_CreateNumberSubstitution,
249     dwritefactory_CreateGlyphRunAnalysis
250 };
251
252 static IDWriteFactory dwritefactory = { &dwritefactoryvtbl };
253
254 HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **factory)
255 {
256     TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), factory);
257
258     if (!IsEqualIID(riid, &IID_IDWriteFactory)) return E_FAIL;
259
260     *factory = (IUnknown*)&dwritefactory;
261
262     return S_OK;
263 }