4 * Copyright 2012 Nikolay Sivov for CodeWeavers
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.
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.
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
31 #include "dwrite_private.h"
32 #include "wine/debug.h"
33 #include "wine/list.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
37 static IDWriteFactory3
*shared_factory
;
38 static void release_shared_factory(IDWriteFactory3
*);
40 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD reason
, LPVOID reserved
)
44 case DLL_PROCESS_ATTACH
:
45 DisableThreadLibraryCalls( hinstDLL
);
48 case DLL_PROCESS_DETACH
:
50 release_shared_factory(shared_factory
);
56 struct renderingparams
{
57 IDWriteRenderingParams3 IDWriteRenderingParams3_iface
;
62 FLOAT grayscalecontrast
;
63 FLOAT cleartype_level
;
64 DWRITE_PIXEL_GEOMETRY geometry
;
65 DWRITE_RENDERING_MODE1 mode
;
66 DWRITE_GRID_FIT_MODE gridfit
;
69 static inline struct renderingparams
*impl_from_IDWriteRenderingParams3(IDWriteRenderingParams3
*iface
)
71 return CONTAINING_RECORD(iface
, struct renderingparams
, IDWriteRenderingParams3_iface
);
74 static HRESULT WINAPI
renderingparams_QueryInterface(IDWriteRenderingParams3
*iface
, REFIID riid
, void **obj
)
76 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
78 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
80 if (IsEqualIID(riid
, &IID_IDWriteRenderingParams3
) ||
81 IsEqualIID(riid
, &IID_IDWriteRenderingParams2
) ||
82 IsEqualIID(riid
, &IID_IDWriteRenderingParams1
) ||
83 IsEqualIID(riid
, &IID_IDWriteRenderingParams
) ||
84 IsEqualIID(riid
, &IID_IUnknown
))
87 IDWriteRenderingParams3_AddRef(iface
);
96 static ULONG WINAPI
renderingparams_AddRef(IDWriteRenderingParams3
*iface
)
98 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
99 ULONG ref
= InterlockedIncrement(&This
->ref
);
100 TRACE("(%p)->(%d)\n", This
, ref
);
104 static ULONG WINAPI
renderingparams_Release(IDWriteRenderingParams3
*iface
)
106 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
107 ULONG ref
= InterlockedDecrement(&This
->ref
);
109 TRACE("(%p)->(%d)\n", This
, ref
);
117 static FLOAT WINAPI
renderingparams_GetGamma(IDWriteRenderingParams3
*iface
)
119 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
120 TRACE("(%p)\n", This
);
124 static FLOAT WINAPI
renderingparams_GetEnhancedContrast(IDWriteRenderingParams3
*iface
)
126 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
127 TRACE("(%p)\n", This
);
128 return This
->contrast
;
131 static FLOAT WINAPI
renderingparams_GetClearTypeLevel(IDWriteRenderingParams3
*iface
)
133 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
134 TRACE("(%p)\n", This
);
135 return This
->cleartype_level
;
138 static DWRITE_PIXEL_GEOMETRY WINAPI
renderingparams_GetPixelGeometry(IDWriteRenderingParams3
*iface
)
140 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
141 TRACE("(%p)\n", This
);
142 return This
->geometry
;
145 static DWRITE_RENDERING_MODE WINAPI
renderingparams_GetRenderingMode(IDWriteRenderingParams3
*iface
)
147 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
149 TRACE("(%p)\n", This
);
151 if (This
->mode
== DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED
)
152 return DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
;
157 static FLOAT WINAPI
renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3
*iface
)
159 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
160 TRACE("(%p)\n", This
);
161 return This
->grayscalecontrast
;
164 static DWRITE_GRID_FIT_MODE WINAPI
renderingparams2_GetGridFitMode(IDWriteRenderingParams3
*iface
)
166 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
167 TRACE("(%p)\n", This
);
168 return This
->gridfit
;
171 static DWRITE_RENDERING_MODE1 WINAPI
renderingparams3_GetRenderingMode1(IDWriteRenderingParams3
*iface
)
173 struct renderingparams
*This
= impl_from_IDWriteRenderingParams3(iface
);
174 TRACE("(%p)\n", This
);
178 static const struct IDWriteRenderingParams3Vtbl renderingparamsvtbl
= {
179 renderingparams_QueryInterface
,
180 renderingparams_AddRef
,
181 renderingparams_Release
,
182 renderingparams_GetGamma
,
183 renderingparams_GetEnhancedContrast
,
184 renderingparams_GetClearTypeLevel
,
185 renderingparams_GetPixelGeometry
,
186 renderingparams_GetRenderingMode
,
187 renderingparams1_GetGrayscaleEnhancedContrast
,
188 renderingparams2_GetGridFitMode
,
189 renderingparams3_GetRenderingMode1
192 static HRESULT
create_renderingparams(FLOAT gamma
, FLOAT contrast
, FLOAT grayscalecontrast
, FLOAT cleartype_level
,
193 DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
, DWRITE_GRID_FIT_MODE gridfit
, IDWriteRenderingParams3
**params
)
195 struct renderingparams
*This
;
199 This
= heap_alloc(sizeof(struct renderingparams
));
200 if (!This
) return E_OUTOFMEMORY
;
202 This
->IDWriteRenderingParams3_iface
.lpVtbl
= &renderingparamsvtbl
;
206 This
->contrast
= contrast
;
207 This
->grayscalecontrast
= grayscalecontrast
;
208 This
->cleartype_level
= cleartype_level
;
209 This
->geometry
= geometry
;
211 This
->gridfit
= gridfit
;
213 *params
= &This
->IDWriteRenderingParams3_iface
;
218 struct localizedpair
{
223 struct localizedstrings
{
224 IDWriteLocalizedStrings IDWriteLocalizedStrings_iface
;
227 struct localizedpair
*data
;
232 static inline struct localizedstrings
*impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings
*iface
)
234 return CONTAINING_RECORD(iface
, struct localizedstrings
, IDWriteLocalizedStrings_iface
);
237 static HRESULT WINAPI
localizedstrings_QueryInterface(IDWriteLocalizedStrings
*iface
, REFIID riid
, void **obj
)
239 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
241 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
243 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteLocalizedStrings
))
246 IDWriteLocalizedStrings_AddRef(iface
);
252 return E_NOINTERFACE
;
255 static ULONG WINAPI
localizedstrings_AddRef(IDWriteLocalizedStrings
*iface
)
257 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
258 ULONG ref
= InterlockedIncrement(&This
->ref
);
259 TRACE("(%p)->(%d)\n", This
, ref
);
263 static ULONG WINAPI
localizedstrings_Release(IDWriteLocalizedStrings
*iface
)
265 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
266 ULONG ref
= InterlockedDecrement(&This
->ref
);
268 TRACE("(%p)->(%d)\n", This
, ref
);
273 for (i
= 0; i
< This
->count
; i
++) {
274 heap_free(This
->data
[i
].locale
);
275 heap_free(This
->data
[i
].string
);
278 heap_free(This
->data
);
285 static UINT32 WINAPI
localizedstrings_GetCount(IDWriteLocalizedStrings
*iface
)
287 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
288 TRACE("(%p)\n", This
);
292 static HRESULT WINAPI
localizedstrings_FindLocaleName(IDWriteLocalizedStrings
*iface
,
293 WCHAR
const *locale_name
, UINT32
*index
, BOOL
*exists
)
295 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
298 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(locale_name
), index
, exists
);
303 for (i
= 0; i
< This
->count
; i
++) {
304 if (!strcmpiW(This
->data
[i
].locale
, locale_name
)) {
314 static HRESULT WINAPI
localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
316 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
318 TRACE("(%p)->(%u %p)\n", This
, index
, length
);
320 if (index
>= This
->count
) {
321 *length
= (UINT32
)-1;
325 *length
= strlenW(This
->data
[index
].locale
);
329 static HRESULT WINAPI
localizedstrings_GetLocaleName(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*buffer
, UINT32 size
)
331 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
333 TRACE("(%p)->(%u %p %u)\n", This
, index
, buffer
, size
);
335 if (index
>= This
->count
) {
336 if (buffer
) *buffer
= 0;
340 if (size
< strlenW(This
->data
[index
].locale
)+1) {
341 if (buffer
) *buffer
= 0;
342 return E_NOT_SUFFICIENT_BUFFER
;
345 strcpyW(buffer
, This
->data
[index
].locale
);
349 static HRESULT WINAPI
localizedstrings_GetStringLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
351 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
353 TRACE("(%p)->(%u %p)\n", This
, index
, length
);
355 if (index
>= This
->count
) {
356 *length
= (UINT32
)-1;
360 *length
= strlenW(This
->data
[index
].string
);
364 static HRESULT WINAPI
localizedstrings_GetString(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*buffer
, UINT32 size
)
366 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
368 TRACE("(%p)->(%u %p %u)\n", This
, index
, buffer
, size
);
370 if (index
>= This
->count
) {
371 if (buffer
) *buffer
= 0;
375 if (size
< strlenW(This
->data
[index
].string
)+1) {
376 if (buffer
) *buffer
= 0;
377 return E_NOT_SUFFICIENT_BUFFER
;
380 strcpyW(buffer
, This
->data
[index
].string
);
384 static const IDWriteLocalizedStringsVtbl localizedstringsvtbl
= {
385 localizedstrings_QueryInterface
,
386 localizedstrings_AddRef
,
387 localizedstrings_Release
,
388 localizedstrings_GetCount
,
389 localizedstrings_FindLocaleName
,
390 localizedstrings_GetLocaleNameLength
,
391 localizedstrings_GetLocaleName
,
392 localizedstrings_GetStringLength
,
393 localizedstrings_GetString
396 HRESULT
create_localizedstrings(IDWriteLocalizedStrings
**strings
)
398 struct localizedstrings
*This
;
402 This
= heap_alloc(sizeof(struct localizedstrings
));
403 if (!This
) return E_OUTOFMEMORY
;
405 This
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
408 This
->data
= heap_alloc_zero(sizeof(struct localizedpair
));
411 return E_OUTOFMEMORY
;
415 *strings
= &This
->IDWriteLocalizedStrings_iface
;
420 HRESULT
add_localizedstring(IDWriteLocalizedStrings
*iface
, const WCHAR
*locale
, const WCHAR
*string
)
422 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
425 /* make sure there's no duplicates */
426 for (i
= 0; i
< This
->count
; i
++)
427 if (!strcmpW(This
->data
[i
].locale
, locale
))
430 if (This
->count
== This
->alloc
) {
433 ptr
= heap_realloc(This
->data
, 2*This
->alloc
*sizeof(struct localizedpair
));
435 return E_OUTOFMEMORY
;
441 This
->data
[This
->count
].locale
= heap_strdupW(locale
);
442 This
->data
[This
->count
].string
= heap_strdupW(string
);
443 if (!This
->data
[This
->count
].locale
|| !This
->data
[This
->count
].string
) {
444 heap_free(This
->data
[This
->count
].locale
);
445 heap_free(This
->data
[This
->count
].string
);
446 return E_OUTOFMEMORY
;
454 HRESULT
clone_localizedstring(IDWriteLocalizedStrings
*iface
, IDWriteLocalizedStrings
**ret
)
456 struct localizedstrings
*strings
, *strings_clone
;
464 strings
= impl_from_IDWriteLocalizedStrings(iface
);
465 strings_clone
= heap_alloc(sizeof(struct localizedstrings
));
466 if (!strings_clone
) return E_OUTOFMEMORY
;
468 strings_clone
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
469 strings_clone
->ref
= 1;
470 strings_clone
->count
= strings
->count
;
471 strings_clone
->data
= heap_alloc(sizeof(struct localizedpair
) * strings_clone
->count
);
472 if (!strings_clone
->data
) {
473 heap_free(strings_clone
);
474 return E_OUTOFMEMORY
;
476 for (i
= 0; i
< strings_clone
->count
; i
++)
478 strings_clone
->data
[i
].locale
= heap_strdupW(strings
->data
[i
].locale
);
479 strings_clone
->data
[i
].string
= heap_strdupW(strings
->data
[i
].string
);
481 strings_clone
->alloc
= strings_clone
->count
;
483 *ret
= &strings_clone
->IDWriteLocalizedStrings_iface
;
488 void set_en_localizedstring(IDWriteLocalizedStrings
*iface
, const WCHAR
*string
)
490 static const WCHAR enusW
[] = {'e','n','-','U','S',0};
491 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
494 for (i
= 0; i
< This
->count
; i
++) {
495 if (!strcmpiW(This
->data
[i
].locale
, enusW
)) {
496 heap_free(This
->data
[i
].string
);
497 This
->data
[i
].string
= heap_strdupW(string
);
503 struct collectionloader
506 IDWriteFontCollectionLoader
*loader
;
509 struct fontfacecached
512 IDWriteFontFace
*fontface
;
518 struct list fontfaces
;
519 IDWriteFontFileLoader
*loader
;
522 struct dwritefactory
{
523 IDWriteFactory3 IDWriteFactory3_iface
;
526 IDWriteFontCollection
*system_collection
;
527 IDWriteFontCollection
*eudc_collection
;
528 struct gdiinterop interop
;
529 IDWriteFontFallback
*fallback
;
531 IDWriteLocalFontFileLoader
* localfontfileloader
;
532 struct list localfontfaces
;
534 struct list collection_loaders
;
535 struct list file_loaders
;
538 static inline struct dwritefactory
*impl_from_IDWriteFactory3(IDWriteFactory3
*iface
)
540 return CONTAINING_RECORD(iface
, struct dwritefactory
, IDWriteFactory3_iface
);
543 static void release_fontface_cache(struct list
*fontfaces
)
545 struct fontfacecached
*fontface
, *fontface2
;
546 LIST_FOR_EACH_ENTRY_SAFE(fontface
, fontface2
, fontfaces
, struct fontfacecached
, entry
) {
547 list_remove(&fontface
->entry
);
548 IDWriteFontFace_Release(fontface
->fontface
);
553 static void release_fileloader(struct fileloader
*fileloader
)
555 list_remove(&fileloader
->entry
);
556 release_fontface_cache(&fileloader
->fontfaces
);
557 IDWriteFontFileLoader_Release(fileloader
->loader
);
558 heap_free(fileloader
);
561 static void release_dwritefactory(struct dwritefactory
*factory
)
563 struct fileloader
*fileloader
, *fileloader2
;
564 struct collectionloader
*loader
, *loader2
;
566 if (factory
->localfontfileloader
)
567 IDWriteLocalFontFileLoader_Release(factory
->localfontfileloader
);
568 release_fontface_cache(&factory
->localfontfaces
);
570 LIST_FOR_EACH_ENTRY_SAFE(loader
, loader2
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
571 list_remove(&loader
->entry
);
572 IDWriteFontCollectionLoader_Release(loader
->loader
);
576 LIST_FOR_EACH_ENTRY_SAFE(fileloader
, fileloader2
, &factory
->file_loaders
, struct fileloader
, entry
)
577 release_fileloader(fileloader
);
579 if (factory
->system_collection
)
580 IDWriteFontCollection_Release(factory
->system_collection
);
581 if (factory
->eudc_collection
)
582 IDWriteFontCollection_Release(factory
->eudc_collection
);
583 if (factory
->fallback
)
584 release_system_fontfallback(factory
->fallback
);
588 static void release_shared_factory(IDWriteFactory3
*iface
)
590 struct dwritefactory
*factory
;
592 factory
= impl_from_IDWriteFactory3(iface
);
593 release_dwritefactory(factory
);
596 static struct fileloader
*factory_get_file_loader(struct dwritefactory
*factory
, IDWriteFontFileLoader
*loader
)
598 struct fileloader
*entry
, *found
= NULL
;
600 LIST_FOR_EACH_ENTRY(entry
, &factory
->file_loaders
, struct fileloader
, entry
) {
601 if (entry
->loader
== loader
) {
610 static struct collectionloader
*factory_get_collection_loader(struct dwritefactory
*factory
, IDWriteFontCollectionLoader
*loader
)
612 struct collectionloader
*entry
, *found
= NULL
;
614 LIST_FOR_EACH_ENTRY(entry
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
615 if (entry
->loader
== loader
) {
624 static HRESULT WINAPI
dwritefactory_QueryInterface(IDWriteFactory3
*iface
, REFIID riid
, void **obj
)
626 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
628 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
630 if (IsEqualIID(riid
, &IID_IDWriteFactory3
) ||
631 IsEqualIID(riid
, &IID_IDWriteFactory2
) ||
632 IsEqualIID(riid
, &IID_IDWriteFactory1
) ||
633 IsEqualIID(riid
, &IID_IDWriteFactory
) ||
634 IsEqualIID(riid
, &IID_IUnknown
))
637 IDWriteFactory3_AddRef(iface
);
643 return E_NOINTERFACE
;
646 static ULONG WINAPI
dwritefactory_AddRef(IDWriteFactory3
*iface
)
648 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
649 ULONG ref
= InterlockedIncrement(&This
->ref
);
650 TRACE("(%p)->(%d)\n", This
, ref
);
654 static ULONG WINAPI
dwritefactory_Release(IDWriteFactory3
*iface
)
656 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
657 ULONG ref
= InterlockedDecrement(&This
->ref
);
659 TRACE("(%p)->(%d)\n", This
, ref
);
662 release_dwritefactory(This
);
667 static HRESULT WINAPI
dwritefactory_GetSystemFontCollection(IDWriteFactory3
*iface
,
668 IDWriteFontCollection
**collection
, BOOL check_for_updates
)
671 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
672 TRACE("(%p)->(%p %d)\n", This
, collection
, check_for_updates
);
674 if (check_for_updates
)
675 FIXME("checking for system font updates not implemented\n");
677 if (!This
->system_collection
)
678 hr
= get_system_fontcollection(iface
, &This
->system_collection
);
681 IDWriteFontCollection_AddRef(This
->system_collection
);
683 *collection
= This
->system_collection
;
688 static HRESULT WINAPI
dwritefactory_CreateCustomFontCollection(IDWriteFactory3
*iface
,
689 IDWriteFontCollectionLoader
*loader
, void const *key
, UINT32 key_size
, IDWriteFontCollection
**collection
)
691 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
692 IDWriteFontFileEnumerator
*enumerator
;
693 struct collectionloader
*found
;
696 TRACE("(%p)->(%p %p %u %p)\n", This
, loader
, key
, key_size
, collection
);
703 found
= factory_get_collection_loader(This
, loader
);
707 hr
= IDWriteFontCollectionLoader_CreateEnumeratorFromKey(found
->loader
, (IDWriteFactory
*)iface
, key
, key_size
, &enumerator
);
711 hr
= create_font_collection(iface
, enumerator
, FALSE
, collection
);
712 IDWriteFontFileEnumerator_Release(enumerator
);
716 static HRESULT WINAPI
dwritefactory_RegisterFontCollectionLoader(IDWriteFactory3
*iface
,
717 IDWriteFontCollectionLoader
*loader
)
719 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
720 struct collectionloader
*entry
;
722 TRACE("(%p)->(%p)\n", This
, loader
);
727 if (factory_get_collection_loader(This
, loader
))
728 return DWRITE_E_ALREADYREGISTERED
;
730 entry
= heap_alloc(sizeof(*entry
));
732 return E_OUTOFMEMORY
;
734 entry
->loader
= loader
;
735 IDWriteFontCollectionLoader_AddRef(loader
);
736 list_add_tail(&This
->collection_loaders
, &entry
->entry
);
741 static HRESULT WINAPI
dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory3
*iface
,
742 IDWriteFontCollectionLoader
*loader
)
744 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
745 struct collectionloader
*found
;
747 TRACE("(%p)->(%p)\n", This
, loader
);
752 found
= factory_get_collection_loader(This
, loader
);
756 IDWriteFontCollectionLoader_Release(found
->loader
);
757 list_remove(&found
->entry
);
763 static HRESULT WINAPI
dwritefactory_CreateFontFileReference(IDWriteFactory3
*iface
,
764 WCHAR
const *path
, FILETIME
const *writetime
, IDWriteFontFile
**font_file
)
766 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
771 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(path
), writetime
, font_file
);
775 if (!This
->localfontfileloader
)
777 hr
= create_localfontfileloader(&This
->localfontfileloader
);
782 /* get a reference key used by local loader */
783 hr
= get_local_refkey(path
, writetime
, &key
, &key_size
);
787 hr
= create_font_file((IDWriteFontFileLoader
*)This
->localfontfileloader
, key
, key_size
, font_file
);
793 static HRESULT WINAPI
dwritefactory_CreateCustomFontFileReference(IDWriteFactory3
*iface
,
794 void const *reference_key
, UINT32 key_size
, IDWriteFontFileLoader
*loader
, IDWriteFontFile
**font_file
)
796 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
798 TRACE("(%p)->(%p %u %p %p)\n", This
, reference_key
, key_size
, loader
, font_file
);
802 /* local loader is accepted as well */
803 if (!loader
|| !(factory_get_file_loader(This
, loader
) ||
804 (IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
))
807 return create_font_file(loader
, reference_key
, key_size
, font_file
);
810 static HRESULT WINAPI
dwritefactory_CreateFontFace(IDWriteFactory3
*iface
,
811 DWRITE_FONT_FACE_TYPE req_facetype
, UINT32 files_number
, IDWriteFontFile
* const* font_files
,
812 UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFace
**font_face
)
814 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
815 DWRITE_FONT_FILE_TYPE file_type
;
816 DWRITE_FONT_FACE_TYPE face_type
;
817 IDWriteFontFileLoader
*loader
;
818 struct fontfacecached
*cached
;
819 struct list
*fontfaces
;
820 IDWriteFontFace3
*face
;
821 UINT32 key_size
, count
;
826 TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This
, req_facetype
, files_number
, font_files
, index
, simulations
, font_face
);
830 if (!is_face_type_supported(req_facetype
))
833 if (req_facetype
!= DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION
&& index
)
836 if (!is_simulation_valid(simulations
))
839 /* check actual file/face type */
840 is_supported
= FALSE
;
841 face_type
= DWRITE_FONT_FACE_TYPE_UNKNOWN
;
842 hr
= IDWriteFontFile_Analyze(*font_files
, &is_supported
, &file_type
, &face_type
, &count
);
849 if (face_type
!= req_facetype
)
850 return DWRITE_E_FILEFORMAT
;
852 hr
= IDWriteFontFile_GetReferenceKey(*font_files
, &key
, &key_size
);
856 hr
= IDWriteFontFile_GetLoader(*font_files
, &loader
);
860 if (loader
== (IDWriteFontFileLoader
*)This
->localfontfileloader
) {
861 fontfaces
= &This
->localfontfaces
;
862 IDWriteFontFileLoader_Release(loader
);
865 struct fileloader
*fileloader
= factory_get_file_loader(This
, loader
);
866 IDWriteFontFileLoader_Release(loader
);
869 fontfaces
= &fileloader
->fontfaces
;
872 /* search through cache list */
873 LIST_FOR_EACH_ENTRY(cached
, fontfaces
, struct fontfacecached
, entry
) {
874 UINT32 cached_key_size
, count
= 1, cached_face_index
;
875 DWRITE_FONT_SIMULATIONS cached_simulations
;
876 const void *cached_key
;
877 IDWriteFontFile
*file
;
879 cached_face_index
= IDWriteFontFace_GetIndex(cached
->fontface
);
880 cached_simulations
= IDWriteFontFace_GetSimulations(cached
->fontface
);
883 if (cached_face_index
!= index
|| cached_simulations
!= simulations
)
886 hr
= IDWriteFontFace_GetFiles(cached
->fontface
, &count
, &file
);
890 hr
= IDWriteFontFile_GetReferenceKey(file
, &cached_key
, &cached_key_size
);
891 IDWriteFontFile_Release(file
);
895 if (cached_key_size
== key_size
&& !memcmp(cached_key
, key
, key_size
)) {
896 TRACE("returning cached fontface %p\n", cached
->fontface
);
897 *font_face
= cached
->fontface
;
898 IDWriteFontFace_AddRef(*font_face
);
903 hr
= create_fontface(req_facetype
, files_number
, font_files
, index
, simulations
, &face
);
907 /* new cache entry */
908 cached
= heap_alloc(sizeof(*cached
));
910 IDWriteFontFace3_Release(face
);
911 return E_OUTOFMEMORY
;
914 cached
->fontface
= (IDWriteFontFace
*)face
;
915 list_add_tail(fontfaces
, &cached
->entry
);
917 *font_face
= cached
->fontface
;
918 IDWriteFontFace_AddRef(*font_face
);
923 static HRESULT WINAPI
dwritefactory_CreateRenderingParams(IDWriteFactory3
*iface
, IDWriteRenderingParams
**params
)
925 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
929 TRACE("(%p)->(%p)\n", This
, params
);
932 monitor
= MonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
933 return IDWriteFactory3_CreateMonitorRenderingParams(iface
, monitor
, params
);
936 static HRESULT WINAPI
dwritefactory_CreateMonitorRenderingParams(IDWriteFactory3
*iface
, HMONITOR monitor
,
937 IDWriteRenderingParams
**params
)
939 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
940 IDWriteRenderingParams3
*params3
;
941 static int fixme_once
= 0;
944 TRACE("(%p)->(%p %p)\n", This
, monitor
, params
);
947 FIXME("(%p): monitor setting ignored\n", monitor
);
949 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, DWRITE_PIXEL_GEOMETRY_FLAT
, DWRITE_RENDERING_MODE_DEFAULT
,
950 DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
951 *params
= (IDWriteRenderingParams
*)params3
;
955 static HRESULT WINAPI
dwritefactory_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT enhancedContrast
,
956 FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams
**params
)
958 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
959 IDWriteRenderingParams3
*params3
;
962 TRACE("(%p)->(%f %f %f %d %d %p)\n", This
, gamma
, enhancedContrast
, cleartype_level
, geometry
, mode
, params
);
964 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, enhancedContrast
, 1.0f
, cleartype_level
, geometry
,
965 mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
966 *params
= (IDWriteRenderingParams
*)params3
;
970 static HRESULT WINAPI
dwritefactory_RegisterFontFileLoader(IDWriteFactory3
*iface
, IDWriteFontFileLoader
*loader
)
972 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
973 struct fileloader
*entry
;
975 TRACE("(%p)->(%p)\n", This
, loader
);
980 if ((IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
)
983 if (factory_get_file_loader(This
, loader
))
984 return DWRITE_E_ALREADYREGISTERED
;
986 entry
= heap_alloc(sizeof(*entry
));
988 return E_OUTOFMEMORY
;
990 entry
->loader
= loader
;
991 list_init(&entry
->fontfaces
);
992 IDWriteFontFileLoader_AddRef(loader
);
993 list_add_tail(&This
->file_loaders
, &entry
->entry
);
998 static HRESULT WINAPI
dwritefactory_UnregisterFontFileLoader(IDWriteFactory3
*iface
, IDWriteFontFileLoader
*loader
)
1000 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1001 struct fileloader
*found
;
1003 TRACE("(%p)->(%p)\n", This
, loader
);
1006 return E_INVALIDARG
;
1008 if ((IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
)
1011 found
= factory_get_file_loader(This
, loader
);
1013 return E_INVALIDARG
;
1015 release_fileloader(found
);
1019 static HRESULT WINAPI
dwritefactory_CreateTextFormat(IDWriteFactory3
*iface
, WCHAR
const* family_name
,
1020 IDWriteFontCollection
*collection
, DWRITE_FONT_WEIGHT weight
, DWRITE_FONT_STYLE style
,
1021 DWRITE_FONT_STRETCH stretch
, FLOAT size
, WCHAR
const *locale
, IDWriteTextFormat
**format
)
1023 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1024 IDWriteFontCollection
*syscollection
= NULL
;
1027 TRACE("(%p)->(%s %p %d %d %d %f %s %p)\n", This
, debugstr_w(family_name
), collection
, weight
, style
, stretch
,
1028 size
, debugstr_w(locale
), format
);
1031 hr
= IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2
*)iface
, &syscollection
, FALSE
);
1036 hr
= create_textformat(family_name
, collection
? collection
: syscollection
, weight
, style
, stretch
, size
, locale
, format
);
1038 IDWriteFontCollection_Release(syscollection
);
1042 static HRESULT WINAPI
dwritefactory_CreateTypography(IDWriteFactory3
*iface
, IDWriteTypography
**typography
)
1044 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1045 TRACE("(%p)->(%p)\n", This
, typography
);
1046 return create_typography(typography
);
1049 static HRESULT WINAPI
dwritefactory_GetGdiInterop(IDWriteFactory3
*iface
, IDWriteGdiInterop
**gdi_interop
)
1051 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1053 TRACE("(%p)->(%p)\n", This
, gdi_interop
);
1055 *gdi_interop
= (IDWriteGdiInterop
*)&This
->interop
.IDWriteGdiInterop1_iface
;
1056 IDWriteGdiInterop_AddRef(*gdi_interop
);
1060 static HRESULT WINAPI
dwritefactory_CreateTextLayout(IDWriteFactory3
*iface
, WCHAR
const* string
,
1061 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, IDWriteTextLayout
**layout
)
1063 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1064 struct textlayout_desc desc
;
1066 TRACE("(%p)->(%s:%u %p %f %f %p)\n", This
, debugstr_wn(string
, length
), length
, format
, max_width
, max_height
, layout
);
1068 desc
.factory
= iface
;
1069 desc
.string
= string
;
1070 desc
.length
= length
;
1071 desc
.format
= format
;
1072 desc
.max_width
= max_width
;
1073 desc
.max_height
= max_height
;
1074 desc
.is_gdi_compatible
= FALSE
;
1076 desc
.transform
= NULL
;
1077 desc
.use_gdi_natural
= FALSE
;
1078 return create_textlayout(&desc
, layout
);
1081 static HRESULT WINAPI
dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory3
*iface
, WCHAR
const* string
,
1082 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, FLOAT pixels_per_dip
,
1083 DWRITE_MATRIX
const* transform
, BOOL use_gdi_natural
, IDWriteTextLayout
**layout
)
1085 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1086 struct textlayout_desc desc
;
1088 TRACE("(%p)->(%s:%u %p %f %f %f %p %d %p)\n", This
, debugstr_wn(string
, length
), length
, format
, max_width
, max_height
,
1089 pixels_per_dip
, transform
, use_gdi_natural
, layout
);
1091 desc
.factory
= iface
;
1092 desc
.string
= string
;
1093 desc
.length
= length
;
1094 desc
.format
= format
;
1095 desc
.max_width
= max_width
;
1096 desc
.max_height
= max_height
;
1097 desc
.is_gdi_compatible
= TRUE
;
1098 desc
.ppdip
= pixels_per_dip
;
1099 desc
.transform
= transform
;
1100 desc
.use_gdi_natural
= use_gdi_natural
;
1101 return create_textlayout(&desc
, layout
);
1104 static HRESULT WINAPI
dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory3
*iface
, IDWriteTextFormat
*format
,
1105 IDWriteInlineObject
**trimming_sign
)
1107 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1108 TRACE("(%p)->(%p %p)\n", This
, format
, trimming_sign
);
1109 return create_trimmingsign(iface
, format
, trimming_sign
);
1112 static HRESULT WINAPI
dwritefactory_CreateTextAnalyzer(IDWriteFactory3
*iface
, IDWriteTextAnalyzer
**analyzer
)
1114 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1115 TRACE("(%p)->(%p)\n", This
, analyzer
);
1116 return get_textanalyzer(analyzer
);
1119 static HRESULT WINAPI
dwritefactory_CreateNumberSubstitution(IDWriteFactory3
*iface
, DWRITE_NUMBER_SUBSTITUTION_METHOD method
,
1120 WCHAR
const* locale
, BOOL ignore_user_override
, IDWriteNumberSubstitution
**substitution
)
1122 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1123 TRACE("(%p)->(%d %s %d %p)\n", This
, method
, debugstr_w(locale
), ignore_user_override
, substitution
);
1124 return create_numbersubstitution(method
, locale
, ignore_user_override
, substitution
);
1127 static HRESULT WINAPI
dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, DWRITE_GLYPH_RUN
const *run
,
1128 FLOAT ppdip
, DWRITE_MATRIX
const* transform
, DWRITE_RENDERING_MODE rendering_mode
,
1129 DWRITE_MEASURING_MODE measuring_mode
, FLOAT originX
, FLOAT originY
, IDWriteGlyphRunAnalysis
**analysis
)
1131 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1132 struct glyphrunanalysis_desc desc
;
1134 TRACE("(%p)->(%p %.2f %p %d %d %.2f %.2f %p)\n", This
, run
, ppdip
, transform
, rendering_mode
,
1135 measuring_mode
, originX
, originY
, analysis
);
1137 if (ppdip
<= 0.0f
) {
1139 return E_INVALIDARG
;
1144 desc
.transform
= transform
;
1145 desc
.rendering_mode
= rendering_mode
;
1146 desc
.measuring_mode
= measuring_mode
;
1147 desc
.gridfit_mode
= DWRITE_GRID_FIT_MODE_DEFAULT
;
1148 desc
.aa_mode
= DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE
;
1149 desc
.origin_x
= originX
;
1150 desc
.origin_y
= originY
;
1151 return create_glyphrunanalysis(&desc
, analysis
);
1154 static HRESULT WINAPI
dwritefactory1_GetEudcFontCollection(IDWriteFactory3
*iface
, IDWriteFontCollection
**collection
,
1155 BOOL check_for_updates
)
1157 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1160 TRACE("(%p)->(%p %d)\n", This
, collection
, check_for_updates
);
1162 if (check_for_updates
)
1163 FIXME("checking for eudc updates not implemented\n");
1165 if (!This
->eudc_collection
)
1166 hr
= get_eudc_fontcollection(iface
, &This
->eudc_collection
);
1169 IDWriteFontCollection_AddRef(This
->eudc_collection
);
1171 *collection
= This
->eudc_collection
;
1176 static HRESULT WINAPI
dwritefactory1_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
,
1177 FLOAT enhcontrast
, FLOAT enhcontrast_grayscale
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
,
1178 DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams1
** params
)
1180 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1181 IDWriteRenderingParams3
*params3
;
1184 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %p)\n", This
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1185 cleartype_level
, geometry
, mode
, params
);
1186 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1187 cleartype_level
, geometry
, mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1188 *params
= (IDWriteRenderingParams1
*)params3
;
1192 static HRESULT WINAPI
dwritefactory2_GetSystemFontFallback(IDWriteFactory3
*iface
, IDWriteFontFallback
**fallback
)
1194 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1196 TRACE("(%p)->(%p)\n", This
, fallback
);
1200 if (!This
->fallback
) {
1201 HRESULT hr
= create_system_fontfallback(iface
, &This
->fallback
);
1206 *fallback
= This
->fallback
;
1207 IDWriteFontFallback_AddRef(*fallback
);
1211 static HRESULT WINAPI
dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory3
*iface
, IDWriteFontFallbackBuilder
**fallbackbuilder
)
1213 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1214 FIXME("(%p)->(%p): stub\n", This
, fallbackbuilder
);
1218 static HRESULT WINAPI
dwritefactory2_TranslateColorGlyphRun(IDWriteFactory3
*iface
, FLOAT originX
, FLOAT originY
,
1219 const DWRITE_GLYPH_RUN
*run
, const DWRITE_GLYPH_RUN_DESCRIPTION
*rundescr
, DWRITE_MEASURING_MODE mode
,
1220 const DWRITE_MATRIX
*transform
, UINT32 palette
, IDWriteColorGlyphRunEnumerator
**colorlayers
)
1222 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1223 TRACE("(%p)->(%.2f %.2f %p %p %d %p %u %p)\n", This
, originX
, originY
, run
, rundescr
, mode
,
1224 transform
, palette
, colorlayers
);
1225 return create_colorglyphenum(originX
, originY
, run
, rundescr
, mode
, transform
, palette
, colorlayers
);
1228 static HRESULT WINAPI
dwritefactory2_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT contrast
,
1229 FLOAT grayscalecontrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
,
1230 DWRITE_GRID_FIT_MODE gridfit
, IDWriteRenderingParams2
**params
)
1232 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1233 IDWriteRenderingParams3
*params3
;
1236 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This
, gamma
, contrast
, grayscalecontrast
, cleartype_level
,
1237 geometry
, mode
, gridfit
, params
);
1239 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, contrast
, grayscalecontrast
,
1240 cleartype_level
, geometry
, mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1241 *params
= (IDWriteRenderingParams2
*)params3
;
1245 static HRESULT WINAPI
dwritefactory2_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, const DWRITE_GLYPH_RUN
*run
,
1246 const DWRITE_MATRIX
*transform
, DWRITE_RENDERING_MODE rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1247 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1248 IDWriteGlyphRunAnalysis
**analysis
)
1250 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1251 struct glyphrunanalysis_desc desc
;
1253 TRACE("(%p)->(%p %p %d %d %d %d %.2f %.2f %p)\n", This
, run
, transform
, rendering_mode
, measuring_mode
,
1254 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1258 desc
.transform
= transform
;
1259 desc
.rendering_mode
= rendering_mode
;
1260 desc
.measuring_mode
= measuring_mode
;
1261 desc
.gridfit_mode
= gridfit_mode
;
1262 desc
.aa_mode
= aa_mode
;
1263 desc
.origin_x
= originX
;
1264 desc
.origin_y
= originY
;
1265 return create_glyphrunanalysis(&desc
, analysis
);
1268 static HRESULT WINAPI
dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, DWRITE_GLYPH_RUN
const *run
,
1269 DWRITE_MATRIX
const *transform
, DWRITE_RENDERING_MODE1 rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1270 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1271 IDWriteGlyphRunAnalysis
**analysis
)
1273 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1275 FIXME("(%p)->(%p %p %d %d %d %d %.2f %.2f %p): stub\n", This
, run
, transform
, rendering_mode
, measuring_mode
,
1276 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1281 static HRESULT WINAPI
dwritefactory3_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT contrast
,
1282 FLOAT grayscale_contrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY pixel_geometry
, DWRITE_RENDERING_MODE1 rendering_mode
,
1283 DWRITE_GRID_FIT_MODE gridfit_mode
, IDWriteRenderingParams3
**params
)
1285 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1287 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This
, gamma
, contrast
, grayscale_contrast
, cleartype_level
,
1288 pixel_geometry
, rendering_mode
, gridfit_mode
, params
);
1290 return create_renderingparams(gamma
, contrast
, grayscale_contrast
, cleartype_level
, pixel_geometry
, rendering_mode
,
1291 gridfit_mode
, params
);
1294 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference_(IDWriteFactory3
*iface
, IDWriteFontFile
*file
, UINT32 index
,
1295 DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFaceReference
**reference
)
1297 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1299 TRACE("(%p)->(%p %u %x %p)\n", This
, file
, index
, simulations
, reference
);
1301 return create_fontfacereference(iface
, file
, index
, simulations
, reference
);
1304 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference(IDWriteFactory3
*iface
, WCHAR
const *path
, FILETIME
const *writetime
,
1305 UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFaceReference
**reference
)
1307 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1308 IDWriteFontFile
*file
;
1311 TRACE("(%p)->(%s %p %u %x, %p)\n", This
, debugstr_w(path
), writetime
, index
, simulations
, reference
);
1313 hr
= IDWriteFactory3_CreateFontFileReference(iface
, path
, writetime
, &file
);
1319 hr
= IDWriteFactory3_CreateFontFaceReference_(iface
, file
, index
, simulations
, reference
);
1320 IDWriteFontFile_Release(file
);
1324 static HRESULT WINAPI
dwritefactory3_GetSystemFontSet(IDWriteFactory3
*iface
, IDWriteFontSet
**fontset
)
1326 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1328 FIXME("(%p)->(%p): stub\n", This
, fontset
);
1333 static HRESULT WINAPI
dwritefactory3_CreateFontSetBuilder(IDWriteFactory3
*iface
, IDWriteFontSetBuilder
**builder
)
1335 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1337 FIXME("(%p)->(%p): stub\n", This
, builder
);
1342 static HRESULT WINAPI
dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory3
*iface
, IDWriteFontSet
*fontset
,
1343 IDWriteFontCollection1
**collection
)
1345 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1347 FIXME("(%p)->(%p %p): stub\n", This
, fontset
, collection
);
1352 static HRESULT WINAPI
dwritefactory3_GetSystemFontCollection(IDWriteFactory3
*iface
, BOOL include_downloadable
,
1353 IDWriteFontCollection1
**collection
, BOOL check_for_updates
)
1355 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1357 FIXME("(%p)->(%d %p %d): stub\n", This
, include_downloadable
, collection
, check_for_updates
);
1362 static HRESULT WINAPI
dwritefactory3_GetFontDownloadQueue(IDWriteFactory3
*iface
, IDWriteFontDownloadQueue
**queue
)
1364 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1366 FIXME("(%p)->(%p): stub\n", This
, queue
);
1371 static const struct IDWriteFactory3Vtbl dwritefactoryvtbl
= {
1372 dwritefactory_QueryInterface
,
1373 dwritefactory_AddRef
,
1374 dwritefactory_Release
,
1375 dwritefactory_GetSystemFontCollection
,
1376 dwritefactory_CreateCustomFontCollection
,
1377 dwritefactory_RegisterFontCollectionLoader
,
1378 dwritefactory_UnregisterFontCollectionLoader
,
1379 dwritefactory_CreateFontFileReference
,
1380 dwritefactory_CreateCustomFontFileReference
,
1381 dwritefactory_CreateFontFace
,
1382 dwritefactory_CreateRenderingParams
,
1383 dwritefactory_CreateMonitorRenderingParams
,
1384 dwritefactory_CreateCustomRenderingParams
,
1385 dwritefactory_RegisterFontFileLoader
,
1386 dwritefactory_UnregisterFontFileLoader
,
1387 dwritefactory_CreateTextFormat
,
1388 dwritefactory_CreateTypography
,
1389 dwritefactory_GetGdiInterop
,
1390 dwritefactory_CreateTextLayout
,
1391 dwritefactory_CreateGdiCompatibleTextLayout
,
1392 dwritefactory_CreateEllipsisTrimmingSign
,
1393 dwritefactory_CreateTextAnalyzer
,
1394 dwritefactory_CreateNumberSubstitution
,
1395 dwritefactory_CreateGlyphRunAnalysis
,
1396 dwritefactory1_GetEudcFontCollection
,
1397 dwritefactory1_CreateCustomRenderingParams
,
1398 dwritefactory2_GetSystemFontFallback
,
1399 dwritefactory2_CreateFontFallbackBuilder
,
1400 dwritefactory2_TranslateColorGlyphRun
,
1401 dwritefactory2_CreateCustomRenderingParams
,
1402 dwritefactory2_CreateGlyphRunAnalysis
,
1403 dwritefactory3_CreateGlyphRunAnalysis
,
1404 dwritefactory3_CreateCustomRenderingParams
,
1405 dwritefactory3_CreateFontFaceReference_
,
1406 dwritefactory3_CreateFontFaceReference
,
1407 dwritefactory3_GetSystemFontSet
,
1408 dwritefactory3_CreateFontSetBuilder
,
1409 dwritefactory3_CreateFontCollectionFromFontSet
,
1410 dwritefactory3_GetSystemFontCollection
,
1411 dwritefactory3_GetFontDownloadQueue
1414 static ULONG WINAPI
shareddwritefactory_AddRef(IDWriteFactory3
*iface
)
1416 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1417 TRACE("(%p)\n", This
);
1421 static ULONG WINAPI
shareddwritefactory_Release(IDWriteFactory3
*iface
)
1423 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1424 TRACE("(%p)\n", This
);
1428 static const struct IDWriteFactory3Vtbl shareddwritefactoryvtbl
= {
1429 dwritefactory_QueryInterface
,
1430 shareddwritefactory_AddRef
,
1431 shareddwritefactory_Release
,
1432 dwritefactory_GetSystemFontCollection
,
1433 dwritefactory_CreateCustomFontCollection
,
1434 dwritefactory_RegisterFontCollectionLoader
,
1435 dwritefactory_UnregisterFontCollectionLoader
,
1436 dwritefactory_CreateFontFileReference
,
1437 dwritefactory_CreateCustomFontFileReference
,
1438 dwritefactory_CreateFontFace
,
1439 dwritefactory_CreateRenderingParams
,
1440 dwritefactory_CreateMonitorRenderingParams
,
1441 dwritefactory_CreateCustomRenderingParams
,
1442 dwritefactory_RegisterFontFileLoader
,
1443 dwritefactory_UnregisterFontFileLoader
,
1444 dwritefactory_CreateTextFormat
,
1445 dwritefactory_CreateTypography
,
1446 dwritefactory_GetGdiInterop
,
1447 dwritefactory_CreateTextLayout
,
1448 dwritefactory_CreateGdiCompatibleTextLayout
,
1449 dwritefactory_CreateEllipsisTrimmingSign
,
1450 dwritefactory_CreateTextAnalyzer
,
1451 dwritefactory_CreateNumberSubstitution
,
1452 dwritefactory_CreateGlyphRunAnalysis
,
1453 dwritefactory1_GetEudcFontCollection
,
1454 dwritefactory1_CreateCustomRenderingParams
,
1455 dwritefactory2_GetSystemFontFallback
,
1456 dwritefactory2_CreateFontFallbackBuilder
,
1457 dwritefactory2_TranslateColorGlyphRun
,
1458 dwritefactory2_CreateCustomRenderingParams
,
1459 dwritefactory2_CreateGlyphRunAnalysis
,
1460 dwritefactory3_CreateGlyphRunAnalysis
,
1461 dwritefactory3_CreateCustomRenderingParams
,
1462 dwritefactory3_CreateFontFaceReference_
,
1463 dwritefactory3_CreateFontFaceReference
,
1464 dwritefactory3_GetSystemFontSet
,
1465 dwritefactory3_CreateFontSetBuilder
,
1466 dwritefactory3_CreateFontCollectionFromFontSet
,
1467 dwritefactory3_GetSystemFontCollection
,
1468 dwritefactory3_GetFontDownloadQueue
1471 static void init_dwritefactory(struct dwritefactory
*factory
, DWRITE_FACTORY_TYPE type
)
1473 factory
->IDWriteFactory3_iface
.lpVtbl
= type
== DWRITE_FACTORY_TYPE_SHARED
? &shareddwritefactoryvtbl
: &dwritefactoryvtbl
;
1475 factory
->localfontfileloader
= NULL
;
1476 factory
->system_collection
= NULL
;
1477 factory
->eudc_collection
= NULL
;
1478 gdiinterop_init(&factory
->interop
, &factory
->IDWriteFactory3_iface
);
1479 factory
->fallback
= NULL
;
1481 list_init(&factory
->collection_loaders
);
1482 list_init(&factory
->file_loaders
);
1483 list_init(&factory
->localfontfaces
);
1486 HRESULT WINAPI
DWriteCreateFactory(DWRITE_FACTORY_TYPE type
, REFIID riid
, IUnknown
**ret
)
1488 struct dwritefactory
*factory
;
1491 TRACE("(%d, %s, %p)\n", type
, debugstr_guid(riid
), ret
);
1495 if (type
== DWRITE_FACTORY_TYPE_SHARED
&& shared_factory
)
1496 return IDWriteFactory3_QueryInterface(shared_factory
, riid
, (void**)ret
);
1498 factory
= heap_alloc(sizeof(struct dwritefactory
));
1499 if (!factory
) return E_OUTOFMEMORY
;
1501 init_dwritefactory(factory
, type
);
1503 if (type
== DWRITE_FACTORY_TYPE_SHARED
)
1504 if (InterlockedCompareExchangePointer((void**)&shared_factory
, &factory
->IDWriteFactory3_iface
, NULL
)) {
1505 release_shared_factory(&factory
->IDWriteFactory3_iface
);
1506 return IDWriteFactory3_QueryInterface(shared_factory
, riid
, (void**)ret
);
1509 hr
= IDWriteFactory3_QueryInterface(&factory
->IDWriteFactory3_iface
, riid
, (void**)ret
);
1510 IDWriteFactory3_Release(&factory
->IDWriteFactory3_iface
);