oleaut32: Use a saner calling convention for the marshaller asm thunks.
[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 #define COBJMACROS
22
23 #include <stdarg.h>
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28
29 #include "initguid.h"
30 #include "dwrite.h"
31
32 #include "dwrite_private.h"
33 #include "wine/debug.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
36
37 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
38 {
39     switch (reason)
40     {
41     case DLL_WINE_PREATTACH:
42         return FALSE;  /* prefer native version */
43     case DLL_PROCESS_ATTACH:
44         DisableThreadLibraryCalls( hinstDLL );
45         break;
46     case DLL_PROCESS_DETACH:
47         release_system_fontcollection();
48         break;
49     }
50     return TRUE;
51 }
52
53 struct renderingparams {
54     IDWriteRenderingParams IDWriteRenderingParams_iface;
55     LONG ref;
56
57     FLOAT gamma;
58     FLOAT enh_contrast;
59     FLOAT cleartype_level;
60     DWRITE_PIXEL_GEOMETRY geometry;
61     DWRITE_RENDERING_MODE mode;
62 };
63
64 static inline struct renderingparams *impl_from_IDWriteRenderingParams(IDWriteRenderingParams *iface)
65 {
66     return CONTAINING_RECORD(iface, struct renderingparams, IDWriteRenderingParams_iface);
67 }
68
69 static HRESULT WINAPI renderingparams_QueryInterface(IDWriteRenderingParams *iface, REFIID riid, void **obj)
70 {
71     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
72
73     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
74
75     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteRenderingParams))
76     {
77         *obj = iface;
78         IDWriteRenderingParams_AddRef(iface);
79         return S_OK;
80     }
81
82     *obj = NULL;
83
84     return E_NOINTERFACE;
85 }
86
87 static ULONG WINAPI renderingparams_AddRef(IDWriteRenderingParams *iface)
88 {
89     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
90     ULONG ref = InterlockedIncrement(&This->ref);
91     TRACE("(%p)->(%d)\n", This, ref);
92     return ref;
93 }
94
95 static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams *iface)
96 {
97     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
98     ULONG ref = InterlockedDecrement(&This->ref);
99
100     TRACE("(%p)->(%d)\n", This, ref);
101
102     if (!ref)
103         heap_free(This);
104
105     return ref;
106 }
107
108 static FLOAT WINAPI renderingparams_GetGamma(IDWriteRenderingParams *iface)
109 {
110     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
111     TRACE("(%p)\n", This);
112     return This->gamma;
113 }
114
115 static FLOAT WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams *iface)
116 {
117     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
118     TRACE("(%p)\n", This);
119     return This->enh_contrast;
120 }
121
122 static FLOAT WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams *iface)
123 {
124     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
125     TRACE("(%p)\n", This);
126     return This->cleartype_level;
127 }
128
129 static DWRITE_PIXEL_GEOMETRY WINAPI renderingparams_GetPixelGeometry(IDWriteRenderingParams *iface)
130 {
131     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
132     TRACE("(%p)\n", This);
133     return This->geometry;
134 }
135
136 static DWRITE_RENDERING_MODE WINAPI renderingparams_GetRenderingMode(IDWriteRenderingParams *iface)
137 {
138     struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
139     TRACE("(%p)\n", This);
140     return This->mode;
141 }
142
143 static const struct IDWriteRenderingParamsVtbl renderingparamsvtbl = {
144     renderingparams_QueryInterface,
145     renderingparams_AddRef,
146     renderingparams_Release,
147     renderingparams_GetGamma,
148     renderingparams_GetEnhancedContrast,
149     renderingparams_GetClearTypeLevel,
150     renderingparams_GetPixelGeometry,
151     renderingparams_GetRenderingMode
152 };
153
154 static HRESULT create_renderingparams(FLOAT gamma, FLOAT enhancedContrast, FLOAT cleartype_level,
155     DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
156 {
157     struct renderingparams *This;
158
159     *params = NULL;
160
161     This = heap_alloc(sizeof(struct renderingparams));
162     if (!This) return E_OUTOFMEMORY;
163
164     This->IDWriteRenderingParams_iface.lpVtbl = &renderingparamsvtbl;
165     This->ref = 1;
166
167     This->gamma = gamma;
168     This->enh_contrast = enhancedContrast;
169     This->cleartype_level = cleartype_level;
170     This->geometry = geometry;
171     This->mode = mode;
172
173     *params = &This->IDWriteRenderingParams_iface;
174
175     return S_OK;
176 }
177
178 struct localizedpair {
179     WCHAR *locale;
180     WCHAR *string;
181 };
182
183 struct localizedstrings {
184     IDWriteLocalizedStrings IDWriteLocalizedStrings_iface;
185     LONG ref;
186
187     struct localizedpair *data;
188     UINT32 count;
189     UINT32 alloc;
190 };
191
192 static inline struct localizedstrings *impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings *iface)
193 {
194     return CONTAINING_RECORD(iface, struct localizedstrings, IDWriteLocalizedStrings_iface);
195 }
196
197 static HRESULT WINAPI localizedstrings_QueryInterface(IDWriteLocalizedStrings *iface, REFIID riid, void **obj)
198 {
199     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
200
201     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
202
203     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteLocalizedStrings))
204     {
205         *obj = iface;
206         IDWriteLocalizedStrings_AddRef(iface);
207         return S_OK;
208     }
209
210     *obj = NULL;
211
212     return E_NOINTERFACE;
213 }
214
215 static ULONG WINAPI localizedstrings_AddRef(IDWriteLocalizedStrings *iface)
216 {
217     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
218     ULONG ref = InterlockedIncrement(&This->ref);
219     TRACE("(%p)->(%d)\n", This, ref);
220     return ref;
221 }
222
223 static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
224 {
225     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
226     ULONG ref = InterlockedDecrement(&This->ref);
227
228     TRACE("(%p)->(%d)\n", This, ref);
229
230     if (!ref) {
231         int i;
232
233         for (i = 0; i < This->count; i++) {
234             heap_free(This->data[i].locale);
235             heap_free(This->data[i].string);
236         }
237
238         heap_free(This->data);
239         heap_free(This);
240     }
241
242     return ref;
243 }
244
245 static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
246 {
247     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
248     TRACE("(%p)\n", This);
249     return This->count;
250 }
251
252 static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
253     WCHAR const *locale_name, UINT32 *index, BOOL *exists)
254 {
255     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
256     FIXME("(%p)->(%s %p %p): stub\n", This, debugstr_w(locale_name), index, exists);
257     return E_NOTIMPL;
258 }
259
260 static HRESULT WINAPI localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
261 {
262     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
263     FIXME("(%p)->(%u %p): stub\n", This, index, length);
264     return E_NOTIMPL;
265 }
266
267 static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *locale_name, UINT32 size)
268 {
269     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
270     FIXME("(%p)->(%u %p %u): stub\n", This, index, locale_name, size);
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
275 {
276     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
277
278     TRACE("(%p)->(%u %p)\n", This, index, length);
279
280     if (index >= This->count) {
281         *length = (UINT32)-1;
282         return E_FAIL;
283     }
284
285     *length = strlenW(This->data[index].string);
286     return S_OK;
287 }
288
289 static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
290 {
291     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
292
293     TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size);
294
295     if (index >= This->count) {
296         if (buffer) *buffer = 0;
297         return E_FAIL;
298     }
299
300     if (size < strlenW(This->data[index].string)+1) {
301         if (buffer) *buffer = 0;
302         return E_NOT_SUFFICIENT_BUFFER;
303     }
304
305     strcpyW(buffer, This->data[index].string);
306     return S_OK;
307 }
308
309 static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = {
310     localizedstrings_QueryInterface,
311     localizedstrings_AddRef,
312     localizedstrings_Release,
313     localizedstrings_GetCount,
314     localizedstrings_FindLocaleName,
315     localizedstrings_GetLocaleNameLength,
316     localizedstrings_GetLocaleName,
317     localizedstrings_GetStringLength,
318     localizedstrings_GetString
319 };
320
321 HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings)
322 {
323     struct localizedstrings *This;
324
325     *strings = NULL;
326
327     This = heap_alloc(sizeof(struct localizedstrings));
328     if (!This) return E_OUTOFMEMORY;
329
330     This->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
331     This->ref = 1;
332     This->count = 0;
333     This->data = heap_alloc_zero(sizeof(struct localizedpair));
334     if (!This->data) {
335         heap_free(This);
336         return E_OUTOFMEMORY;
337     }
338     This->alloc = 1;
339
340     *strings = &This->IDWriteLocalizedStrings_iface;
341
342     return S_OK;
343 }
344
345 HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale, const WCHAR *string)
346 {
347     struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
348
349     if (This->count == This->alloc) {
350         This->alloc *= 2;
351         This->data = heap_realloc(This->data, This->alloc*sizeof(struct localizedpair));
352     }
353
354     This->data[This->count].locale = heap_strdupW(locale);
355     This->data[This->count].string = heap_strdupW(string);
356     This->count++;
357
358     return S_OK;
359 }
360
361 static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj)
362 {
363     TRACE("(%s %p)\n", debugstr_guid(riid), obj);
364
365     if (IsEqualIID(riid, &IID_IUnknown) ||
366         IsEqualIID(riid, &IID_IDWriteFactory))
367     {
368         *obj = iface;
369         return S_OK;
370     }
371
372     *obj = NULL;
373
374     return E_NOINTERFACE;
375 }
376
377 static ULONG WINAPI dwritefactory_AddRef(IDWriteFactory *iface)
378 {
379     return 2;
380 }
381
382 static ULONG WINAPI dwritefactory_Release(IDWriteFactory *iface)
383 {
384     return 1;
385 }
386
387 static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory *iface,
388     IDWriteFontCollection **collection, BOOL check_for_updates)
389 {
390     TRACE("(%p %d)\n", collection, check_for_updates);
391
392     if (check_for_updates)
393         FIXME("checking for system font updates not implemented\n");
394
395     return get_system_fontcollection(collection);
396 }
397
398 static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory *iface,
399     IDWriteFontCollectionLoader *loader, void const *key, UINT32 key_size, IDWriteFontCollection **collection)
400 {
401     FIXME("(%p %p %u %p): stub\n", loader, key, key_size, collection);
402     return E_NOTIMPL;
403 }
404
405 static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory *iface,
406     IDWriteFontCollectionLoader *loader)
407 {
408     FIXME("(%p): stub\n", loader);
409     return E_NOTIMPL;
410 }
411
412 static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory *iface,
413     IDWriteFontCollectionLoader *loader)
414 {
415     FIXME("(%p): stub\n", loader);
416     return E_NOTIMPL;
417 }
418
419 static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory *iface,
420     WCHAR const *path, FILETIME const *writetime, IDWriteFontFile **font_file)
421 {
422     FIXME("(%s %p %p): stub\n", debugstr_w(path), writetime, font_file);
423     return E_NOTIMPL;
424 }
425
426 static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory *iface,
427     void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file)
428 {
429     FIXME("(%p %u %p %p): stub\n", reference_key, key_size, loader, font_file);
430     return E_NOTIMPL;
431 }
432
433 static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory *iface,
434     DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDWriteFontFile* const* font_files,
435     UINT32 index, DWRITE_FONT_SIMULATIONS sim_flags, IDWriteFontFace **font_face)
436 {
437     FIXME("(%d %u %p %u 0x%x %p): stub\n", facetype, files_number, font_files, index, sim_flags, font_face);
438     return E_NOTIMPL;
439 }
440
441 static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory *iface, IDWriteRenderingParams **params)
442 {
443     HMONITOR monitor;
444     POINT pt;
445
446     TRACE("(%p)\n", params);
447
448     pt.x = pt.y = 0;
449     monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
450     return IDWriteFactory_CreateMonitorRenderingParams(iface, monitor, params);
451 }
452
453 static HRESULT WINAPI dwritefactory_CreateMonitorRenderingParams(IDWriteFactory *iface, HMONITOR monitor,
454     IDWriteRenderingParams **params)
455 {
456     static int fixme_once = 0;
457
458     TRACE("(%p %p)\n", monitor, params);
459
460     if (!fixme_once++)
461         FIXME("(%p): monitor setting ignored\n", monitor);
462     return IDWriteFactory_CreateCustomRenderingParams(iface, 0.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
463         DWRITE_RENDERING_MODE_DEFAULT, params);
464 }
465
466 static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory *iface, FLOAT gamma, FLOAT enhancedContrast,
467     FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
468 {
469     TRACE("(%f %f %f %d %d %p)\n", gamma, enhancedContrast, cleartype_level, geometry, mode, params);
470     return create_renderingparams(gamma, enhancedContrast, cleartype_level, geometry, mode, params);
471 }
472
473 static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
474 {
475     FIXME("(%p): stub\n", loader);
476     return E_NOTIMPL;
477 }
478
479 static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
480 {
481     FIXME("(%p): stub\n", loader);
482     return E_NOTIMPL;
483 }
484
485 static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory *iface, WCHAR const* family_name,
486     IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
487     DWRITE_FONT_STRETCH stretch, FLOAT size, WCHAR const *locale, IDWriteTextFormat **format)
488 {
489     TRACE("(%s %p %d %d %d %f %s %p)\n", debugstr_w(family_name), collection, weight, style, stretch,
490         size, debugstr_w(locale), format);
491     return create_textformat(family_name, collection, weight, style, stretch, size, locale, format);
492 }
493
494 static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory *iface, IDWriteTypography **typography)
495 {
496     FIXME("(%p): stub\n", typography);
497     return E_NOTIMPL;
498 }
499
500 static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory *iface, IDWriteGdiInterop **gdi_interop)
501 {
502     TRACE("(%p)\n", gdi_interop);
503     return get_gdiinterop(gdi_interop);
504 }
505
506 static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHAR const* string,
507     UINT32 len, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout)
508 {
509     TRACE("(%s %u %p %f %f %p)\n", debugstr_w(string), len, format, max_width, max_height, layout);
510
511     if (!format) return E_INVALIDARG;
512     return create_textlayout(string, len, format, layout);
513 }
514
515 static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
516     UINT32 len, IDWriteTextFormat *format, FLOAT layout_width, FLOAT layout_height, FLOAT pixels_per_dip,
517     DWRITE_MATRIX const* transform, BOOL use_gdi_natural, IDWriteTextLayout **layout)
518 {
519     FIXME("(%s:%u %p %f %f %f %p %d %p): semi-stub\n", debugstr_wn(string, len), len, format, layout_width, layout_height,
520         pixels_per_dip, transform, use_gdi_natural, layout);
521
522     if (!format) return E_INVALIDARG;
523     return create_textlayout(string, len, format, layout);
524 }
525
526 static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
527     IDWriteInlineObject **trimming_sign)
528 {
529     FIXME("(%p %p): stub\n", format, trimming_sign);
530     return E_NOTIMPL;
531 }
532
533 static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory *iface, IDWriteTextAnalyzer **analyzer)
534 {
535     TRACE("(%p)\n", analyzer);
536     return get_textanalyzer(analyzer);
537 }
538
539 static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory *iface, DWRITE_NUMBER_SUBSTITUTION_METHOD method,
540     WCHAR const* locale, BOOL ignore_user_override, IDWriteNumberSubstitution **substitution)
541 {
542     FIXME("(%d %s %d %p): stub\n", method, debugstr_w(locale), ignore_user_override, substitution);
543     return E_NOTIMPL;
544 }
545
546 static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory *iface, DWRITE_GLYPH_RUN const *glyph_run,
547     FLOAT pixels_per_dip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
548     DWRITE_MEASURING_MODE measuring_mode, FLOAT baseline_x, FLOAT baseline_y, IDWriteGlyphRunAnalysis **analysis)
549 {
550     FIXME("(%p %f %p %d %d %f %f %p): stub\n", glyph_run, pixels_per_dip, transform, rendering_mode,
551         measuring_mode, baseline_x, baseline_y, analysis);
552     return E_NOTIMPL;
553 }
554
555 static const struct IDWriteFactoryVtbl dwritefactoryvtbl = {
556     dwritefactory_QueryInterface,
557     dwritefactory_AddRef,
558     dwritefactory_Release,
559     dwritefactory_GetSystemFontCollection,
560     dwritefactory_CreateCustomFontCollection,
561     dwritefactory_RegisterFontCollectionLoader,
562     dwritefactory_UnregisterFontCollectionLoader,
563     dwritefactory_CreateFontFileReference,
564     dwritefactory_CreateCustomFontFileReference,
565     dwritefactory_CreateFontFace,
566     dwritefactory_CreateRenderingParams,
567     dwritefactory_CreateMonitorRenderingParams,
568     dwritefactory_CreateCustomRenderingParams,
569     dwritefactory_RegisterFontFileLoader,
570     dwritefactory_UnregisterFontFileLoader,
571     dwritefactory_CreateTextFormat,
572     dwritefactory_CreateTypography,
573     dwritefactory_GetGdiInterop,
574     dwritefactory_CreateTextLayout,
575     dwritefactory_CreateGdiCompatibleTextLayout,
576     dwritefactory_CreateEllipsisTrimmingSign,
577     dwritefactory_CreateTextAnalyzer,
578     dwritefactory_CreateNumberSubstitution,
579     dwritefactory_CreateGlyphRunAnalysis
580 };
581
582 static IDWriteFactory dwritefactory = { &dwritefactoryvtbl };
583
584 HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **factory)
585 {
586     TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), factory);
587
588     if (!IsEqualIID(riid, &IID_IDWriteFactory)) return E_FAIL;
589
590     *factory = (IUnknown*)&dwritefactory;
591
592     return S_OK;
593 }