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 IDWriteGdiInterop1
*gdiinterop
;
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 void notify_factory_fallback_removed(IDWriteFactory3
*iface
)
545 struct dwritefactory
*factory
= impl_from_IDWriteFactory3(iface
);
546 factory
->fallback
= NULL
;
549 static void release_fontface_cache(struct list
*fontfaces
)
551 struct fontfacecached
*fontface
, *fontface2
;
552 LIST_FOR_EACH_ENTRY_SAFE(fontface
, fontface2
, fontfaces
, struct fontfacecached
, entry
) {
553 list_remove(&fontface
->entry
);
554 IDWriteFontFace_Release(fontface
->fontface
);
559 static void release_fileloader(struct fileloader
*fileloader
)
561 list_remove(&fileloader
->entry
);
562 release_fontface_cache(&fileloader
->fontfaces
);
563 IDWriteFontFileLoader_Release(fileloader
->loader
);
564 heap_free(fileloader
);
567 static void release_dwritefactory(struct dwritefactory
*factory
)
569 struct fileloader
*fileloader
, *fileloader2
;
570 struct collectionloader
*loader
, *loader2
;
572 if (factory
->localfontfileloader
)
573 IDWriteLocalFontFileLoader_Release(factory
->localfontfileloader
);
574 release_fontface_cache(&factory
->localfontfaces
);
576 LIST_FOR_EACH_ENTRY_SAFE(loader
, loader2
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
577 list_remove(&loader
->entry
);
578 IDWriteFontCollectionLoader_Release(loader
->loader
);
582 LIST_FOR_EACH_ENTRY_SAFE(fileloader
, fileloader2
, &factory
->file_loaders
, struct fileloader
, entry
)
583 release_fileloader(fileloader
);
585 if (factory
->system_collection
)
586 IDWriteFontCollection_Release(factory
->system_collection
);
587 if (factory
->eudc_collection
)
588 IDWriteFontCollection_Release(factory
->eudc_collection
);
589 if (factory
->gdiinterop
)
590 release_gdiinterop(factory
->gdiinterop
);
591 if (factory
->fallback
)
592 release_system_fontfallback(factory
->fallback
);
596 static void release_shared_factory(IDWriteFactory3
*iface
)
598 struct dwritefactory
*factory
;
600 factory
= impl_from_IDWriteFactory3(iface
);
601 release_dwritefactory(factory
);
604 static struct fileloader
*factory_get_file_loader(struct dwritefactory
*factory
, IDWriteFontFileLoader
*loader
)
606 struct fileloader
*entry
, *found
= NULL
;
608 LIST_FOR_EACH_ENTRY(entry
, &factory
->file_loaders
, struct fileloader
, entry
) {
609 if (entry
->loader
== loader
) {
618 static struct collectionloader
*factory_get_collection_loader(struct dwritefactory
*factory
, IDWriteFontCollectionLoader
*loader
)
620 struct collectionloader
*entry
, *found
= NULL
;
622 LIST_FOR_EACH_ENTRY(entry
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
623 if (entry
->loader
== loader
) {
632 static HRESULT WINAPI
dwritefactory_QueryInterface(IDWriteFactory3
*iface
, REFIID riid
, void **obj
)
634 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
636 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
638 if (IsEqualIID(riid
, &IID_IDWriteFactory3
) ||
639 IsEqualIID(riid
, &IID_IDWriteFactory2
) ||
640 IsEqualIID(riid
, &IID_IDWriteFactory1
) ||
641 IsEqualIID(riid
, &IID_IDWriteFactory
) ||
642 IsEqualIID(riid
, &IID_IUnknown
))
645 IDWriteFactory3_AddRef(iface
);
651 return E_NOINTERFACE
;
654 static ULONG WINAPI
dwritefactory_AddRef(IDWriteFactory3
*iface
)
656 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
657 ULONG ref
= InterlockedIncrement(&This
->ref
);
658 TRACE("(%p)->(%d)\n", This
, ref
);
662 static ULONG WINAPI
dwritefactory_Release(IDWriteFactory3
*iface
)
664 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
665 ULONG ref
= InterlockedDecrement(&This
->ref
);
667 TRACE("(%p)->(%d)\n", This
, ref
);
670 release_dwritefactory(This
);
675 static HRESULT WINAPI
dwritefactory_GetSystemFontCollection(IDWriteFactory3
*iface
,
676 IDWriteFontCollection
**collection
, BOOL check_for_updates
)
679 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
680 TRACE("(%p)->(%p %d)\n", This
, collection
, check_for_updates
);
682 if (check_for_updates
)
683 FIXME("checking for system font updates not implemented\n");
685 if (!This
->system_collection
)
686 hr
= get_system_fontcollection(iface
, &This
->system_collection
);
689 IDWriteFontCollection_AddRef(This
->system_collection
);
691 *collection
= This
->system_collection
;
696 static HRESULT WINAPI
dwritefactory_CreateCustomFontCollection(IDWriteFactory3
*iface
,
697 IDWriteFontCollectionLoader
*loader
, void const *key
, UINT32 key_size
, IDWriteFontCollection
**collection
)
699 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
700 IDWriteFontFileEnumerator
*enumerator
;
701 struct collectionloader
*found
;
704 TRACE("(%p)->(%p %p %u %p)\n", This
, loader
, key
, key_size
, collection
);
711 found
= factory_get_collection_loader(This
, loader
);
715 hr
= IDWriteFontCollectionLoader_CreateEnumeratorFromKey(found
->loader
, (IDWriteFactory
*)iface
, key
, key_size
, &enumerator
);
719 hr
= create_font_collection(iface
, enumerator
, FALSE
, collection
);
720 IDWriteFontFileEnumerator_Release(enumerator
);
724 static HRESULT WINAPI
dwritefactory_RegisterFontCollectionLoader(IDWriteFactory3
*iface
,
725 IDWriteFontCollectionLoader
*loader
)
727 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
728 struct collectionloader
*entry
;
730 TRACE("(%p)->(%p)\n", This
, loader
);
735 if (factory_get_collection_loader(This
, loader
))
736 return DWRITE_E_ALREADYREGISTERED
;
738 entry
= heap_alloc(sizeof(*entry
));
740 return E_OUTOFMEMORY
;
742 entry
->loader
= loader
;
743 IDWriteFontCollectionLoader_AddRef(loader
);
744 list_add_tail(&This
->collection_loaders
, &entry
->entry
);
749 static HRESULT WINAPI
dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory3
*iface
,
750 IDWriteFontCollectionLoader
*loader
)
752 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
753 struct collectionloader
*found
;
755 TRACE("(%p)->(%p)\n", This
, loader
);
760 found
= factory_get_collection_loader(This
, loader
);
764 IDWriteFontCollectionLoader_Release(found
->loader
);
765 list_remove(&found
->entry
);
771 static HRESULT WINAPI
dwritefactory_CreateFontFileReference(IDWriteFactory3
*iface
,
772 WCHAR
const *path
, FILETIME
const *writetime
, IDWriteFontFile
**font_file
)
774 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
779 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(path
), writetime
, font_file
);
783 if (!This
->localfontfileloader
)
785 hr
= create_localfontfileloader(&This
->localfontfileloader
);
790 /* get a reference key used by local loader */
791 hr
= get_local_refkey(path
, writetime
, &key
, &key_size
);
795 hr
= create_font_file((IDWriteFontFileLoader
*)This
->localfontfileloader
, key
, key_size
, font_file
);
801 static HRESULT WINAPI
dwritefactory_CreateCustomFontFileReference(IDWriteFactory3
*iface
,
802 void const *reference_key
, UINT32 key_size
, IDWriteFontFileLoader
*loader
, IDWriteFontFile
**font_file
)
804 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
806 TRACE("(%p)->(%p %u %p %p)\n", This
, reference_key
, key_size
, loader
, font_file
);
810 /* local loader is accepted as well */
811 if (!loader
|| !(factory_get_file_loader(This
, loader
) ||
812 (IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
))
815 return create_font_file(loader
, reference_key
, key_size
, font_file
);
818 static HRESULT WINAPI
dwritefactory_CreateFontFace(IDWriteFactory3
*iface
,
819 DWRITE_FONT_FACE_TYPE req_facetype
, UINT32 files_number
, IDWriteFontFile
* const* font_files
,
820 UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFace
**font_face
)
822 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
823 DWRITE_FONT_FILE_TYPE file_type
;
824 DWRITE_FONT_FACE_TYPE face_type
;
825 IDWriteFontFileLoader
*loader
;
826 struct fontfacecached
*cached
;
827 struct list
*fontfaces
;
828 IDWriteFontFace3
*face
;
829 UINT32 key_size
, count
;
834 TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This
, req_facetype
, files_number
, font_files
, index
, simulations
, font_face
);
838 if (!is_face_type_supported(req_facetype
))
841 if (req_facetype
!= DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION
&& index
)
844 /* check actual file/face type */
845 is_supported
= FALSE
;
846 face_type
= DWRITE_FONT_FACE_TYPE_UNKNOWN
;
847 hr
= IDWriteFontFile_Analyze(*font_files
, &is_supported
, &file_type
, &face_type
, &count
);
854 if (face_type
!= req_facetype
)
855 return DWRITE_E_FILEFORMAT
;
857 hr
= IDWriteFontFile_GetReferenceKey(*font_files
, &key
, &key_size
);
861 hr
= IDWriteFontFile_GetLoader(*font_files
, &loader
);
865 if (loader
== (IDWriteFontFileLoader
*)This
->localfontfileloader
) {
866 fontfaces
= &This
->localfontfaces
;
867 IDWriteFontFileLoader_Release(loader
);
870 struct fileloader
*fileloader
= factory_get_file_loader(This
, loader
);
871 IDWriteFontFileLoader_Release(loader
);
874 fontfaces
= &fileloader
->fontfaces
;
877 /* search through cache list */
878 LIST_FOR_EACH_ENTRY(cached
, fontfaces
, struct fontfacecached
, entry
) {
879 UINT32 cached_key_size
, count
= 1, cached_face_index
;
880 DWRITE_FONT_SIMULATIONS cached_simulations
;
881 const void *cached_key
;
882 IDWriteFontFile
*file
;
884 cached_face_index
= IDWriteFontFace_GetIndex(cached
->fontface
);
885 cached_simulations
= IDWriteFontFace_GetSimulations(cached
->fontface
);
888 if (cached_face_index
!= index
|| cached_simulations
!= simulations
)
891 hr
= IDWriteFontFace_GetFiles(cached
->fontface
, &count
, &file
);
895 hr
= IDWriteFontFile_GetReferenceKey(file
, &cached_key
, &cached_key_size
);
896 IDWriteFontFile_Release(file
);
900 if (cached_key_size
== key_size
&& !memcmp(cached_key
, key
, key_size
)) {
901 TRACE("returning cached fontface %p\n", cached
->fontface
);
902 *font_face
= cached
->fontface
;
903 IDWriteFontFace_AddRef(*font_face
);
908 hr
= create_fontface(req_facetype
, files_number
, font_files
, index
, simulations
, &face
);
912 /* new cache entry */
913 cached
= heap_alloc(sizeof(*cached
));
915 IDWriteFontFace3_Release(face
);
916 return E_OUTOFMEMORY
;
919 cached
->fontface
= (IDWriteFontFace
*)face
;
920 list_add_tail(fontfaces
, &cached
->entry
);
922 *font_face
= cached
->fontface
;
923 IDWriteFontFace_AddRef(*font_face
);
928 static HRESULT WINAPI
dwritefactory_CreateRenderingParams(IDWriteFactory3
*iface
, IDWriteRenderingParams
**params
)
930 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
934 TRACE("(%p)->(%p)\n", This
, params
);
937 monitor
= MonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
938 return IDWriteFactory3_CreateMonitorRenderingParams(iface
, monitor
, params
);
941 static HRESULT WINAPI
dwritefactory_CreateMonitorRenderingParams(IDWriteFactory3
*iface
, HMONITOR monitor
,
942 IDWriteRenderingParams
**params
)
944 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
945 IDWriteRenderingParams3
*params3
;
946 static int fixme_once
= 0;
949 TRACE("(%p)->(%p %p)\n", This
, monitor
, params
);
952 FIXME("(%p): monitor setting ignored\n", monitor
);
954 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, 0.0f
, 0.0f
, 1.0f
, 0.0f
, DWRITE_PIXEL_GEOMETRY_FLAT
, DWRITE_RENDERING_MODE_DEFAULT
,
955 DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
956 *params
= (IDWriteRenderingParams
*)params3
;
960 static HRESULT WINAPI
dwritefactory_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT enhancedContrast
,
961 FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams
**params
)
963 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
964 IDWriteRenderingParams3
*params3
;
967 TRACE("(%p)->(%f %f %f %d %d %p)\n", This
, gamma
, enhancedContrast
, cleartype_level
, geometry
, mode
, params
);
969 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, enhancedContrast
, 1.0f
, cleartype_level
, geometry
,
970 mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
971 *params
= (IDWriteRenderingParams
*)params3
;
975 static HRESULT WINAPI
dwritefactory_RegisterFontFileLoader(IDWriteFactory3
*iface
, IDWriteFontFileLoader
*loader
)
977 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
978 struct fileloader
*entry
;
980 TRACE("(%p)->(%p)\n", This
, loader
);
985 if ((IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
)
988 if (factory_get_file_loader(This
, loader
))
989 return DWRITE_E_ALREADYREGISTERED
;
991 entry
= heap_alloc(sizeof(*entry
));
993 return E_OUTOFMEMORY
;
995 entry
->loader
= loader
;
996 list_init(&entry
->fontfaces
);
997 IDWriteFontFileLoader_AddRef(loader
);
998 list_add_tail(&This
->file_loaders
, &entry
->entry
);
1003 static HRESULT WINAPI
dwritefactory_UnregisterFontFileLoader(IDWriteFactory3
*iface
, IDWriteFontFileLoader
*loader
)
1005 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1006 struct fileloader
*found
;
1008 TRACE("(%p)->(%p)\n", This
, loader
);
1011 return E_INVALIDARG
;
1013 if ((IDWriteFontFileLoader
*)This
->localfontfileloader
== loader
)
1016 found
= factory_get_file_loader(This
, loader
);
1018 return E_INVALIDARG
;
1020 release_fileloader(found
);
1024 static HRESULT WINAPI
dwritefactory_CreateTextFormat(IDWriteFactory3
*iface
, WCHAR
const* family_name
,
1025 IDWriteFontCollection
*collection
, DWRITE_FONT_WEIGHT weight
, DWRITE_FONT_STYLE style
,
1026 DWRITE_FONT_STRETCH stretch
, FLOAT size
, WCHAR
const *locale
, IDWriteTextFormat
**format
)
1028 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1029 IDWriteFontCollection
*syscollection
= NULL
;
1032 TRACE("(%p)->(%s %p %d %d %d %f %s %p)\n", This
, debugstr_w(family_name
), collection
, weight
, style
, stretch
,
1033 size
, debugstr_w(locale
), format
);
1036 hr
= IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2
*)iface
, &syscollection
, FALSE
);
1041 hr
= create_textformat(family_name
, collection
? collection
: syscollection
, weight
, style
, stretch
, size
, locale
, format
);
1043 IDWriteFontCollection_Release(syscollection
);
1047 static HRESULT WINAPI
dwritefactory_CreateTypography(IDWriteFactory3
*iface
, IDWriteTypography
**typography
)
1049 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1050 TRACE("(%p)->(%p)\n", This
, typography
);
1051 return create_typography(typography
);
1054 static HRESULT WINAPI
dwritefactory_GetGdiInterop(IDWriteFactory3
*iface
, IDWriteGdiInterop
**gdi_interop
)
1056 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1058 TRACE("(%p)->(%p)\n", This
, gdi_interop
);
1060 *gdi_interop
= NULL
;
1062 if (!This
->gdiinterop
) {
1063 HRESULT hr
= create_gdiinterop(iface
, &This
->gdiinterop
);
1068 *gdi_interop
= (IDWriteGdiInterop
*)This
->gdiinterop
;
1069 IDWriteGdiInterop_AddRef(*gdi_interop
);
1074 static HRESULT WINAPI
dwritefactory_CreateTextLayout(IDWriteFactory3
*iface
, WCHAR
const* string
,
1075 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, IDWriteTextLayout
**layout
)
1077 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1078 struct textlayout_desc desc
;
1080 TRACE("(%p)->(%s:%u %p %f %f %p)\n", This
, debugstr_wn(string
, length
), length
, format
, max_width
, max_height
, layout
);
1082 desc
.factory
= iface
;
1083 desc
.string
= string
;
1084 desc
.length
= length
;
1085 desc
.format
= format
;
1086 desc
.max_width
= max_width
;
1087 desc
.max_height
= max_height
;
1088 desc
.is_gdi_compatible
= FALSE
;
1090 desc
.transform
= NULL
;
1091 desc
.use_gdi_natural
= FALSE
;
1092 return create_textlayout(&desc
, layout
);
1095 static HRESULT WINAPI
dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory3
*iface
, WCHAR
const* string
,
1096 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, FLOAT pixels_per_dip
,
1097 DWRITE_MATRIX
const* transform
, BOOL use_gdi_natural
, IDWriteTextLayout
**layout
)
1099 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1100 struct textlayout_desc desc
;
1102 TRACE("(%p)->(%s:%u %p %f %f %f %p %d %p)\n", This
, debugstr_wn(string
, length
), length
, format
, max_width
, max_height
,
1103 pixels_per_dip
, transform
, use_gdi_natural
, layout
);
1105 desc
.factory
= iface
;
1106 desc
.string
= string
;
1107 desc
.length
= length
;
1108 desc
.format
= format
;
1109 desc
.max_width
= max_width
;
1110 desc
.max_height
= max_height
;
1111 desc
.is_gdi_compatible
= TRUE
;
1112 desc
.ppdip
= pixels_per_dip
;
1113 desc
.transform
= transform
;
1114 desc
.use_gdi_natural
= use_gdi_natural
;
1115 return create_textlayout(&desc
, layout
);
1118 static HRESULT WINAPI
dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory3
*iface
, IDWriteTextFormat
*format
,
1119 IDWriteInlineObject
**trimming_sign
)
1121 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1122 TRACE("(%p)->(%p %p)\n", This
, format
, trimming_sign
);
1123 return create_trimmingsign(iface
, format
, trimming_sign
);
1126 static HRESULT WINAPI
dwritefactory_CreateTextAnalyzer(IDWriteFactory3
*iface
, IDWriteTextAnalyzer
**analyzer
)
1128 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1129 TRACE("(%p)->(%p)\n", This
, analyzer
);
1130 return get_textanalyzer(analyzer
);
1133 static HRESULT WINAPI
dwritefactory_CreateNumberSubstitution(IDWriteFactory3
*iface
, DWRITE_NUMBER_SUBSTITUTION_METHOD method
,
1134 WCHAR
const* locale
, BOOL ignore_user_override
, IDWriteNumberSubstitution
**substitution
)
1136 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1137 TRACE("(%p)->(%d %s %d %p)\n", This
, method
, debugstr_w(locale
), ignore_user_override
, substitution
);
1138 return create_numbersubstitution(method
, locale
, ignore_user_override
, substitution
);
1141 static HRESULT WINAPI
dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, DWRITE_GLYPH_RUN
const *run
,
1142 FLOAT ppdip
, DWRITE_MATRIX
const* transform
, DWRITE_RENDERING_MODE rendering_mode
,
1143 DWRITE_MEASURING_MODE measuring_mode
, FLOAT originX
, FLOAT originY
, IDWriteGlyphRunAnalysis
**analysis
)
1145 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1146 struct glyphrunanalysis_desc desc
;
1148 TRACE("(%p)->(%p %.2f %p %d %d %.2f %.2f %p)\n", This
, run
, ppdip
, transform
, rendering_mode
,
1149 measuring_mode
, originX
, originY
, analysis
);
1151 if (ppdip
<= 0.0f
) {
1153 return E_INVALIDARG
;
1158 desc
.transform
= transform
;
1159 desc
.rendering_mode
= rendering_mode
;
1160 desc
.measuring_mode
= measuring_mode
;
1161 desc
.gridfit_mode
= DWRITE_GRID_FIT_MODE_DEFAULT
;
1162 desc
.aa_mode
= DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE
;
1163 desc
.origin_x
= originX
;
1164 desc
.origin_y
= originY
;
1165 return create_glyphrunanalysis(&desc
, analysis
);
1168 static HRESULT WINAPI
dwritefactory1_GetEudcFontCollection(IDWriteFactory3
*iface
, IDWriteFontCollection
**collection
,
1169 BOOL check_for_updates
)
1171 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1174 TRACE("(%p)->(%p %d)\n", This
, collection
, check_for_updates
);
1176 if (check_for_updates
)
1177 FIXME("checking for eudc updates not implemented\n");
1179 if (!This
->eudc_collection
)
1180 hr
= get_eudc_fontcollection(iface
, &This
->eudc_collection
);
1183 IDWriteFontCollection_AddRef(This
->eudc_collection
);
1185 *collection
= This
->eudc_collection
;
1190 static HRESULT WINAPI
dwritefactory1_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
,
1191 FLOAT enhcontrast
, FLOAT enhcontrast_grayscale
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
,
1192 DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams1
** params
)
1194 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1195 IDWriteRenderingParams3
*params3
;
1198 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %p)\n", This
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1199 cleartype_level
, geometry
, mode
, params
);
1200 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1201 cleartype_level
, geometry
, mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1202 *params
= (IDWriteRenderingParams1
*)params3
;
1206 static HRESULT WINAPI
dwritefactory2_GetSystemFontFallback(IDWriteFactory3
*iface
, IDWriteFontFallback
**fallback
)
1208 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1210 TRACE("(%p)->(%p)\n", This
, fallback
);
1214 if (!This
->fallback
) {
1215 HRESULT hr
= create_system_fontfallback(iface
, &This
->fallback
);
1220 *fallback
= This
->fallback
;
1221 IDWriteFontFallback_AddRef(*fallback
);
1225 static HRESULT WINAPI
dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory3
*iface
, IDWriteFontFallbackBuilder
**fallbackbuilder
)
1227 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1228 FIXME("(%p)->(%p): stub\n", This
, fallbackbuilder
);
1232 static HRESULT WINAPI
dwritefactory2_TranslateColorGlyphRun(IDWriteFactory3
*iface
, FLOAT originX
, FLOAT originY
,
1233 const DWRITE_GLYPH_RUN
*run
, const DWRITE_GLYPH_RUN_DESCRIPTION
*rundescr
, DWRITE_MEASURING_MODE mode
,
1234 const DWRITE_MATRIX
*transform
, UINT32 palette
, IDWriteColorGlyphRunEnumerator
**colorlayers
)
1236 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1237 TRACE("(%p)->(%.2f %.2f %p %p %d %p %u %p)\n", This
, originX
, originY
, run
, rundescr
, mode
,
1238 transform
, palette
, colorlayers
);
1239 return create_colorglyphenum(originX
, originY
, run
, rundescr
, mode
, transform
, palette
, colorlayers
);
1242 static HRESULT WINAPI
dwritefactory2_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT contrast
,
1243 FLOAT grayscalecontrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
,
1244 DWRITE_GRID_FIT_MODE gridfit
, IDWriteRenderingParams2
**params
)
1246 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1247 IDWriteRenderingParams3
*params3
;
1250 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This
, gamma
, contrast
, grayscalecontrast
, cleartype_level
,
1251 geometry
, mode
, gridfit
, params
);
1253 hr
= IDWriteFactory3_CreateCustomRenderingParams(iface
, gamma
, contrast
, grayscalecontrast
,
1254 cleartype_level
, geometry
, mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1255 *params
= (IDWriteRenderingParams2
*)params3
;
1259 static HRESULT WINAPI
dwritefactory2_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, const DWRITE_GLYPH_RUN
*run
,
1260 const DWRITE_MATRIX
*transform
, DWRITE_RENDERING_MODE rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1261 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1262 IDWriteGlyphRunAnalysis
**analysis
)
1264 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1265 struct glyphrunanalysis_desc desc
;
1267 TRACE("(%p)->(%p %p %d %d %d %d %.2f %.2f %p)\n", This
, run
, transform
, rendering_mode
, measuring_mode
,
1268 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1272 desc
.transform
= transform
;
1273 desc
.rendering_mode
= rendering_mode
;
1274 desc
.measuring_mode
= measuring_mode
;
1275 desc
.gridfit_mode
= gridfit_mode
;
1276 desc
.aa_mode
= aa_mode
;
1277 desc
.origin_x
= originX
;
1278 desc
.origin_y
= originY
;
1279 return create_glyphrunanalysis(&desc
, analysis
);
1282 static HRESULT WINAPI
dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory3
*iface
, DWRITE_GLYPH_RUN
const *run
,
1283 DWRITE_MATRIX
const *transform
, DWRITE_RENDERING_MODE1 rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1284 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1285 IDWriteGlyphRunAnalysis
**analysis
)
1287 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1289 FIXME("(%p)->(%p %p %d %d %d %d %.2f %.2f %p): stub\n", This
, run
, transform
, rendering_mode
, measuring_mode
,
1290 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1295 static HRESULT WINAPI
dwritefactory3_CreateCustomRenderingParams(IDWriteFactory3
*iface
, FLOAT gamma
, FLOAT contrast
,
1296 FLOAT grayscale_contrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY pixel_geometry
, DWRITE_RENDERING_MODE1 rendering_mode
,
1297 DWRITE_GRID_FIT_MODE gridfit_mode
, IDWriteRenderingParams3
**params
)
1299 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1301 TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This
, gamma
, contrast
, grayscale_contrast
, cleartype_level
,
1302 pixel_geometry
, rendering_mode
, gridfit_mode
, params
);
1304 return create_renderingparams(gamma
, contrast
, grayscale_contrast
, cleartype_level
, pixel_geometry
, rendering_mode
,
1305 gridfit_mode
, params
);
1308 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference_(IDWriteFactory3
*iface
, IDWriteFontFile
*file
, UINT32 index
,
1309 DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFaceReference
**reference
)
1311 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1313 TRACE("(%p)->(%p %u %x %p)\n", This
, file
, index
, simulations
, reference
);
1315 return create_fontfacereference(iface
, file
, index
, simulations
, reference
);
1318 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference(IDWriteFactory3
*iface
, WCHAR
const *path
, FILETIME
const *writetime
,
1319 UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFaceReference
**reference
)
1321 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1322 IDWriteFontFile
*file
;
1325 TRACE("(%p)->(%s %p %u %x, %p)\n", This
, debugstr_w(path
), writetime
, index
, simulations
, reference
);
1327 hr
= IDWriteFactory3_CreateFontFileReference(iface
, path
, writetime
, &file
);
1333 hr
= IDWriteFactory3_CreateFontFaceReference_(iface
, file
, index
, simulations
, reference
);
1334 IDWriteFontFile_Release(file
);
1338 static HRESULT WINAPI
dwritefactory3_GetSystemFontSet(IDWriteFactory3
*iface
, IDWriteFontSet
**fontset
)
1340 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1342 FIXME("(%p)->(%p): stub\n", This
, fontset
);
1347 static HRESULT WINAPI
dwritefactory3_CreateFontSetBuilder(IDWriteFactory3
*iface
, IDWriteFontSetBuilder
**builder
)
1349 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1351 FIXME("(%p)->(%p): stub\n", This
, builder
);
1356 static HRESULT WINAPI
dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory3
*iface
, IDWriteFontSet
*fontset
,
1357 IDWriteFontCollection1
**collection
)
1359 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1361 FIXME("(%p)->(%p %p): stub\n", This
, fontset
, collection
);
1366 static HRESULT WINAPI
dwritefactory3_GetSystemFontCollection(IDWriteFactory3
*iface
, BOOL include_downloadable
,
1367 IDWriteFontCollection1
**collection
, BOOL check_for_updates
)
1369 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1371 FIXME("(%p)->(%d %p %d): stub\n", This
, include_downloadable
, collection
, check_for_updates
);
1376 static HRESULT WINAPI
dwritefactory3_GetFontDownloadQueue(IDWriteFactory3
*iface
, IDWriteFontDownloadQueue
**queue
)
1378 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1380 FIXME("(%p)->(%p): stub\n", This
, queue
);
1385 static const struct IDWriteFactory3Vtbl dwritefactoryvtbl
= {
1386 dwritefactory_QueryInterface
,
1387 dwritefactory_AddRef
,
1388 dwritefactory_Release
,
1389 dwritefactory_GetSystemFontCollection
,
1390 dwritefactory_CreateCustomFontCollection
,
1391 dwritefactory_RegisterFontCollectionLoader
,
1392 dwritefactory_UnregisterFontCollectionLoader
,
1393 dwritefactory_CreateFontFileReference
,
1394 dwritefactory_CreateCustomFontFileReference
,
1395 dwritefactory_CreateFontFace
,
1396 dwritefactory_CreateRenderingParams
,
1397 dwritefactory_CreateMonitorRenderingParams
,
1398 dwritefactory_CreateCustomRenderingParams
,
1399 dwritefactory_RegisterFontFileLoader
,
1400 dwritefactory_UnregisterFontFileLoader
,
1401 dwritefactory_CreateTextFormat
,
1402 dwritefactory_CreateTypography
,
1403 dwritefactory_GetGdiInterop
,
1404 dwritefactory_CreateTextLayout
,
1405 dwritefactory_CreateGdiCompatibleTextLayout
,
1406 dwritefactory_CreateEllipsisTrimmingSign
,
1407 dwritefactory_CreateTextAnalyzer
,
1408 dwritefactory_CreateNumberSubstitution
,
1409 dwritefactory_CreateGlyphRunAnalysis
,
1410 dwritefactory1_GetEudcFontCollection
,
1411 dwritefactory1_CreateCustomRenderingParams
,
1412 dwritefactory2_GetSystemFontFallback
,
1413 dwritefactory2_CreateFontFallbackBuilder
,
1414 dwritefactory2_TranslateColorGlyphRun
,
1415 dwritefactory2_CreateCustomRenderingParams
,
1416 dwritefactory2_CreateGlyphRunAnalysis
,
1417 dwritefactory3_CreateGlyphRunAnalysis
,
1418 dwritefactory3_CreateCustomRenderingParams
,
1419 dwritefactory3_CreateFontFaceReference_
,
1420 dwritefactory3_CreateFontFaceReference
,
1421 dwritefactory3_GetSystemFontSet
,
1422 dwritefactory3_CreateFontSetBuilder
,
1423 dwritefactory3_CreateFontCollectionFromFontSet
,
1424 dwritefactory3_GetSystemFontCollection
,
1425 dwritefactory3_GetFontDownloadQueue
1428 static ULONG WINAPI
shareddwritefactory_AddRef(IDWriteFactory3
*iface
)
1430 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1431 TRACE("(%p)\n", This
);
1435 static ULONG WINAPI
shareddwritefactory_Release(IDWriteFactory3
*iface
)
1437 struct dwritefactory
*This
= impl_from_IDWriteFactory3(iface
);
1438 TRACE("(%p)\n", This
);
1442 static const struct IDWriteFactory3Vtbl shareddwritefactoryvtbl
= {
1443 dwritefactory_QueryInterface
,
1444 shareddwritefactory_AddRef
,
1445 shareddwritefactory_Release
,
1446 dwritefactory_GetSystemFontCollection
,
1447 dwritefactory_CreateCustomFontCollection
,
1448 dwritefactory_RegisterFontCollectionLoader
,
1449 dwritefactory_UnregisterFontCollectionLoader
,
1450 dwritefactory_CreateFontFileReference
,
1451 dwritefactory_CreateCustomFontFileReference
,
1452 dwritefactory_CreateFontFace
,
1453 dwritefactory_CreateRenderingParams
,
1454 dwritefactory_CreateMonitorRenderingParams
,
1455 dwritefactory_CreateCustomRenderingParams
,
1456 dwritefactory_RegisterFontFileLoader
,
1457 dwritefactory_UnregisterFontFileLoader
,
1458 dwritefactory_CreateTextFormat
,
1459 dwritefactory_CreateTypography
,
1460 dwritefactory_GetGdiInterop
,
1461 dwritefactory_CreateTextLayout
,
1462 dwritefactory_CreateGdiCompatibleTextLayout
,
1463 dwritefactory_CreateEllipsisTrimmingSign
,
1464 dwritefactory_CreateTextAnalyzer
,
1465 dwritefactory_CreateNumberSubstitution
,
1466 dwritefactory_CreateGlyphRunAnalysis
,
1467 dwritefactory1_GetEudcFontCollection
,
1468 dwritefactory1_CreateCustomRenderingParams
,
1469 dwritefactory2_GetSystemFontFallback
,
1470 dwritefactory2_CreateFontFallbackBuilder
,
1471 dwritefactory2_TranslateColorGlyphRun
,
1472 dwritefactory2_CreateCustomRenderingParams
,
1473 dwritefactory2_CreateGlyphRunAnalysis
,
1474 dwritefactory3_CreateGlyphRunAnalysis
,
1475 dwritefactory3_CreateCustomRenderingParams
,
1476 dwritefactory3_CreateFontFaceReference_
,
1477 dwritefactory3_CreateFontFaceReference
,
1478 dwritefactory3_GetSystemFontSet
,
1479 dwritefactory3_CreateFontSetBuilder
,
1480 dwritefactory3_CreateFontCollectionFromFontSet
,
1481 dwritefactory3_GetSystemFontCollection
,
1482 dwritefactory3_GetFontDownloadQueue
1485 static void init_dwritefactory(struct dwritefactory
*factory
, DWRITE_FACTORY_TYPE type
)
1487 factory
->IDWriteFactory3_iface
.lpVtbl
= type
== DWRITE_FACTORY_TYPE_SHARED
? &shareddwritefactoryvtbl
: &dwritefactoryvtbl
;
1489 factory
->localfontfileloader
= NULL
;
1490 factory
->system_collection
= NULL
;
1491 factory
->eudc_collection
= NULL
;
1492 factory
->gdiinterop
= NULL
;
1493 factory
->fallback
= NULL
;
1495 list_init(&factory
->collection_loaders
);
1496 list_init(&factory
->file_loaders
);
1497 list_init(&factory
->localfontfaces
);
1500 HRESULT WINAPI
DWriteCreateFactory(DWRITE_FACTORY_TYPE type
, REFIID riid
, IUnknown
**ret
)
1502 struct dwritefactory
*factory
;
1505 TRACE("(%d, %s, %p)\n", type
, debugstr_guid(riid
), ret
);
1509 if (type
== DWRITE_FACTORY_TYPE_SHARED
&& shared_factory
)
1510 return IDWriteFactory3_QueryInterface(shared_factory
, riid
, (void**)ret
);
1512 factory
= heap_alloc(sizeof(struct dwritefactory
));
1513 if (!factory
) return E_OUTOFMEMORY
;
1515 init_dwritefactory(factory
, type
);
1517 if (type
== DWRITE_FACTORY_TYPE_SHARED
)
1518 if (InterlockedCompareExchangePointer((void**)&shared_factory
, &factory
->IDWriteFactory3_iface
, NULL
)) {
1519 release_shared_factory(&factory
->IDWriteFactory3_iface
);
1520 return IDWriteFactory3_QueryInterface(shared_factory
, riid
, (void**)ret
);
1523 hr
= IDWriteFactory3_QueryInterface(&factory
->IDWriteFactory3_iface
, riid
, (void**)ret
);
1524 IDWriteFactory3_Release(&factory
->IDWriteFactory3_iface
);