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
32 #include "dwrite_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
37 HMODULE dwrite_module
= 0;
38 static IDWriteFactory7
*shared_factory
;
39 static void release_shared_factory(IDWriteFactory7
*factory
);
41 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD reason
, LPVOID reserved
)
45 case DLL_PROCESS_ATTACH
:
46 dwrite_module
= hinstDLL
;
47 DisableThreadLibraryCalls( hinstDLL
);
49 init_local_fontfile_loader();
51 case DLL_PROCESS_DETACH
:
53 release_shared_factory(shared_factory
);
54 release_font_backend();
59 struct renderingparams
61 IDWriteRenderingParams3 IDWriteRenderingParams3_iface
;
66 float grayscalecontrast
;
67 float cleartype_level
;
68 DWRITE_PIXEL_GEOMETRY geometry
;
69 DWRITE_RENDERING_MODE1 mode
;
70 DWRITE_GRID_FIT_MODE gridfit
;
73 static inline struct renderingparams
*impl_from_IDWriteRenderingParams3(IDWriteRenderingParams3
*iface
)
75 return CONTAINING_RECORD(iface
, struct renderingparams
, IDWriteRenderingParams3_iface
);
78 static HRESULT WINAPI
renderingparams_QueryInterface(IDWriteRenderingParams3
*iface
, REFIID riid
, void **obj
)
80 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
82 if (IsEqualIID(riid
, &IID_IDWriteRenderingParams3
) ||
83 IsEqualIID(riid
, &IID_IDWriteRenderingParams2
) ||
84 IsEqualIID(riid
, &IID_IDWriteRenderingParams1
) ||
85 IsEqualIID(riid
, &IID_IDWriteRenderingParams
) ||
86 IsEqualIID(riid
, &IID_IUnknown
))
89 IDWriteRenderingParams3_AddRef(iface
);
98 static ULONG WINAPI
renderingparams_AddRef(IDWriteRenderingParams3
*iface
)
100 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
101 ULONG refcount
= InterlockedIncrement(¶ms
->refcount
);
103 TRACE("%p, refcount %d.\n", iface
, refcount
);
108 static ULONG WINAPI
renderingparams_Release(IDWriteRenderingParams3
*iface
)
110 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
111 ULONG refcount
= InterlockedDecrement(¶ms
->refcount
);
113 TRACE("%p, refcount %d.\n", iface
, refcount
);
121 static float WINAPI
renderingparams_GetGamma(IDWriteRenderingParams3
*iface
)
123 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
125 TRACE("%p.\n", iface
);
127 return params
->gamma
;
130 static float WINAPI
renderingparams_GetEnhancedContrast(IDWriteRenderingParams3
*iface
)
132 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
134 TRACE("%p.\n", iface
);
136 return params
->contrast
;
139 static float WINAPI
renderingparams_GetClearTypeLevel(IDWriteRenderingParams3
*iface
)
141 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
143 TRACE("%p.\n", iface
);
145 return params
->cleartype_level
;
148 static DWRITE_PIXEL_GEOMETRY WINAPI
renderingparams_GetPixelGeometry(IDWriteRenderingParams3
*iface
)
150 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
152 TRACE("%p.\n", iface
);
154 return params
->geometry
;
157 static DWRITE_RENDERING_MODE
rendering_mode_from_mode1(DWRITE_RENDERING_MODE1 mode
)
159 static const DWRITE_RENDERING_MODE rendering_modes
[] = {
160 DWRITE_RENDERING_MODE_DEFAULT
, /* DWRITE_RENDERING_MODE1_DEFAULT */
161 DWRITE_RENDERING_MODE_ALIASED
, /* DWRITE_RENDERING_MODE1_ALIASED */
162 DWRITE_RENDERING_MODE_GDI_CLASSIC
, /* DWRITE_RENDERING_MODE1_GDI_CLASSIC */
163 DWRITE_RENDERING_MODE_GDI_NATURAL
, /* DWRITE_RENDERING_MODE1_GDI_NATURAL */
164 DWRITE_RENDERING_MODE_NATURAL
, /* DWRITE_RENDERING_MODE1_NATURAL */
165 DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
, /* DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC */
166 DWRITE_RENDERING_MODE_OUTLINE
, /* DWRITE_RENDERING_MODE1_OUTLINE */
167 DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC
, /* DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED */
170 return rendering_modes
[mode
];
173 static DWRITE_RENDERING_MODE WINAPI
renderingparams_GetRenderingMode(IDWriteRenderingParams3
*iface
)
175 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
177 TRACE("%p.\n", iface
);
179 return rendering_mode_from_mode1(params
->mode
);
182 static float WINAPI
renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3
*iface
)
184 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
186 TRACE("%p.\n", iface
);
188 return params
->grayscalecontrast
;
191 static DWRITE_GRID_FIT_MODE WINAPI
renderingparams2_GetGridFitMode(IDWriteRenderingParams3
*iface
)
193 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
195 TRACE("%p.\n", iface
);
197 return params
->gridfit
;
200 static DWRITE_RENDERING_MODE1 WINAPI
renderingparams3_GetRenderingMode1(IDWriteRenderingParams3
*iface
)
202 struct renderingparams
*params
= impl_from_IDWriteRenderingParams3(iface
);
204 TRACE("%p.\n", iface
);
209 static const IDWriteRenderingParams3Vtbl renderingparamsvtbl
=
211 renderingparams_QueryInterface
,
212 renderingparams_AddRef
,
213 renderingparams_Release
,
214 renderingparams_GetGamma
,
215 renderingparams_GetEnhancedContrast
,
216 renderingparams_GetClearTypeLevel
,
217 renderingparams_GetPixelGeometry
,
218 renderingparams_GetRenderingMode
,
219 renderingparams1_GetGrayscaleEnhancedContrast
,
220 renderingparams2_GetGridFitMode
,
221 renderingparams3_GetRenderingMode1
224 static HRESULT
create_renderingparams(float gamma
, float contrast
, float grayscalecontrast
, float cleartype_level
,
225 DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE1 mode
, DWRITE_GRID_FIT_MODE gridfit
,
226 IDWriteRenderingParams3
**params
)
228 struct renderingparams
*object
;
232 if (gamma
<= 0.0f
|| contrast
< 0.0f
|| grayscalecontrast
< 0.0f
|| cleartype_level
< 0.0f
)
235 if ((UINT32
)gridfit
> DWRITE_GRID_FIT_MODE_ENABLED
|| (UINT32
)geometry
> DWRITE_PIXEL_GEOMETRY_BGR
)
238 if (!(object
= heap_alloc(sizeof(*object
))))
239 return E_OUTOFMEMORY
;
241 object
->IDWriteRenderingParams3_iface
.lpVtbl
= &renderingparamsvtbl
;
242 object
->refcount
= 1;
244 object
->gamma
= gamma
;
245 object
->contrast
= contrast
;
246 object
->grayscalecontrast
= grayscalecontrast
;
247 object
->cleartype_level
= cleartype_level
;
248 object
->geometry
= geometry
;
250 object
->gridfit
= gridfit
;
252 *params
= &object
->IDWriteRenderingParams3_iface
;
257 struct localizedpair
{
262 struct localizedstrings
264 IDWriteLocalizedStrings IDWriteLocalizedStrings_iface
;
267 struct localizedpair
*data
;
272 static inline struct localizedstrings
*impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings
*iface
)
274 return CONTAINING_RECORD(iface
, struct localizedstrings
, IDWriteLocalizedStrings_iface
);
277 static HRESULT WINAPI
localizedstrings_QueryInterface(IDWriteLocalizedStrings
*iface
, REFIID riid
, void **obj
)
279 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
281 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteLocalizedStrings
))
284 IDWriteLocalizedStrings_AddRef(iface
);
290 return E_NOINTERFACE
;
293 static ULONG WINAPI
localizedstrings_AddRef(IDWriteLocalizedStrings
*iface
)
295 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
296 ULONG refcount
= InterlockedIncrement(&strings
->refcount
);
298 TRACE("%p, refcount %d.\n", iface
, refcount
);
303 static ULONG WINAPI
localizedstrings_Release(IDWriteLocalizedStrings
*iface
)
305 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
306 ULONG refcount
= InterlockedDecrement(&strings
->refcount
);
309 TRACE("%p, refcount %d.\n", iface
, refcount
);
313 for (i
= 0; i
< strings
->count
; ++i
)
315 heap_free(strings
->data
[i
].locale
);
316 heap_free(strings
->data
[i
].string
);
319 heap_free(strings
->data
);
326 static UINT32 WINAPI
localizedstrings_GetCount(IDWriteLocalizedStrings
*iface
)
328 TRACE("%p.\n", iface
);
330 return get_localizedstrings_count(iface
);
333 static HRESULT WINAPI
localizedstrings_FindLocaleName(IDWriteLocalizedStrings
*iface
,
334 WCHAR
const *locale_name
, UINT32
*index
, BOOL
*exists
)
336 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
339 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_w(locale_name
), index
, exists
);
344 for (i
= 0; i
< strings
->count
; ++i
)
346 if (!wcsicmp(strings
->data
[i
].locale
, locale_name
))
357 static HRESULT WINAPI
localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
359 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
361 TRACE("%p, %u, %p.\n", iface
, index
, length
);
363 if (index
>= strings
->count
)
365 *length
= (UINT32
)-1;
369 *length
= wcslen(strings
->data
[index
].locale
);
373 static HRESULT WINAPI
localizedstrings_GetLocaleName(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*buffer
, UINT32 size
)
375 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
377 TRACE("%p, %u, %p, %u.\n", iface
, index
, buffer
, size
);
379 if (index
>= strings
->count
)
381 if (buffer
) *buffer
= 0;
385 if (size
< wcslen(strings
->data
[index
].locale
) + 1)
387 if (buffer
) *buffer
= 0;
388 return E_NOT_SUFFICIENT_BUFFER
;
391 wcscpy(buffer
, strings
->data
[index
].locale
);
395 static HRESULT WINAPI
localizedstrings_GetStringLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
397 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
399 TRACE("%p, %u, %p.\n", iface
, index
, length
);
401 if (index
>= strings
->count
)
407 *length
= wcslen(strings
->data
[index
].string
);
411 static HRESULT WINAPI
localizedstrings_GetString(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*buffer
, UINT32 size
)
413 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
415 TRACE("%p, %u, %p, %u.\n", iface
, index
, buffer
, size
);
417 if (index
>= strings
->count
)
419 if (buffer
) *buffer
= 0;
423 if (size
< wcslen(strings
->data
[index
].string
) + 1)
425 if (buffer
) *buffer
= 0;
426 return E_NOT_SUFFICIENT_BUFFER
;
429 wcscpy(buffer
, strings
->data
[index
].string
);
433 static const IDWriteLocalizedStringsVtbl localizedstringsvtbl
=
435 localizedstrings_QueryInterface
,
436 localizedstrings_AddRef
,
437 localizedstrings_Release
,
438 localizedstrings_GetCount
,
439 localizedstrings_FindLocaleName
,
440 localizedstrings_GetLocaleNameLength
,
441 localizedstrings_GetLocaleName
,
442 localizedstrings_GetStringLength
,
443 localizedstrings_GetString
446 HRESULT
create_localizedstrings(IDWriteLocalizedStrings
**strings
)
448 struct localizedstrings
*object
;
452 object
= heap_alloc_zero(sizeof(*object
));
454 return E_OUTOFMEMORY
;
456 object
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
457 object
->refcount
= 1;
459 *strings
= &object
->IDWriteLocalizedStrings_iface
;
464 HRESULT
add_localizedstring(IDWriteLocalizedStrings
*iface
, const WCHAR
*locale
, const WCHAR
*string
)
466 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
467 size_t i
, count
= strings
->count
;
469 /* Make sure there's no duplicates, unless it's empty. This is used by dlng/slng entries of 'meta' table. */
472 for (i
= 0; i
< count
; i
++)
473 if (!wcsicmp(strings
->data
[i
].locale
, locale
))
477 if (!dwrite_array_reserve((void **)&strings
->data
, &strings
->size
, strings
->count
+ 1, sizeof(*strings
->data
)))
478 return E_OUTOFMEMORY
;
480 strings
->data
[count
].locale
= heap_strdupW(locale
);
481 strings
->data
[count
].string
= heap_strdupW(string
);
482 if (!strings
->data
[count
].locale
|| !strings
->data
[count
].string
)
484 heap_free(strings
->data
[count
].locale
);
485 heap_free(strings
->data
[count
].string
);
486 return E_OUTOFMEMORY
;
488 wcslwr(strings
->data
[count
].locale
);
495 HRESULT
clone_localizedstrings(IDWriteLocalizedStrings
*iface
, IDWriteLocalizedStrings
**ret
)
497 struct localizedstrings
*strings
, *strings_clone
;
505 strings
= impl_from_IDWriteLocalizedStrings(iface
);
506 strings_clone
= heap_alloc_zero(sizeof(*strings_clone
));
508 return E_OUTOFMEMORY
;
510 if (!dwrite_array_reserve((void **)&strings_clone
->data
, &strings_clone
->size
, strings
->count
,
511 sizeof(*strings_clone
->data
)))
513 heap_free(strings_clone
);
514 return E_OUTOFMEMORY
;
517 strings_clone
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
518 strings_clone
->refcount
= 1;
519 strings_clone
->count
= strings
->count
;
521 for (i
= 0; i
< strings_clone
->count
; ++i
)
523 strings_clone
->data
[i
].locale
= heap_strdupW(strings
->data
[i
].locale
);
524 strings_clone
->data
[i
].string
= heap_strdupW(strings
->data
[i
].string
);
527 *ret
= &strings_clone
->IDWriteLocalizedStrings_iface
;
532 void set_en_localizedstring(IDWriteLocalizedStrings
*iface
, const WCHAR
*string
)
534 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
537 for (i
= 0; i
< strings
->count
; i
++)
539 if (!wcsicmp(strings
->data
[i
].locale
, L
"en-US"))
541 heap_free(strings
->data
[i
].string
);
542 strings
->data
[i
].string
= heap_strdupW(string
);
548 static int __cdecl
localizedstrings_sorting_compare(const void *left
, const void *right
)
550 const struct localizedpair
*_l
= left
, *_r
= right
;
552 return wcscmp(_l
->locale
, _r
->locale
);
555 void sort_localizedstrings(IDWriteLocalizedStrings
*iface
)
557 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
559 qsort(strings
->data
, strings
->count
, sizeof(*strings
->data
), localizedstrings_sorting_compare
);
562 unsigned int get_localizedstrings_count(IDWriteLocalizedStrings
*iface
)
564 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
565 return strings
->count
;
568 BOOL
localizedstrings_contains(IDWriteLocalizedStrings
*iface
, const WCHAR
*str
)
570 struct localizedstrings
*strings
= impl_from_IDWriteLocalizedStrings(iface
);
573 for (i
= 0; i
< strings
->count
; ++i
)
575 if (!wcsicmp(strings
->data
[i
].string
, str
)) return TRUE
;
581 struct collectionloader
584 IDWriteFontCollectionLoader
*loader
;
590 struct list fontfaces
;
591 IDWriteFontFileLoader
*loader
;
596 IDWriteFactory7 IDWriteFactory7_iface
;
599 IDWriteFontCollection1
*system_collection
;
600 IDWriteFontCollection1
*eudc_collection
;
601 IDWriteGdiInterop1
*gdiinterop
;
602 IDWriteFontFallback1
*fallback
;
604 IDWriteFontFileLoader
*localfontfileloader
;
605 struct list localfontfaces
;
607 struct list collection_loaders
;
608 struct list file_loaders
;
613 static inline struct dwritefactory
*impl_from_IDWriteFactory7(IDWriteFactory7
*iface
)
615 return CONTAINING_RECORD(iface
, struct dwritefactory
, IDWriteFactory7_iface
);
618 static void release_fontface_cache(struct list
*fontfaces
)
620 struct fontfacecached
*fontface
, *fontface2
;
622 LIST_FOR_EACH_ENTRY_SAFE(fontface
, fontface2
, fontfaces
, struct fontfacecached
, entry
) {
623 list_remove(&fontface
->entry
);
624 fontface_detach_from_cache(fontface
->fontface
);
629 static void release_fileloader(struct fileloader
*fileloader
)
631 list_remove(&fileloader
->entry
);
632 release_fontface_cache(&fileloader
->fontfaces
);
633 IDWriteFontFileLoader_Release(fileloader
->loader
);
634 heap_free(fileloader
);
637 static void release_dwritefactory(struct dwritefactory
*factory
)
639 struct fileloader
*fileloader
, *fileloader2
;
640 struct collectionloader
*loader
, *loader2
;
642 EnterCriticalSection(&factory
->cs
);
643 release_fontface_cache(&factory
->localfontfaces
);
644 LeaveCriticalSection(&factory
->cs
);
646 LIST_FOR_EACH_ENTRY_SAFE(loader
, loader2
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
647 list_remove(&loader
->entry
);
648 IDWriteFontCollectionLoader_Release(loader
->loader
);
652 LIST_FOR_EACH_ENTRY_SAFE(fileloader
, fileloader2
, &factory
->file_loaders
, struct fileloader
, entry
)
653 release_fileloader(fileloader
);
655 if (factory
->system_collection
)
656 IDWriteFontCollection1_Release(factory
->system_collection
);
657 if (factory
->eudc_collection
)
658 IDWriteFontCollection1_Release(factory
->eudc_collection
);
659 if (factory
->fallback
)
660 release_system_fontfallback(factory
->fallback
);
662 factory
->cs
.DebugInfo
->Spare
[0] = 0;
663 DeleteCriticalSection(&factory
->cs
);
667 static void release_shared_factory(IDWriteFactory7
*iface
)
669 struct dwritefactory
*factory
;
671 factory
= impl_from_IDWriteFactory7(iface
);
672 release_dwritefactory(factory
);
675 static struct fileloader
*factory_get_file_loader(struct dwritefactory
*factory
, IDWriteFontFileLoader
*loader
)
677 struct fileloader
*entry
, *found
= NULL
;
679 LIST_FOR_EACH_ENTRY(entry
, &factory
->file_loaders
, struct fileloader
, entry
) {
680 if (entry
->loader
== loader
) {
689 static struct collectionloader
*factory_get_collection_loader(struct dwritefactory
*factory
,
690 IDWriteFontCollectionLoader
*loader
)
692 struct collectionloader
*entry
, *found
= NULL
;
694 LIST_FOR_EACH_ENTRY(entry
, &factory
->collection_loaders
, struct collectionloader
, entry
) {
695 if (entry
->loader
== loader
) {
704 static IDWriteFontCollection1
*factory_get_system_collection(struct dwritefactory
*factory
)
706 IDWriteFontCollection1
*collection
;
709 if (factory
->system_collection
) {
710 IDWriteFontCollection1_AddRef(factory
->system_collection
);
711 return factory
->system_collection
;
714 if (FAILED(hr
= get_system_fontcollection(&factory
->IDWriteFactory7_iface
, &collection
)))
716 WARN("Failed to create system font collection, hr %#x.\n", hr
);
720 if (InterlockedCompareExchangePointer((void **)&factory
->system_collection
, collection
, NULL
))
721 IDWriteFontCollection1_Release(collection
);
723 return factory
->system_collection
;
726 static HRESULT WINAPI
dwritefactory_QueryInterface(IDWriteFactory7
*iface
, REFIID riid
, void **obj
)
728 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
730 if (IsEqualIID(riid
, &IID_IDWriteFactory7
) ||
731 IsEqualIID(riid
, &IID_IDWriteFactory6
) ||
732 IsEqualIID(riid
, &IID_IDWriteFactory5
) ||
733 IsEqualIID(riid
, &IID_IDWriteFactory4
) ||
734 IsEqualIID(riid
, &IID_IDWriteFactory3
) ||
735 IsEqualIID(riid
, &IID_IDWriteFactory2
) ||
736 IsEqualIID(riid
, &IID_IDWriteFactory1
) ||
737 IsEqualIID(riid
, &IID_IDWriteFactory
) ||
738 IsEqualIID(riid
, &IID_IUnknown
))
741 IDWriteFactory7_AddRef(iface
);
747 return E_NOINTERFACE
;
750 static ULONG WINAPI
dwritefactory_AddRef(IDWriteFactory7
*iface
)
752 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
753 ULONG refcount
= InterlockedIncrement(&factory
->refcount
);
755 TRACE("%p, refcount %u.\n", iface
, refcount
);
760 static ULONG WINAPI
dwritefactory_Release(IDWriteFactory7
*iface
)
762 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
763 ULONG refcount
= InterlockedDecrement(&factory
->refcount
);
765 TRACE("%p, refcount %u.\n", iface
, refcount
);
768 release_dwritefactory(factory
);
773 static HRESULT WINAPI
dwritefactory_GetSystemFontCollection(IDWriteFactory7
*iface
,
774 IDWriteFontCollection
**collection
, BOOL check_for_updates
)
776 return IDWriteFactory5_GetSystemFontCollection((IDWriteFactory5
*)iface
, FALSE
, (IDWriteFontCollection1
**)collection
,
780 static HRESULT WINAPI
dwritefactory_CreateCustomFontCollection(IDWriteFactory7
*iface
,
781 IDWriteFontCollectionLoader
*loader
, void const *key
, UINT32 key_size
, IDWriteFontCollection
**collection
)
783 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
784 IDWriteFontFileEnumerator
*enumerator
;
785 struct collectionloader
*found
;
788 TRACE("%p, %p, %p, %u, %p.\n", iface
, loader
, key
, key_size
, collection
);
795 found
= factory_get_collection_loader(factory
, loader
);
799 hr
= IDWriteFontCollectionLoader_CreateEnumeratorFromKey(found
->loader
, (IDWriteFactory
*)iface
,
800 key
, key_size
, &enumerator
);
804 hr
= create_font_collection(iface
, enumerator
, FALSE
, (IDWriteFontCollection3
**)collection
);
805 IDWriteFontFileEnumerator_Release(enumerator
);
809 static HRESULT WINAPI
dwritefactory_RegisterFontCollectionLoader(IDWriteFactory7
*iface
,
810 IDWriteFontCollectionLoader
*loader
)
812 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
813 struct collectionloader
*entry
;
815 TRACE("%p, %p.\n", iface
, loader
);
820 if (factory_get_collection_loader(factory
, loader
))
821 return DWRITE_E_ALREADYREGISTERED
;
823 entry
= heap_alloc(sizeof(*entry
));
825 return E_OUTOFMEMORY
;
827 entry
->loader
= loader
;
828 IDWriteFontCollectionLoader_AddRef(loader
);
829 list_add_tail(&factory
->collection_loaders
, &entry
->entry
);
834 static HRESULT WINAPI
dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory7
*iface
,
835 IDWriteFontCollectionLoader
*loader
)
837 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
838 struct collectionloader
*found
;
840 TRACE("%p, %p.\n", iface
, loader
);
845 found
= factory_get_collection_loader(factory
, loader
);
849 IDWriteFontCollectionLoader_Release(found
->loader
);
850 list_remove(&found
->entry
);
856 static HRESULT WINAPI
dwritefactory_CreateFontFileReference(IDWriteFactory7
*iface
,
857 WCHAR
const *path
, FILETIME
const *writetime
, IDWriteFontFile
**font_file
)
859 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
864 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_w(path
), writetime
, font_file
);
868 /* Get a reference key in local file loader format. */
869 hr
= get_local_refkey(path
, writetime
, &key
, &key_size
);
873 hr
= create_font_file(factory
->localfontfileloader
, key
, key_size
, font_file
);
879 static HRESULT WINAPI
dwritefactory_CreateCustomFontFileReference(IDWriteFactory7
*iface
,
880 void const *reference_key
, UINT32 key_size
, IDWriteFontFileLoader
*loader
, IDWriteFontFile
**font_file
)
882 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
884 TRACE("%p, %p, %u, %p, %p.\n", iface
, reference_key
, key_size
, loader
, font_file
);
888 if (!loader
|| !(factory_get_file_loader(factory
, loader
) || factory
->localfontfileloader
== loader
))
891 return create_font_file(loader
, reference_key
, key_size
, font_file
);
894 void factory_lock(IDWriteFactory7
*iface
)
896 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
897 EnterCriticalSection(&factory
->cs
);
900 void factory_unlock(IDWriteFactory7
*iface
)
902 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
903 LeaveCriticalSection(&factory
->cs
);
906 HRESULT
factory_get_cached_fontface(IDWriteFactory7
*iface
, IDWriteFontFile
* const *font_files
, UINT32 index
,
907 DWRITE_FONT_SIMULATIONS simulations
, struct list
**cached_list
, REFIID riid
, void **obj
)
909 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
910 struct fontfacecached
*cached
;
911 IDWriteFontFileLoader
*loader
;
912 struct list
*fontfaces
;
920 hr
= IDWriteFontFile_GetReferenceKey(*font_files
, &key
, &key_size
);
924 hr
= IDWriteFontFile_GetLoader(*font_files
, &loader
);
928 if (loader
== factory
->localfontfileloader
) {
929 fontfaces
= &factory
->localfontfaces
;
930 IDWriteFontFileLoader_Release(loader
);
933 struct fileloader
*fileloader
= factory_get_file_loader(factory
, loader
);
934 IDWriteFontFileLoader_Release(loader
);
937 fontfaces
= &fileloader
->fontfaces
;
940 *cached_list
= fontfaces
;
942 EnterCriticalSection(&factory
->cs
);
944 /* search through cache list */
945 LIST_FOR_EACH_ENTRY(cached
, fontfaces
, struct fontfacecached
, entry
) {
946 UINT32 cached_key_size
, count
= 1, cached_face_index
;
947 DWRITE_FONT_SIMULATIONS cached_simulations
;
948 const void *cached_key
;
949 IDWriteFontFile
*file
;
951 cached_face_index
= IDWriteFontFace5_GetIndex(cached
->fontface
);
952 cached_simulations
= IDWriteFontFace5_GetSimulations(cached
->fontface
);
955 if (cached_face_index
!= index
|| cached_simulations
!= simulations
)
958 hr
= IDWriteFontFace5_GetFiles(cached
->fontface
, &count
, &file
);
962 hr
= IDWriteFontFile_GetReferenceKey(file
, &cached_key
, &cached_key_size
);
963 IDWriteFontFile_Release(file
);
967 if (cached_key_size
== key_size
&& !memcmp(cached_key
, key
, key_size
))
969 if (FAILED(hr
= IDWriteFontFace5_QueryInterface(cached
->fontface
, riid
, obj
)))
970 WARN("Failed to get %s from fontface, hr %#x.\n", debugstr_guid(riid
), hr
);
972 TRACE("returning cached fontface %p\n", cached
->fontface
);
977 LeaveCriticalSection(&factory
->cs
);
979 return *obj
? S_OK
: S_FALSE
;
982 struct fontfacecached
*factory_cache_fontface(IDWriteFactory7
*iface
, struct list
*fontfaces
,
983 IDWriteFontFace5
*fontface
)
985 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
986 struct fontfacecached
*cached
;
988 /* new cache entry */
989 cached
= heap_alloc(sizeof(*cached
));
993 cached
->fontface
= fontface
;
994 EnterCriticalSection(&factory
->cs
);
995 list_add_tail(fontfaces
, &cached
->entry
);
996 LeaveCriticalSection(&factory
->cs
);
1001 static HRESULT WINAPI
dwritefactory_CreateFontFace(IDWriteFactory7
*iface
, DWRITE_FONT_FACE_TYPE req_facetype
,
1002 UINT32 files_number
, IDWriteFontFile
* const* font_files
, UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
,
1003 IDWriteFontFace
**fontface
)
1005 DWRITE_FONT_FILE_TYPE file_type
;
1006 DWRITE_FONT_FACE_TYPE face_type
;
1007 IDWriteFontFileStream
*stream
;
1008 struct fontface_desc desc
;
1009 struct list
*fontfaces
;
1014 TRACE("%p, %d, %u, %p, %u, %#x, %p.\n", iface
, req_facetype
, files_number
, font_files
, index
,
1015 simulations
, fontface
);
1019 if (!is_face_type_supported(req_facetype
))
1020 return E_INVALIDARG
;
1022 if (req_facetype
!= DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION
&& index
)
1023 return E_INVALIDARG
;
1025 if (!is_simulation_valid(simulations
))
1026 return E_INVALIDARG
;
1028 if (FAILED(hr
= get_filestream_from_file(*font_files
, &stream
)))
1031 /* check actual file/face type */
1032 is_supported
= FALSE
;
1033 face_type
= DWRITE_FONT_FACE_TYPE_UNKNOWN
;
1034 hr
= opentype_analyze_font(stream
, &is_supported
, &file_type
, &face_type
, &face_count
);
1038 if (!is_supported
) {
1043 if (face_type
!= req_facetype
) {
1044 hr
= DWRITE_E_FILEFORMAT
;
1048 hr
= factory_get_cached_fontface(iface
, font_files
, index
, simulations
, &fontfaces
,
1049 &IID_IDWriteFontFace
, (void **)fontface
);
1053 desc
.factory
= iface
;
1054 desc
.face_type
= req_facetype
;
1055 desc
.file
= *font_files
;
1056 desc
.stream
= stream
;
1058 desc
.simulations
= simulations
;
1059 desc
.font_data
= NULL
;
1060 hr
= create_fontface(&desc
, fontfaces
, (IDWriteFontFace5
**)fontface
);
1063 IDWriteFontFileStream_Release(stream
);
1067 static HRESULT WINAPI
dwritefactory_CreateRenderingParams(IDWriteFactory7
*iface
, IDWriteRenderingParams
**params
)
1072 TRACE("%p, %p.\n", iface
, params
);
1075 monitor
= MonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
1076 return IDWriteFactory7_CreateMonitorRenderingParams(iface
, monitor
, params
);
1079 static HRESULT WINAPI
dwritefactory_CreateMonitorRenderingParams(IDWriteFactory7
*iface
, HMONITOR monitor
,
1080 IDWriteRenderingParams
**params
)
1082 IDWriteRenderingParams3
*params3
;
1083 static int fixme_once
= 0;
1086 TRACE("%p, %p, %p.\n", iface
, monitor
, params
);
1089 FIXME("(%p): monitor setting ignored\n", monitor
);
1091 /* FIXME: use actual per-monitor gamma factor */
1092 hr
= IDWriteFactory7_CreateCustomRenderingParams(iface
, 2.0f
, 0.0f
, 1.0f
, 0.0f
, DWRITE_PIXEL_GEOMETRY_FLAT
,
1093 DWRITE_RENDERING_MODE1_DEFAULT
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1094 *params
= (IDWriteRenderingParams
*)params3
;
1098 static HRESULT WINAPI
dwritefactory_CreateCustomRenderingParams(IDWriteFactory7
*iface
, FLOAT gamma
,
1099 FLOAT enhancedContrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
,
1100 IDWriteRenderingParams
**params
)
1102 IDWriteRenderingParams3
*params3
;
1105 TRACE("%p, %.8e, %.8e, %.8e, %d, %d, %p.\n", iface
, gamma
, enhancedContrast
, cleartype_level
, geometry
, mode
, params
);
1107 if ((UINT32
)mode
> DWRITE_RENDERING_MODE_OUTLINE
) {
1109 return E_INVALIDARG
;
1112 hr
= IDWriteFactory7_CreateCustomRenderingParams(iface
, gamma
, enhancedContrast
, 1.0f
, cleartype_level
, geometry
,
1113 (DWRITE_RENDERING_MODE1
)mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1114 *params
= (IDWriteRenderingParams
*)params3
;
1118 static HRESULT WINAPI
dwritefactory_RegisterFontFileLoader(IDWriteFactory7
*iface
, IDWriteFontFileLoader
*loader
)
1120 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1121 struct fileloader
*entry
;
1123 TRACE("%p, %p.\n", iface
, loader
);
1126 return E_INVALIDARG
;
1128 if (factory_get_file_loader(factory
, loader
))
1129 return DWRITE_E_ALREADYREGISTERED
;
1131 entry
= heap_alloc(sizeof(*entry
));
1133 return E_OUTOFMEMORY
;
1135 entry
->loader
= loader
;
1136 list_init(&entry
->fontfaces
);
1137 IDWriteFontFileLoader_AddRef(loader
);
1138 list_add_tail(&factory
->file_loaders
, &entry
->entry
);
1143 static HRESULT WINAPI
dwritefactory_UnregisterFontFileLoader(IDWriteFactory7
*iface
, IDWriteFontFileLoader
*loader
)
1145 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1146 struct fileloader
*found
;
1148 TRACE("%p, %p.\n", iface
, loader
);
1151 return E_INVALIDARG
;
1153 found
= factory_get_file_loader(factory
, loader
);
1155 return E_INVALIDARG
;
1157 release_fileloader(found
);
1161 static HRESULT WINAPI
dwritefactory_CreateTextFormat(IDWriteFactory7
*iface
, WCHAR
const* family_name
,
1162 IDWriteFontCollection
*collection
, DWRITE_FONT_WEIGHT weight
, DWRITE_FONT_STYLE style
,
1163 DWRITE_FONT_STRETCH stretch
, FLOAT size
, WCHAR
const *locale
, IDWriteTextFormat
**format
)
1165 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1168 TRACE("%p, %s, %p, %d, %d, %d, %.8e, %s, %p.\n", iface
, debugstr_w(family_name
), collection
, weight
, style
, stretch
,
1169 size
, debugstr_w(locale
), format
);
1172 IDWriteFontCollection_AddRef(collection
);
1174 collection
= (IDWriteFontCollection
*)factory_get_system_collection(factory
);
1181 hr
= create_textformat(family_name
, collection
, weight
, style
, stretch
, size
, locale
, format
);
1182 IDWriteFontCollection_Release(collection
);
1186 static HRESULT WINAPI
dwritefactory_CreateTypography(IDWriteFactory7
*iface
, IDWriteTypography
**typography
)
1188 TRACE("%p, %p.\n", iface
, typography
);
1190 return create_typography(typography
);
1193 static HRESULT WINAPI
dwritefactory_GetGdiInterop(IDWriteFactory7
*iface
, IDWriteGdiInterop
**gdi_interop
)
1195 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1198 TRACE("%p, %p.\n", iface
, gdi_interop
);
1200 if (factory
->gdiinterop
)
1201 IDWriteGdiInterop1_AddRef(factory
->gdiinterop
);
1203 hr
= create_gdiinterop(iface
, &factory
->gdiinterop
);
1205 *gdi_interop
= (IDWriteGdiInterop
*)factory
->gdiinterop
;
1210 static HRESULT WINAPI
dwritefactory_CreateTextLayout(IDWriteFactory7
*iface
, WCHAR
const* string
,
1211 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, IDWriteTextLayout
**layout
)
1213 struct textlayout_desc desc
;
1215 TRACE("%p, %s:%u, %p, %.8e, %.8e, %p.\n", iface
, debugstr_wn(string
, length
), length
, format
, max_width
, max_height
, layout
);
1217 desc
.factory
= iface
;
1218 desc
.string
= string
;
1219 desc
.length
= length
;
1220 desc
.format
= format
;
1221 desc
.max_width
= max_width
;
1222 desc
.max_height
= max_height
;
1223 desc
.is_gdi_compatible
= FALSE
;
1225 desc
.transform
= NULL
;
1226 desc
.use_gdi_natural
= FALSE
;
1227 return create_textlayout(&desc
, layout
);
1230 static HRESULT WINAPI
dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory7
*iface
, WCHAR
const* string
,
1231 UINT32 length
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, FLOAT pixels_per_dip
,
1232 DWRITE_MATRIX
const* transform
, BOOL use_gdi_natural
, IDWriteTextLayout
**layout
)
1234 struct textlayout_desc desc
;
1236 TRACE("%p, %s:%u, %p, %.8e, %.8e, %.8e, %p, %d, %p.\n", iface
, debugstr_wn(string
, length
), length
, format
,
1237 max_width
, max_height
, pixels_per_dip
, transform
, use_gdi_natural
, layout
);
1239 desc
.factory
= iface
;
1240 desc
.string
= string
;
1241 desc
.length
= length
;
1242 desc
.format
= format
;
1243 desc
.max_width
= max_width
;
1244 desc
.max_height
= max_height
;
1245 desc
.is_gdi_compatible
= TRUE
;
1246 desc
.ppdip
= pixels_per_dip
;
1247 desc
.transform
= transform
;
1248 desc
.use_gdi_natural
= use_gdi_natural
;
1249 return create_textlayout(&desc
, layout
);
1252 static HRESULT WINAPI
dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory7
*iface
, IDWriteTextFormat
*format
,
1253 IDWriteInlineObject
**trimming_sign
)
1255 TRACE("%p, %p, %p.\n", iface
, format
, trimming_sign
);
1257 return create_trimmingsign(iface
, format
, trimming_sign
);
1260 static HRESULT WINAPI
dwritefactory_CreateTextAnalyzer(IDWriteFactory7
*iface
, IDWriteTextAnalyzer
**analyzer
)
1262 TRACE("%p, %p.\n", iface
, analyzer
);
1264 *analyzer
= (IDWriteTextAnalyzer
*)get_text_analyzer();
1269 static HRESULT WINAPI
dwritefactory_CreateNumberSubstitution(IDWriteFactory7
*iface
,
1270 DWRITE_NUMBER_SUBSTITUTION_METHOD method
, WCHAR
const* locale
, BOOL ignore_user_override
,
1271 IDWriteNumberSubstitution
**substitution
)
1273 TRACE("%p, %d, %s, %d, %p.\n", iface
, method
, debugstr_w(locale
), ignore_user_override
, substitution
);
1275 return create_numbersubstitution(method
, locale
, ignore_user_override
, substitution
);
1278 static inline void dwrite_matrix_multiply(DWRITE_MATRIX
*a
, const DWRITE_MATRIX
*b
)
1280 DWRITE_MATRIX tmp
= *a
;
1282 a
->m11
= tmp
.m11
* b
->m11
+ tmp
.m12
* b
->m21
;
1283 a
->m12
= tmp
.m11
* b
->m12
+ tmp
.m12
* b
->m22
;
1284 a
->m21
= tmp
.m21
* b
->m11
+ tmp
.m22
* b
->m21
;
1285 a
->m22
= tmp
.m21
* b
->m12
+ tmp
.m22
* b
->m22
;
1286 a
->dx
= tmp
.dx
* b
->m11
+ tmp
.dy
* b
->m21
+ b
->dx
;
1287 a
->dy
= tmp
.dy
* b
->m12
+ tmp
.dy
* b
->m22
+ b
->dx
;
1290 static HRESULT WINAPI
dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory7
*iface
, DWRITE_GLYPH_RUN
const *run
,
1291 FLOAT ppdip
, DWRITE_MATRIX
const* transform
, DWRITE_RENDERING_MODE rendering_mode
,
1292 DWRITE_MEASURING_MODE measuring_mode
, FLOAT originX
, FLOAT originY
, IDWriteGlyphRunAnalysis
**analysis
)
1294 struct glyphrunanalysis_desc desc
;
1295 DWRITE_MATRIX m
, scale
= { 0 };
1297 TRACE("%p, %p, %.8e, %p, %d, %d, %.8e, %.8e, %p.\n", iface
, run
, ppdip
, transform
, rendering_mode
,
1298 measuring_mode
, originX
, originY
, analysis
);
1300 if (ppdip
<= 0.0f
) {
1302 return E_INVALIDARG
;
1305 m
= transform
? *transform
: identity
;
1308 dwrite_matrix_multiply(&m
, &scale
);
1310 desc
.transform
= &m
;
1311 desc
.rendering_mode
= (DWRITE_RENDERING_MODE1
)rendering_mode
;
1312 desc
.measuring_mode
= measuring_mode
;
1313 desc
.gridfit_mode
= DWRITE_GRID_FIT_MODE_DEFAULT
;
1314 desc
.aa_mode
= DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE
;
1315 desc
.origin
.x
= originX
;
1316 desc
.origin
.y
= originY
;
1317 return create_glyphrunanalysis(&desc
, analysis
);
1320 static HRESULT WINAPI
dwritefactory1_GetEudcFontCollection(IDWriteFactory7
*iface
, IDWriteFontCollection
**collection
,
1321 BOOL check_for_updates
)
1323 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1326 TRACE("%p, %p, %d.\n", iface
, collection
, check_for_updates
);
1328 if (check_for_updates
)
1329 FIXME("checking for eudc updates not implemented\n");
1331 if (factory
->eudc_collection
)
1332 IDWriteFontCollection1_AddRef(factory
->eudc_collection
);
1334 IDWriteFontCollection3
*eudc_collection
;
1336 if (FAILED(hr
= get_eudc_fontcollection(iface
, &eudc_collection
)))
1339 WARN("Failed to get EUDC collection, hr %#x.\n", hr
);
1343 if (InterlockedCompareExchangePointer((void **)&factory
->eudc_collection
, eudc_collection
, NULL
))
1344 IDWriteFontCollection3_Release(eudc_collection
);
1347 *collection
= (IDWriteFontCollection
*)factory
->eudc_collection
;
1352 static HRESULT WINAPI
dwritefactory1_CreateCustomRenderingParams(IDWriteFactory7
*iface
, FLOAT gamma
,
1353 FLOAT enhcontrast
, FLOAT enhcontrast_grayscale
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
,
1354 DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams1
** params
)
1356 IDWriteRenderingParams3
*params3
;
1359 TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %p.\n", iface
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1360 cleartype_level
, geometry
, mode
, params
);
1362 if ((UINT32
)mode
> DWRITE_RENDERING_MODE_OUTLINE
) {
1364 return E_INVALIDARG
;
1367 hr
= IDWriteFactory7_CreateCustomRenderingParams(iface
, gamma
, enhcontrast
, enhcontrast_grayscale
,
1368 cleartype_level
, geometry
, (DWRITE_RENDERING_MODE1
)mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1369 *params
= (IDWriteRenderingParams1
*)params3
;
1373 static HRESULT WINAPI
dwritefactory2_GetSystemFontFallback(IDWriteFactory7
*iface
, IDWriteFontFallback
**fallback
)
1375 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1377 TRACE("%p, %p.\n", iface
, fallback
);
1381 if (!factory
->fallback
)
1383 HRESULT hr
= create_system_fontfallback(iface
, &factory
->fallback
);
1388 *fallback
= (IDWriteFontFallback
*)factory
->fallback
;
1389 IDWriteFontFallback_AddRef(*fallback
);
1393 static HRESULT WINAPI
dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory7
*iface
,
1394 IDWriteFontFallbackBuilder
**fallbackbuilder
)
1396 TRACE("%p, %p.\n", iface
, fallbackbuilder
);
1398 return create_fontfallback_builder(iface
, fallbackbuilder
);
1401 static HRESULT WINAPI
dwritefactory2_TranslateColorGlyphRun(IDWriteFactory7
*iface
, FLOAT originX
, FLOAT originY
,
1402 const DWRITE_GLYPH_RUN
*run
, const DWRITE_GLYPH_RUN_DESCRIPTION
*rundescr
, DWRITE_MEASURING_MODE mode
,
1403 const DWRITE_MATRIX
*transform
, UINT32 palette
, IDWriteColorGlyphRunEnumerator
**colorlayers
)
1405 TRACE("%p, %.8e, %.8e, %p, %p, %d, %p, %u, %p.\n", iface
, originX
, originY
, run
, rundescr
, mode
,
1406 transform
, palette
, colorlayers
);
1408 return create_colorglyphenum(originX
, originY
, run
, rundescr
, mode
, transform
, palette
, colorlayers
);
1411 static HRESULT WINAPI
dwritefactory2_CreateCustomRenderingParams(IDWriteFactory7
*iface
, FLOAT gamma
, FLOAT contrast
,
1412 FLOAT grayscalecontrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
,
1413 DWRITE_GRID_FIT_MODE gridfit
, IDWriteRenderingParams2
**params
)
1415 IDWriteRenderingParams3
*params3
;
1418 TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %d, %p.\n", iface
, gamma
, contrast
, grayscalecontrast
, cleartype_level
,
1419 geometry
, mode
, gridfit
, params
);
1421 if ((UINT32
)mode
> DWRITE_RENDERING_MODE_OUTLINE
) {
1423 return E_INVALIDARG
;
1426 hr
= IDWriteFactory7_CreateCustomRenderingParams(iface
, gamma
, contrast
, grayscalecontrast
,
1427 cleartype_level
, geometry
, (DWRITE_RENDERING_MODE1
)mode
, DWRITE_GRID_FIT_MODE_DEFAULT
, ¶ms3
);
1428 *params
= (IDWriteRenderingParams2
*)params3
;
1432 static HRESULT
factory_create_glyphrun_analysis(const DWRITE_GLYPH_RUN
*run
, const DWRITE_MATRIX
*transform
,
1433 DWRITE_RENDERING_MODE1 rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
, DWRITE_GRID_FIT_MODE gridfit_mode
,
1434 DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
, IDWriteGlyphRunAnalysis
**analysis
)
1436 struct glyphrunanalysis_desc desc
;
1439 desc
.transform
= transform
;
1440 desc
.rendering_mode
= rendering_mode
;
1441 desc
.measuring_mode
= measuring_mode
;
1442 desc
.gridfit_mode
= gridfit_mode
;
1443 desc
.aa_mode
= aa_mode
;
1444 desc
.origin
.x
= originX
;
1445 desc
.origin
.y
= originY
;
1446 return create_glyphrunanalysis(&desc
, analysis
);
1449 static HRESULT WINAPI
dwritefactory2_CreateGlyphRunAnalysis(IDWriteFactory7
*iface
, const DWRITE_GLYPH_RUN
*run
,
1450 const DWRITE_MATRIX
*transform
, DWRITE_RENDERING_MODE rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1451 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1452 IDWriteGlyphRunAnalysis
**analysis
)
1454 TRACE("%p, %p, %p, %d, %d, %d, %d, %.8e, %.8e, %p.\n", iface
, run
, transform
, rendering_mode
, measuring_mode
,
1455 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1457 return factory_create_glyphrun_analysis(run
, transform
, (DWRITE_RENDERING_MODE1
)rendering_mode
, measuring_mode
,
1458 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1461 static HRESULT WINAPI
dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory7
*iface
, DWRITE_GLYPH_RUN
const *run
,
1462 DWRITE_MATRIX
const *transform
, DWRITE_RENDERING_MODE1 rendering_mode
, DWRITE_MEASURING_MODE measuring_mode
,
1463 DWRITE_GRID_FIT_MODE gridfit_mode
, DWRITE_TEXT_ANTIALIAS_MODE aa_mode
, FLOAT originX
, FLOAT originY
,
1464 IDWriteGlyphRunAnalysis
**analysis
)
1466 TRACE("%p, %p, %p, %d, %d, %d, %d, %.8e, %.8e, %p.\n", iface
, run
, transform
, rendering_mode
, measuring_mode
,
1467 gridfit_mode
, aa_mode
, originX
, originY
, analysis
);
1469 return factory_create_glyphrun_analysis(run
, transform
, rendering_mode
, measuring_mode
, gridfit_mode
,
1470 aa_mode
, originX
, originY
, analysis
);
1473 static HRESULT WINAPI
dwritefactory3_CreateCustomRenderingParams(IDWriteFactory7
*iface
, FLOAT gamma
, FLOAT contrast
,
1474 FLOAT grayscale_contrast
, FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY pixel_geometry
,
1475 DWRITE_RENDERING_MODE1 rendering_mode
, DWRITE_GRID_FIT_MODE gridfit_mode
, IDWriteRenderingParams3
**params
)
1477 TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %d, %p.\n", iface
, gamma
, contrast
, grayscale_contrast
, cleartype_level
,
1478 pixel_geometry
, rendering_mode
, gridfit_mode
, params
);
1480 return create_renderingparams(gamma
, contrast
, grayscale_contrast
, cleartype_level
, pixel_geometry
, rendering_mode
,
1481 gridfit_mode
, params
);
1484 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference_(IDWriteFactory7
*iface
, IDWriteFontFile
*file
,
1485 UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
, IDWriteFontFaceReference
**reference
)
1487 TRACE("%p, %p, %u, %x, %p.\n", iface
, file
, index
, simulations
, reference
);
1489 return create_fontfacereference(iface
, file
, index
, simulations
, NULL
, 0, (IDWriteFontFaceReference1
**)reference
);
1492 static HRESULT WINAPI
dwritefactory3_CreateFontFaceReference(IDWriteFactory7
*iface
, WCHAR
const *path
,
1493 FILETIME
const *writetime
, UINT32 index
, DWRITE_FONT_SIMULATIONS simulations
,
1494 IDWriteFontFaceReference
**reference
)
1496 IDWriteFontFile
*file
;
1499 TRACE("%p, %s, %p, %u, %#x, %p.\n", iface
, debugstr_w(path
), writetime
, index
, simulations
, reference
);
1501 hr
= IDWriteFactory7_CreateFontFileReference(iface
, path
, writetime
, &file
);
1508 hr
= create_fontfacereference(iface
, file
, index
, simulations
, NULL
, 0, (IDWriteFontFaceReference1
**)reference
);
1509 IDWriteFontFile_Release(file
);
1513 static HRESULT
create_system_path_list(WCHAR
***ret
, unsigned int *ret_count
)
1515 unsigned int index
= 0, value_size
, name_count
, max_name_count
, type
, data_size
;
1516 WCHAR
**paths
= NULL
, *name
, *value
= NULL
;
1517 size_t capacity
= 0, count
= 0;
1521 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE
, "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
1522 0, GENERIC_READ
, &hkey
))
1524 return E_UNEXPECTED
;
1527 value_size
= MAX_PATH
* sizeof(*value
);
1528 value
= heap_alloc(value_size
);
1530 max_name_count
= MAX_PATH
;
1531 name
= heap_alloc(max_name_count
* sizeof(*name
));
1537 value_size
= MAX_PATH
* sizeof(*value
);
1538 value
= heap_alloc(value_size
);
1543 name_count
= max_name_count
;
1544 data_size
= value_size
- sizeof(*value
);
1546 r
= RegEnumValueW(hkey
, index
, name
, &name_count
, NULL
, &type
, (BYTE
*)value
, &data_size
);
1547 if (r
== ERROR_MORE_DATA
)
1549 if (name_count
>= max_name_count
)
1551 max_name_count
*= 2;
1553 name
= heap_alloc(max_name_count
* sizeof(*name
));
1556 if (data_size
> value_size
- sizeof(*value
))
1559 value_size
= max(data_size
+ sizeof(*value
), value_size
* 2);
1560 value
= heap_alloc(value_size
);
1563 } while (r
== ERROR_MORE_DATA
);
1565 if (r
!= ERROR_SUCCESS
)
1568 value
[data_size
/ sizeof(*value
)] = 0;
1569 if (type
== REG_SZ
&& *name
!= '@')
1571 if (dwrite_array_reserve((void **)&paths
, &capacity
, count
+ 1, sizeof(*paths
)))
1573 if (!wcschr(value
, '\\'))
1577 ptrW
= heap_alloc((MAX_PATH
+ wcslen(value
)) * sizeof(WCHAR
));
1578 GetWindowsDirectoryW(ptrW
, MAX_PATH
);
1579 wcscat(ptrW
, L
"\\fonts\\");
1580 wcscat(ptrW
, value
);
1586 paths
[count
++] = value
;
1603 static int __cdecl
create_system_fontset_compare(const void *left
, const void *right
)
1605 const WCHAR
*_l
= *(WCHAR
**)left
, *_r
= *(WCHAR
**)right
;
1606 return wcsicmp(_l
, _r
);
1609 static HRESULT
create_system_fontset(IDWriteFactory7
*factory
, REFIID riid
, void **obj
)
1611 IDWriteFontSetBuilder2
*builder
;
1612 IDWriteFontSet
*fontset
;
1613 unsigned int i
, j
, count
;
1619 if (FAILED(hr
= create_fontset_builder(factory
, &builder
))) return hr
;
1621 if (SUCCEEDED(hr
= create_system_path_list(&paths
, &count
)))
1623 /* Sort, skip duplicates. */
1625 qsort(paths
, count
, sizeof(*paths
), create_system_fontset_compare
);
1627 for (i
= 0, j
= 0; i
< count
; ++i
)
1629 if (i
!= j
&& !wcsicmp(paths
[i
], paths
[j
])) continue;
1631 if (FAILED(hr
= IDWriteFontSetBuilder2_AddFontFile(builder
, paths
[i
])) && hr
!= DWRITE_E_FILEFORMAT
)
1632 WARN("Failed to add font file, hr %#x, path %s.\n", hr
, debugstr_w(paths
[i
]));
1637 for (i
= 0; i
< count
; ++i
)
1638 heap_free(paths
[i
]);
1642 if (SUCCEEDED(hr
= IDWriteFontSetBuilder2_CreateFontSet(builder
, &fontset
)))
1644 hr
= IDWriteFontSet_QueryInterface(fontset
, riid
, obj
);
1645 IDWriteFontSet_Release(fontset
);
1648 IDWriteFontSetBuilder2_Release(builder
);
1653 static HRESULT WINAPI
dwritefactory3_GetSystemFontSet(IDWriteFactory7
*iface
, IDWriteFontSet
**fontset
)
1655 TRACE("%p, %p.\n", iface
, fontset
);
1657 return create_system_fontset(iface
, &IID_IDWriteFontSet
, (void **)fontset
);
1660 static HRESULT WINAPI
dwritefactory3_CreateFontSetBuilder(IDWriteFactory7
*iface
, IDWriteFontSetBuilder
**builder
)
1662 TRACE("%p, %p.\n", iface
, builder
);
1664 return create_fontset_builder(iface
, (IDWriteFontSetBuilder2
**)builder
);
1667 static HRESULT WINAPI
dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory7
*iface
, IDWriteFontSet
*fontset
,
1668 IDWriteFontCollection1
**collection
)
1670 FIXME("%p, %p, %p: stub\n", iface
, fontset
, collection
);
1675 static HRESULT WINAPI
dwritefactory3_GetSystemFontCollection(IDWriteFactory7
*iface
, BOOL include_downloadable
,
1676 IDWriteFontCollection1
**collection
, BOOL check_for_updates
)
1678 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
1680 TRACE("%p, %d, %p, %d.\n", iface
, include_downloadable
, collection
, check_for_updates
);
1682 if (include_downloadable
)
1683 FIXME("remote fonts are not supported\n");
1685 if (check_for_updates
)
1686 FIXME("checking for system font updates not implemented\n");
1688 *collection
= factory_get_system_collection(factory
);
1690 return *collection
? S_OK
: E_FAIL
;
1693 static HRESULT WINAPI
dwritefactory3_GetFontDownloadQueue(IDWriteFactory7
*iface
, IDWriteFontDownloadQueue
**queue
)
1695 FIXME("%p, %p: stub\n", iface
, queue
);
1700 static HRESULT WINAPI
dwritefactory4_TranslateColorGlyphRun(IDWriteFactory7
*iface
, D2D1_POINT_2F baseline_origin
,
1701 DWRITE_GLYPH_RUN
const *run
, DWRITE_GLYPH_RUN_DESCRIPTION
const *run_desc
,
1702 DWRITE_GLYPH_IMAGE_FORMATS desired_formats
, DWRITE_MEASURING_MODE measuring_mode
, DWRITE_MATRIX
const *transform
,
1703 UINT32 palette
, IDWriteColorGlyphRunEnumerator1
**layers
)
1705 FIXME("%p, %p, %p, %u, %d, %p, %u, %p: stub\n", iface
, run
, run_desc
, desired_formats
, measuring_mode
,
1706 transform
, palette
, layers
);
1711 HRESULT
compute_glyph_origins(DWRITE_GLYPH_RUN
const *run
, DWRITE_MEASURING_MODE measuring_mode
,
1712 D2D1_POINT_2F baseline_origin
, DWRITE_MATRIX
const *transform
, D2D1_POINT_2F
*origins
)
1714 struct dwrite_fontface
*font_obj
;
1718 font_obj
= unsafe_impl_from_IDWriteFontFace(run
->fontFace
);
1720 for (i
= 0; i
< run
->glyphCount
; ++i
)
1722 origins
[i
] = baseline_origin
;
1724 if (run
->bidiLevel
& 1)
1726 advance
= fontface_get_scaled_design_advance(font_obj
, measuring_mode
, run
->fontEmSize
,
1727 1.0f
, transform
, run
->glyphIndices
[i
], run
->isSideways
);
1729 origins
[i
].x
-= advance
;
1731 if (run
->glyphOffsets
)
1733 origins
[i
].x
-= run
->glyphOffsets
[i
].advanceOffset
;
1734 origins
[i
].y
-= run
->glyphOffsets
[i
].ascenderOffset
;
1737 baseline_origin
.x
-= run
->glyphAdvances
? run
->glyphAdvances
[i
] : advance
;
1741 if (run
->glyphOffsets
)
1743 origins
[i
].x
+= run
->glyphOffsets
[i
].advanceOffset
;
1744 origins
[i
].y
-= run
->glyphOffsets
[i
].ascenderOffset
;
1747 baseline_origin
.x
+= run
->glyphAdvances
? run
->glyphAdvances
[i
] :
1748 fontface_get_scaled_design_advance(font_obj
, measuring_mode
, run
->fontEmSize
, 1.0f
, transform
,
1749 run
->glyphIndices
[i
], run
->isSideways
);
1757 static HRESULT WINAPI
dwritefactory4_ComputeGlyphOrigins_(IDWriteFactory7
*iface
, DWRITE_GLYPH_RUN
const *run
,
1758 D2D1_POINT_2F baseline_origin
, D2D1_POINT_2F
*origins
)
1760 TRACE("%p, %p, {%.8e,%.8e}, %p.\n", iface
, run
, baseline_origin
.x
, baseline_origin
.y
, origins
);
1762 return compute_glyph_origins(run
, DWRITE_MEASURING_MODE_NATURAL
, baseline_origin
, NULL
, origins
);
1765 static HRESULT WINAPI
dwritefactory4_ComputeGlyphOrigins(IDWriteFactory7
*iface
, DWRITE_GLYPH_RUN
const *run
,
1766 DWRITE_MEASURING_MODE measuring_mode
, D2D1_POINT_2F baseline_origin
, DWRITE_MATRIX
const *transform
,
1767 D2D1_POINT_2F
*origins
)
1769 TRACE("%p, %p, %d, {%.8e,%.8e}, %p, %p.\n", iface
, run
, measuring_mode
, baseline_origin
.x
, baseline_origin
.y
,
1770 transform
, origins
);
1772 return compute_glyph_origins(run
, measuring_mode
, baseline_origin
, transform
, origins
);
1775 static HRESULT WINAPI
dwritefactory5_CreateFontSetBuilder(IDWriteFactory7
*iface
, IDWriteFontSetBuilder1
**builder
)
1777 TRACE("%p, %p.\n", iface
, builder
);
1779 return create_fontset_builder(iface
, (IDWriteFontSetBuilder2
**)builder
);
1782 static HRESULT WINAPI
dwritefactory5_CreateInMemoryFontFileLoader(IDWriteFactory7
*iface
,
1783 IDWriteInMemoryFontFileLoader
**loader
)
1785 TRACE("%p, %p.\n", iface
, loader
);
1787 return create_inmemory_fileloader(loader
);
1790 static HRESULT WINAPI
dwritefactory5_CreateHttpFontFileLoader(IDWriteFactory7
*iface
, WCHAR
const *referrer_url
,
1791 WCHAR
const *extra_headers
, IDWriteRemoteFontFileLoader
**loader
)
1793 FIXME("%p, %s, %s, %p: stub\n", iface
, debugstr_w(referrer_url
), wine_dbgstr_w(extra_headers
), loader
);
1798 static DWRITE_CONTAINER_TYPE WINAPI
dwritefactory5_AnalyzeContainerType(IDWriteFactory7
*iface
, void const *data
,
1801 TRACE("%p, %p, %u.\n", iface
, data
, data_size
);
1803 return opentype_analyze_container_type(data
, data_size
);
1806 static HRESULT WINAPI
dwritefactory5_UnpackFontFile(IDWriteFactory7
*iface
, DWRITE_CONTAINER_TYPE container_type
, void const *data
,
1807 UINT32 data_size
, IDWriteFontFileStream
**stream
)
1809 FIXME("%p, %d, %p, %u, %p: stub\n", iface
, container_type
, data
, data_size
, stream
);
1814 static HRESULT WINAPI
dwritefactory6_CreateFontFaceReference(IDWriteFactory7
*iface
, IDWriteFontFile
*file
,
1815 UINT32 face_index
, DWRITE_FONT_SIMULATIONS simulations
, DWRITE_FONT_AXIS_VALUE
const *axis_values
,
1816 UINT32 axis_values_count
, IDWriteFontFaceReference1
**reference
)
1818 TRACE("%p, %p, %u, %#x, %p, %u, %p.\n", iface
, file
, face_index
, simulations
, axis_values
, axis_values_count
,
1821 return create_fontfacereference(iface
, file
, face_index
, simulations
, axis_values
, axis_values_count
, reference
);
1824 static HRESULT WINAPI
dwritefactory6_CreateFontResource(IDWriteFactory7
*iface
, IDWriteFontFile
*file
,
1825 UINT32 face_index
, IDWriteFontResource
**resource
)
1827 TRACE("%p, %p, %u, %p.\n", iface
, file
, face_index
, resource
);
1829 return create_font_resource(iface
, file
, face_index
, resource
);
1832 static HRESULT WINAPI
dwritefactory6_GetSystemFontSet(IDWriteFactory7
*iface
, BOOL include_downloadable
,
1833 IDWriteFontSet1
**fontset
)
1835 TRACE("%p, %d, %p.\n", iface
, include_downloadable
, fontset
);
1837 if (include_downloadable
)
1838 FIXME("Downloadable fonts are not supported.\n");
1840 return create_system_fontset(iface
, &IID_IDWriteFontSet1
, (void **)fontset
);
1843 static HRESULT WINAPI
dwritefactory6_GetSystemFontCollection(IDWriteFactory7
*iface
, BOOL include_downloadable
,
1844 DWRITE_FONT_FAMILY_MODEL family_model
, IDWriteFontCollection2
**collection
)
1846 FIXME("%p, %d, %d, %p.\n", iface
, include_downloadable
, family_model
, collection
);
1851 static HRESULT WINAPI
dwritefactory6_CreateFontCollectionFromFontSet(IDWriteFactory7
*iface
, IDWriteFontSet
*fontset
,
1852 DWRITE_FONT_FAMILY_MODEL family_model
, IDWriteFontCollection2
**collection
)
1854 FIXME("%p, %p, %d, %p.\n", iface
, fontset
, family_model
, collection
);
1859 static HRESULT WINAPI
dwritefactory6_CreateFontSetBuilder(IDWriteFactory7
*iface
, IDWriteFontSetBuilder2
**builder
)
1861 TRACE("%p, %p.\n", iface
, builder
);
1863 return create_fontset_builder(iface
, builder
);
1866 static HRESULT WINAPI
dwritefactory6_CreateTextFormat(IDWriteFactory7
*iface
, const WCHAR
*familyname
,
1867 IDWriteFontCollection
*collection
, DWRITE_FONT_AXIS_VALUE
const *axis_values
, UINT32 num_axis
,
1868 FLOAT fontsize
, const WCHAR
*localename
, IDWriteTextFormat3
**format
)
1870 FIXME("%p, %s, %p, %p, %u, %.8e, %s, %p.\n", iface
, debugstr_w(familyname
), collection
, axis_values
, num_axis
,
1871 fontsize
, debugstr_w(localename
), format
);
1876 static HRESULT WINAPI
dwritefactory7_GetSystemFontSet(IDWriteFactory7
*iface
, BOOL include_downloadable
,
1877 IDWriteFontSet2
**fontset
)
1879 TRACE("%p, %d, %p.\n", iface
, include_downloadable
, fontset
);
1881 if (include_downloadable
)
1882 FIXME("Downloadable fonts are not supported.\n");
1884 return create_system_fontset(iface
, &IID_IDWriteFontSet2
, (void **)fontset
);
1887 static HRESULT WINAPI
dwritefactory7_GetSystemFontCollection(IDWriteFactory7
*iface
, BOOL include_downloadable
,
1888 DWRITE_FONT_FAMILY_MODEL family_model
, IDWriteFontCollection3
**collection
)
1890 FIXME("%p, %d, %d, %p.\n", iface
, include_downloadable
, family_model
, collection
);
1895 static const IDWriteFactory7Vtbl dwritefactoryvtbl
=
1897 dwritefactory_QueryInterface
,
1898 dwritefactory_AddRef
,
1899 dwritefactory_Release
,
1900 dwritefactory_GetSystemFontCollection
,
1901 dwritefactory_CreateCustomFontCollection
,
1902 dwritefactory_RegisterFontCollectionLoader
,
1903 dwritefactory_UnregisterFontCollectionLoader
,
1904 dwritefactory_CreateFontFileReference
,
1905 dwritefactory_CreateCustomFontFileReference
,
1906 dwritefactory_CreateFontFace
,
1907 dwritefactory_CreateRenderingParams
,
1908 dwritefactory_CreateMonitorRenderingParams
,
1909 dwritefactory_CreateCustomRenderingParams
,
1910 dwritefactory_RegisterFontFileLoader
,
1911 dwritefactory_UnregisterFontFileLoader
,
1912 dwritefactory_CreateTextFormat
,
1913 dwritefactory_CreateTypography
,
1914 dwritefactory_GetGdiInterop
,
1915 dwritefactory_CreateTextLayout
,
1916 dwritefactory_CreateGdiCompatibleTextLayout
,
1917 dwritefactory_CreateEllipsisTrimmingSign
,
1918 dwritefactory_CreateTextAnalyzer
,
1919 dwritefactory_CreateNumberSubstitution
,
1920 dwritefactory_CreateGlyphRunAnalysis
,
1921 dwritefactory1_GetEudcFontCollection
,
1922 dwritefactory1_CreateCustomRenderingParams
,
1923 dwritefactory2_GetSystemFontFallback
,
1924 dwritefactory2_CreateFontFallbackBuilder
,
1925 dwritefactory2_TranslateColorGlyphRun
,
1926 dwritefactory2_CreateCustomRenderingParams
,
1927 dwritefactory2_CreateGlyphRunAnalysis
,
1928 dwritefactory3_CreateGlyphRunAnalysis
,
1929 dwritefactory3_CreateCustomRenderingParams
,
1930 dwritefactory3_CreateFontFaceReference_
,
1931 dwritefactory3_CreateFontFaceReference
,
1932 dwritefactory3_GetSystemFontSet
,
1933 dwritefactory3_CreateFontSetBuilder
,
1934 dwritefactory3_CreateFontCollectionFromFontSet
,
1935 dwritefactory3_GetSystemFontCollection
,
1936 dwritefactory3_GetFontDownloadQueue
,
1937 dwritefactory4_TranslateColorGlyphRun
,
1938 dwritefactory4_ComputeGlyphOrigins_
,
1939 dwritefactory4_ComputeGlyphOrigins
,
1940 dwritefactory5_CreateFontSetBuilder
,
1941 dwritefactory5_CreateInMemoryFontFileLoader
,
1942 dwritefactory5_CreateHttpFontFileLoader
,
1943 dwritefactory5_AnalyzeContainerType
,
1944 dwritefactory5_UnpackFontFile
,
1945 dwritefactory6_CreateFontFaceReference
,
1946 dwritefactory6_CreateFontResource
,
1947 dwritefactory6_GetSystemFontSet
,
1948 dwritefactory6_GetSystemFontCollection
,
1949 dwritefactory6_CreateFontCollectionFromFontSet
,
1950 dwritefactory6_CreateFontSetBuilder
,
1951 dwritefactory6_CreateTextFormat
,
1952 dwritefactory7_GetSystemFontSet
,
1953 dwritefactory7_GetSystemFontCollection
,
1956 static ULONG WINAPI
shareddwritefactory_AddRef(IDWriteFactory7
*iface
)
1958 TRACE("%p.\n", iface
);
1963 static ULONG WINAPI
shareddwritefactory_Release(IDWriteFactory7
*iface
)
1965 TRACE("%p.\n", iface
);
1970 static const IDWriteFactory7Vtbl shareddwritefactoryvtbl
=
1972 dwritefactory_QueryInterface
,
1973 shareddwritefactory_AddRef
,
1974 shareddwritefactory_Release
,
1975 dwritefactory_GetSystemFontCollection
,
1976 dwritefactory_CreateCustomFontCollection
,
1977 dwritefactory_RegisterFontCollectionLoader
,
1978 dwritefactory_UnregisterFontCollectionLoader
,
1979 dwritefactory_CreateFontFileReference
,
1980 dwritefactory_CreateCustomFontFileReference
,
1981 dwritefactory_CreateFontFace
,
1982 dwritefactory_CreateRenderingParams
,
1983 dwritefactory_CreateMonitorRenderingParams
,
1984 dwritefactory_CreateCustomRenderingParams
,
1985 dwritefactory_RegisterFontFileLoader
,
1986 dwritefactory_UnregisterFontFileLoader
,
1987 dwritefactory_CreateTextFormat
,
1988 dwritefactory_CreateTypography
,
1989 dwritefactory_GetGdiInterop
,
1990 dwritefactory_CreateTextLayout
,
1991 dwritefactory_CreateGdiCompatibleTextLayout
,
1992 dwritefactory_CreateEllipsisTrimmingSign
,
1993 dwritefactory_CreateTextAnalyzer
,
1994 dwritefactory_CreateNumberSubstitution
,
1995 dwritefactory_CreateGlyphRunAnalysis
,
1996 dwritefactory1_GetEudcFontCollection
,
1997 dwritefactory1_CreateCustomRenderingParams
,
1998 dwritefactory2_GetSystemFontFallback
,
1999 dwritefactory2_CreateFontFallbackBuilder
,
2000 dwritefactory2_TranslateColorGlyphRun
,
2001 dwritefactory2_CreateCustomRenderingParams
,
2002 dwritefactory2_CreateGlyphRunAnalysis
,
2003 dwritefactory3_CreateGlyphRunAnalysis
,
2004 dwritefactory3_CreateCustomRenderingParams
,
2005 dwritefactory3_CreateFontFaceReference_
,
2006 dwritefactory3_CreateFontFaceReference
,
2007 dwritefactory3_GetSystemFontSet
,
2008 dwritefactory3_CreateFontSetBuilder
,
2009 dwritefactory3_CreateFontCollectionFromFontSet
,
2010 dwritefactory3_GetSystemFontCollection
,
2011 dwritefactory3_GetFontDownloadQueue
,
2012 dwritefactory4_TranslateColorGlyphRun
,
2013 dwritefactory4_ComputeGlyphOrigins_
,
2014 dwritefactory4_ComputeGlyphOrigins
,
2015 dwritefactory5_CreateFontSetBuilder
,
2016 dwritefactory5_CreateInMemoryFontFileLoader
,
2017 dwritefactory5_CreateHttpFontFileLoader
,
2018 dwritefactory5_AnalyzeContainerType
,
2019 dwritefactory5_UnpackFontFile
,
2020 dwritefactory6_CreateFontFaceReference
,
2021 dwritefactory6_CreateFontResource
,
2022 dwritefactory6_GetSystemFontSet
,
2023 dwritefactory6_GetSystemFontCollection
,
2024 dwritefactory6_CreateFontCollectionFromFontSet
,
2025 dwritefactory6_CreateFontSetBuilder
,
2026 dwritefactory6_CreateTextFormat
,
2027 dwritefactory7_GetSystemFontSet
,
2028 dwritefactory7_GetSystemFontCollection
,
2031 static void init_dwritefactory(struct dwritefactory
*factory
, DWRITE_FACTORY_TYPE type
)
2033 factory
->IDWriteFactory7_iface
.lpVtbl
= type
== DWRITE_FACTORY_TYPE_SHARED
?
2034 &shareddwritefactoryvtbl
: &dwritefactoryvtbl
;
2035 factory
->refcount
= 1;
2036 factory
->localfontfileloader
= get_local_fontfile_loader();
2037 factory
->system_collection
= NULL
;
2038 factory
->eudc_collection
= NULL
;
2039 factory
->gdiinterop
= NULL
;
2040 factory
->fallback
= NULL
;
2042 list_init(&factory
->collection_loaders
);
2043 list_init(&factory
->file_loaders
);
2044 list_init(&factory
->localfontfaces
);
2046 InitializeCriticalSection(&factory
->cs
);
2047 factory
->cs
.DebugInfo
->Spare
[0] = (DWORD_PTR
)(__FILE__
": dwritefactory.lock");
2050 void factory_detach_fontcollection(IDWriteFactory7
*iface
, IDWriteFontCollection3
*collection
)
2052 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
2053 InterlockedCompareExchangePointer((void **)&factory
->system_collection
, NULL
, collection
);
2054 InterlockedCompareExchangePointer((void **)&factory
->eudc_collection
, NULL
, collection
);
2055 IDWriteFactory7_Release(iface
);
2058 void factory_detach_gdiinterop(IDWriteFactory7
*iface
, IDWriteGdiInterop1
*interop
)
2060 struct dwritefactory
*factory
= impl_from_IDWriteFactory7(iface
);
2061 factory
->gdiinterop
= NULL
;
2062 IDWriteFactory7_Release(iface
);
2065 HRESULT WINAPI
DWriteCreateFactory(DWRITE_FACTORY_TYPE type
, REFIID riid
, IUnknown
**ret
)
2067 struct dwritefactory
*factory
;
2070 TRACE("%d, %s, %p.\n", type
, debugstr_guid(riid
), ret
);
2074 if (type
== DWRITE_FACTORY_TYPE_SHARED
&& shared_factory
)
2075 return IDWriteFactory7_QueryInterface(shared_factory
, riid
, (void**)ret
);
2077 factory
= heap_alloc(sizeof(struct dwritefactory
));
2078 if (!factory
) return E_OUTOFMEMORY
;
2080 init_dwritefactory(factory
, type
);
2082 if (type
== DWRITE_FACTORY_TYPE_SHARED
)
2083 if (InterlockedCompareExchangePointer((void **)&shared_factory
, &factory
->IDWriteFactory7_iface
, NULL
))
2085 release_shared_factory(&factory
->IDWriteFactory7_iface
);
2086 return IDWriteFactory7_QueryInterface(shared_factory
, riid
, (void**)ret
);
2089 hr
= IDWriteFactory7_QueryInterface(&factory
->IDWriteFactory7_iface
, riid
, (void**)ret
);
2090 IDWriteFactory7_Release(&factory
->IDWriteFactory7_iface
);