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
33 #include "dwrite_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dwrite
);
38 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD reason
, LPVOID reserved
)
42 case DLL_WINE_PREATTACH
:
43 return FALSE
; /* prefer native version */
44 case DLL_PROCESS_ATTACH
:
45 DisableThreadLibraryCalls( hinstDLL
);
51 struct renderingparams
{
52 IDWriteRenderingParams IDWriteRenderingParams_iface
;
57 FLOAT cleartype_level
;
58 DWRITE_PIXEL_GEOMETRY geometry
;
59 DWRITE_RENDERING_MODE mode
;
62 static inline struct renderingparams
*impl_from_IDWriteRenderingParams(IDWriteRenderingParams
*iface
)
64 return CONTAINING_RECORD(iface
, struct renderingparams
, IDWriteRenderingParams_iface
);
67 static HRESULT WINAPI
renderingparams_QueryInterface(IDWriteRenderingParams
*iface
, REFIID riid
, void **obj
)
69 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
71 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
73 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteRenderingParams
))
76 IDWriteRenderingParams_AddRef(iface
);
85 static ULONG WINAPI
renderingparams_AddRef(IDWriteRenderingParams
*iface
)
87 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
88 ULONG ref
= InterlockedIncrement(&This
->ref
);
89 TRACE("(%p)->(%d)\n", This
, ref
);
93 static ULONG WINAPI
renderingparams_Release(IDWriteRenderingParams
*iface
)
95 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
96 ULONG ref
= InterlockedDecrement(&This
->ref
);
98 TRACE("(%p)->(%d)\n", This
, ref
);
106 static FLOAT WINAPI
renderingparams_GetGamma(IDWriteRenderingParams
*iface
)
108 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
109 TRACE("(%p)\n", This
);
113 static FLOAT WINAPI
renderingparams_GetEnhancedContrast(IDWriteRenderingParams
*iface
)
115 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
116 TRACE("(%p)\n", This
);
117 return This
->enh_contrast
;
120 static FLOAT WINAPI
renderingparams_GetClearTypeLevel(IDWriteRenderingParams
*iface
)
122 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
123 TRACE("(%p)\n", This
);
124 return This
->cleartype_level
;
127 static DWRITE_PIXEL_GEOMETRY WINAPI
renderingparams_GetPixelGeometry(IDWriteRenderingParams
*iface
)
129 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
130 TRACE("(%p)\n", This
);
131 return This
->geometry
;
134 static DWRITE_RENDERING_MODE WINAPI
renderingparams_GetRenderingMode(IDWriteRenderingParams
*iface
)
136 struct renderingparams
*This
= impl_from_IDWriteRenderingParams(iface
);
137 TRACE("(%p)\n", This
);
141 static const struct IDWriteRenderingParamsVtbl renderingparamsvtbl
= {
142 renderingparams_QueryInterface
,
143 renderingparams_AddRef
,
144 renderingparams_Release
,
145 renderingparams_GetGamma
,
146 renderingparams_GetEnhancedContrast
,
147 renderingparams_GetClearTypeLevel
,
148 renderingparams_GetPixelGeometry
,
149 renderingparams_GetRenderingMode
152 static HRESULT
create_renderingparams(FLOAT gamma
, FLOAT enhancedContrast
, FLOAT cleartype_level
,
153 DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams
**params
)
155 struct renderingparams
*This
;
159 This
= heap_alloc(sizeof(struct renderingparams
));
160 if (!This
) return E_OUTOFMEMORY
;
162 This
->IDWriteRenderingParams_iface
.lpVtbl
= &renderingparamsvtbl
;
166 This
->enh_contrast
= enhancedContrast
;
167 This
->cleartype_level
= cleartype_level
;
168 This
->geometry
= geometry
;
171 *params
= &This
->IDWriteRenderingParams_iface
;
176 struct localizedpair
{
181 struct localizedstrings
{
182 IDWriteLocalizedStrings IDWriteLocalizedStrings_iface
;
185 struct localizedpair
*data
;
190 static inline struct localizedstrings
*impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings
*iface
)
192 return CONTAINING_RECORD(iface
, struct localizedstrings
, IDWriteLocalizedStrings_iface
);
195 static HRESULT WINAPI
localizedstrings_QueryInterface(IDWriteLocalizedStrings
*iface
, REFIID riid
, void **obj
)
197 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
199 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
201 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDWriteLocalizedStrings
))
204 IDWriteLocalizedStrings_AddRef(iface
);
210 return E_NOINTERFACE
;
213 static ULONG WINAPI
localizedstrings_AddRef(IDWriteLocalizedStrings
*iface
)
215 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
216 ULONG ref
= InterlockedIncrement(&This
->ref
);
217 TRACE("(%p)->(%d)\n", This
, ref
);
221 static ULONG WINAPI
localizedstrings_Release(IDWriteLocalizedStrings
*iface
)
223 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
224 ULONG ref
= InterlockedDecrement(&This
->ref
);
226 TRACE("(%p)->(%d)\n", This
, ref
);
231 for (i
= 0; i
< This
->count
; i
++) {
232 heap_free(This
->data
[i
].locale
);
233 heap_free(This
->data
[i
].string
);
236 heap_free(This
->data
);
243 static UINT32 WINAPI
localizedstrings_GetCount(IDWriteLocalizedStrings
*iface
)
245 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
246 TRACE("(%p)\n", This
);
250 static HRESULT WINAPI
localizedstrings_FindLocaleName(IDWriteLocalizedStrings
*iface
,
251 WCHAR
const *locale_name
, UINT32
*index
, BOOL
*exists
)
253 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
254 FIXME("(%p)->(%s %p %p): stub\n", This
, debugstr_w(locale_name
), index
, exists
);
258 static HRESULT WINAPI
localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
260 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
261 FIXME("(%p)->(%u %p): stub\n", This
, index
, length
);
265 static HRESULT WINAPI
localizedstrings_GetLocaleName(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*locale_name
, UINT32 size
)
267 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
268 FIXME("(%p)->(%u %p %u): stub\n", This
, index
, locale_name
, size
);
272 static HRESULT WINAPI
localizedstrings_GetStringLength(IDWriteLocalizedStrings
*iface
, UINT32 index
, UINT32
*length
)
274 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
276 TRACE("(%p)->(%u %p)\n", This
, index
, length
);
278 if (index
>= This
->count
) {
279 *length
= (UINT32
)-1;
283 *length
= strlenW(This
->data
[index
].string
);
287 static HRESULT WINAPI
localizedstrings_GetString(IDWriteLocalizedStrings
*iface
, UINT32 index
, WCHAR
*buffer
, UINT32 size
)
289 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
291 TRACE("(%p)->(%u %p %u)\n", This
, index
, buffer
, size
);
293 if (index
>= This
->count
) {
294 if (buffer
) *buffer
= 0;
298 if (size
< strlenW(This
->data
[index
].string
)+1) {
299 if (buffer
) *buffer
= 0;
300 return E_NOT_SUFFICIENT_BUFFER
;
303 strcpyW(buffer
, This
->data
[index
].string
);
307 static const IDWriteLocalizedStringsVtbl localizedstringsvtbl
= {
308 localizedstrings_QueryInterface
,
309 localizedstrings_AddRef
,
310 localizedstrings_Release
,
311 localizedstrings_GetCount
,
312 localizedstrings_FindLocaleName
,
313 localizedstrings_GetLocaleNameLength
,
314 localizedstrings_GetLocaleName
,
315 localizedstrings_GetStringLength
,
316 localizedstrings_GetString
319 HRESULT
create_localizedstrings(IDWriteLocalizedStrings
**strings
)
321 struct localizedstrings
*This
;
325 This
= heap_alloc(sizeof(struct localizedstrings
));
326 if (!This
) return E_OUTOFMEMORY
;
328 This
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
331 This
->data
= heap_alloc_zero(sizeof(struct localizedpair
));
334 return E_OUTOFMEMORY
;
338 *strings
= &This
->IDWriteLocalizedStrings_iface
;
343 HRESULT
add_localizedstring(IDWriteLocalizedStrings
*iface
, const WCHAR
*locale
, const WCHAR
*string
)
345 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
347 if (This
->count
== This
->alloc
) {
349 This
->data
= heap_realloc(This
->data
, This
->alloc
*sizeof(struct localizedpair
));
352 This
->data
[This
->count
].locale
= heap_strdupW(locale
);
353 This
->data
[This
->count
].string
= heap_strdupW(string
);
359 HRESULT
clone_localizedstring(IDWriteLocalizedStrings
*iface
, IDWriteLocalizedStrings
**strings
)
361 struct localizedstrings
*This
= impl_from_IDWriteLocalizedStrings(iface
);
362 struct localizedstrings
*New
;
367 New
= heap_alloc(sizeof(struct localizedstrings
));
368 if (!New
) return E_OUTOFMEMORY
;
370 New
->IDWriteLocalizedStrings_iface
.lpVtbl
= &localizedstringsvtbl
;
372 New
->count
= This
->count
;
373 New
->data
= heap_alloc(sizeof(struct localizedpair
) * New
->count
);
376 return E_OUTOFMEMORY
;
378 for (i
= 0; i
< New
->count
; i
++)
380 New
->data
[i
].locale
= heap_strdupW(This
->data
[i
].locale
);
381 New
->data
[i
].string
= heap_strdupW(This
->data
[i
].string
);
383 New
->alloc
= New
->count
;
385 *strings
= &New
->IDWriteLocalizedStrings_iface
;
390 struct dwritefactory
{
391 IDWriteFactory IDWriteFactory_iface
;
394 IDWriteLocalFontFileLoader
* localfontfileloader
;
395 IDWriteFontCollection
*system_collection
;
397 IDWriteFontCollectionLoader
**loaders
;
399 IDWriteFontFileLoader
**file_loaders
;
400 LONG file_loader_count
;
403 static inline struct dwritefactory
*impl_from_IDWriteFactory(IDWriteFactory
*iface
)
405 return CONTAINING_RECORD(iface
, struct dwritefactory
, IDWriteFactory_iface
);
408 static HRESULT WINAPI
dwritefactory_QueryInterface(IDWriteFactory
*iface
, REFIID riid
, void **obj
)
410 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
412 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), obj
);
414 if (IsEqualIID(riid
, &IID_IUnknown
) ||
415 IsEqualIID(riid
, &IID_IDWriteFactory
))
418 IDWriteFactory_AddRef(iface
);
424 return E_NOINTERFACE
;
427 static ULONG WINAPI
dwritefactory_AddRef(IDWriteFactory
*iface
)
429 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
430 ULONG ref
= InterlockedIncrement(&This
->ref
);
431 TRACE("(%p)->(%d)\n", This
, ref
);
435 static ULONG WINAPI
dwritefactory_Release(IDWriteFactory
*iface
)
437 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
438 ULONG ref
= InterlockedDecrement(&This
->ref
);
440 TRACE("(%p)->(%d)\n", This
, ref
);
444 if (This
->localfontfileloader
)
445 IDWriteLocalFontFileLoader_Release(This
->localfontfileloader
);
446 for (i
= 0; i
< This
->loader_count
; i
++)
447 if (This
->loaders
[i
])
448 IDWriteFontCollectionLoader_Release(This
->loaders
[i
]);
449 heap_free(This
->loaders
);
450 for (i
= 0; i
< This
->file_loader_count
; i
++)
451 if (This
->file_loaders
[i
])
452 IDWriteFontFileLoader_Release(This
->file_loaders
[i
]);
453 heap_free(This
->file_loaders
);
454 if (This
->system_collection
)
455 IDWriteFontCollection_Release(This
->system_collection
);
462 static HRESULT WINAPI
dwritefactory_GetSystemFontCollection(IDWriteFactory
*iface
,
463 IDWriteFontCollection
**collection
, BOOL check_for_updates
)
466 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
467 TRACE("(%p)->(%p %d)\n", This
, collection
, check_for_updates
);
469 if (check_for_updates
)
470 FIXME("checking for system font updates not implemented\n");
472 if (!This
->system_collection
)
473 hr
= get_system_fontcollection(&This
->system_collection
);
476 IDWriteFontCollection_AddRef(This
->system_collection
);
478 *collection
= This
->system_collection
;
483 static HRESULT WINAPI
dwritefactory_CreateCustomFontCollection(IDWriteFactory
*iface
,
484 IDWriteFontCollectionLoader
*loader
, void const *key
, UINT32 key_size
, IDWriteFontCollection
**collection
)
486 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
487 FIXME("(%p)->(%p %p %u %p): stub\n", This
, loader
, key
, key_size
, collection
);
491 static HRESULT WINAPI
dwritefactory_RegisterFontCollectionLoader(IDWriteFactory
*iface
,
492 IDWriteFontCollectionLoader
*loader
)
495 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
497 TRACE("(%p)->(%p)\n", This
, loader
);
499 for (i
= 0; i
< This
->loader_count
; i
++)
500 if (This
->loaders
[i
] == loader
)
501 return DWRITE_E_ALREADYREGISTERED
;
502 else if (This
->loaders
[i
] == NULL
)
505 if (i
== This
->loader_count
)
507 IDWriteFontCollectionLoader
**new_list
= NULL
;
510 new_count
= This
->loader_count
* 2;
511 new_list
= heap_realloc_zero(This
->loaders
, new_count
* sizeof(*This
->loaders
));
514 return E_OUTOFMEMORY
;
517 This
->loader_count
= new_count
;
518 This
->loaders
= new_list
;
521 IDWriteFontCollectionLoader_AddRef(loader
);
522 This
->loaders
[i
] = loader
;
527 static HRESULT WINAPI
dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory
*iface
,
528 IDWriteFontCollectionLoader
*loader
)
531 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
533 TRACE("(%p)->(%p)\n", This
, loader
);
535 for (i
= 0; i
< This
->loader_count
; i
++)
536 if (This
->loaders
[i
] == loader
) break;
537 if (i
== This
->loader_count
)
539 IDWriteFontCollectionLoader_Release(This
->loaders
[i
]);
540 This
->loaders
[i
] = NULL
;
545 static HRESULT WINAPI
dwritefactory_CreateFontFileReference(IDWriteFactory
*iface
,
546 WCHAR
const *path
, FILETIME
const *writetime
, IDWriteFontFile
**font_file
)
549 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
550 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(path
), writetime
, font_file
);
552 if (!This
->localfontfileloader
)
554 hr
= create_localfontfileloader(&This
->localfontfileloader
);
558 return create_font_file((IDWriteFontFileLoader
*)This
->localfontfileloader
, path
, sizeof(WCHAR
) * (strlenW(path
)+1), font_file
);
561 static HRESULT WINAPI
dwritefactory_CreateCustomFontFileReference(IDWriteFactory
*iface
,
562 void const *reference_key
, UINT32 key_size
, IDWriteFontFileLoader
*loader
, IDWriteFontFile
**font_file
)
565 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
568 TRACE("(%p)->(%p %u %p %p)\n", This
, reference_key
, key_size
, loader
, font_file
);
573 for (i
= 0; i
< This
->file_loader_count
; i
++)
574 if (This
->file_loaders
[i
] == loader
) break;
575 if (i
== This
->file_loader_count
)
577 hr
= create_font_file(loader
, reference_key
, key_size
, font_file
);
581 static HRESULT WINAPI
dwritefactory_CreateFontFace(IDWriteFactory
*iface
,
582 DWRITE_FONT_FACE_TYPE facetype
, UINT32 files_number
, IDWriteFontFile
* const* font_files
,
583 UINT32 index
, DWRITE_FONT_SIMULATIONS sim_flags
, IDWriteFontFace
**font_face
)
585 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
586 TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This
, facetype
, files_number
, font_files
, index
, sim_flags
, font_face
);
587 return font_create_fontface(iface
, facetype
, files_number
, font_files
, index
, sim_flags
, font_face
);
590 static HRESULT WINAPI
dwritefactory_CreateRenderingParams(IDWriteFactory
*iface
, IDWriteRenderingParams
**params
)
592 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
596 TRACE("(%p)->(%p)\n", This
, params
);
599 monitor
= MonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
600 return IDWriteFactory_CreateMonitorRenderingParams(iface
, monitor
, params
);
603 static HRESULT WINAPI
dwritefactory_CreateMonitorRenderingParams(IDWriteFactory
*iface
, HMONITOR monitor
,
604 IDWriteRenderingParams
**params
)
606 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
607 static int fixme_once
= 0;
609 TRACE("(%p)->(%p %p)\n", This
, monitor
, params
);
612 FIXME("(%p): monitor setting ignored\n", monitor
);
613 return IDWriteFactory_CreateCustomRenderingParams(iface
, 0.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT
,
614 DWRITE_RENDERING_MODE_DEFAULT
, params
);
617 static HRESULT WINAPI
dwritefactory_CreateCustomRenderingParams(IDWriteFactory
*iface
, FLOAT gamma
, FLOAT enhancedContrast
,
618 FLOAT cleartype_level
, DWRITE_PIXEL_GEOMETRY geometry
, DWRITE_RENDERING_MODE mode
, IDWriteRenderingParams
**params
)
620 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
621 TRACE("(%p)->(%f %f %f %d %d %p)\n", This
, gamma
, enhancedContrast
, cleartype_level
, geometry
, mode
, params
);
622 return create_renderingparams(gamma
, enhancedContrast
, cleartype_level
, geometry
, mode
, params
);
625 static HRESULT WINAPI
dwritefactory_RegisterFontFileLoader(IDWriteFactory
*iface
, IDWriteFontFileLoader
*loader
)
628 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
629 TRACE("(%p)->(%p)\n", This
, loader
);
634 for (i
= 0; i
< This
->file_loader_count
; i
++)
635 if (This
->file_loaders
[i
] == loader
)
636 return DWRITE_E_ALREADYREGISTERED
;
637 else if (This
->file_loaders
[i
] == NULL
)
640 if (i
== This
->file_loader_count
)
642 IDWriteFontFileLoader
**new_list
= NULL
;
645 new_count
= This
->file_loader_count
* 2;
646 new_list
= heap_realloc_zero(This
->file_loaders
, new_count
* sizeof(*This
->file_loaders
));
649 return E_OUTOFMEMORY
;
652 This
->file_loader_count
= new_count
;
653 This
->file_loaders
= new_list
;
656 IDWriteFontFileLoader_AddRef(loader
);
657 This
->file_loaders
[i
] = loader
;
662 static HRESULT WINAPI
dwritefactory_UnregisterFontFileLoader(IDWriteFactory
*iface
, IDWriteFontFileLoader
*loader
)
665 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
666 TRACE("(%p)->(%p)\n", This
, loader
);
668 for (i
= 0; i
< This
->file_loader_count
; i
++)
669 if (This
->file_loaders
[i
] == loader
) break;
670 if (i
== This
->file_loader_count
)
672 IDWriteFontFileLoader_Release(This
->file_loaders
[i
]);
673 This
->file_loaders
[i
] = NULL
;
678 static HRESULT WINAPI
dwritefactory_CreateTextFormat(IDWriteFactory
*iface
, WCHAR
const* family_name
,
679 IDWriteFontCollection
*collection
, DWRITE_FONT_WEIGHT weight
, DWRITE_FONT_STYLE style
,
680 DWRITE_FONT_STRETCH stretch
, FLOAT size
, WCHAR
const *locale
, IDWriteTextFormat
**format
)
682 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
683 TRACE("(%p)->(%s %p %d %d %d %f %s %p)\n", This
, debugstr_w(family_name
), collection
, weight
, style
, stretch
,
684 size
, debugstr_w(locale
), format
);
688 HRESULT hr
= IDWriteFactory_GetSystemFontCollection(iface
, &collection
, FALSE
);
691 /* Our ref count is 1 too many, since we will add ref in create_textformat */
692 IDWriteFontCollection_Release(This
->system_collection
);
694 return create_textformat(family_name
, collection
, weight
, style
, stretch
, size
, locale
, format
);
697 static HRESULT WINAPI
dwritefactory_CreateTypography(IDWriteFactory
*iface
, IDWriteTypography
**typography
)
699 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
700 TRACE("(%p)->(%p)\n", This
, typography
);
701 return create_typography(typography
);
704 static HRESULT WINAPI
dwritefactory_GetGdiInterop(IDWriteFactory
*iface
, IDWriteGdiInterop
**gdi_interop
)
706 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
707 TRACE("(%p)->(%p)\n", This
, gdi_interop
);
708 return get_gdiinterop(gdi_interop
);
711 static HRESULT WINAPI
dwritefactory_CreateTextLayout(IDWriteFactory
*iface
, WCHAR
const* string
,
712 UINT32 len
, IDWriteTextFormat
*format
, FLOAT max_width
, FLOAT max_height
, IDWriteTextLayout
**layout
)
714 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
715 TRACE("(%p)->(%s %u %p %f %f %p)\n", This
, debugstr_w(string
), len
, format
, max_width
, max_height
, layout
);
717 if (!format
) return E_INVALIDARG
;
718 return create_textlayout(string
, len
, format
, max_width
, max_height
, layout
);
721 static HRESULT WINAPI
dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory
*iface
, WCHAR
const* string
,
722 UINT32 len
, IDWriteTextFormat
*format
, FLOAT layout_width
, FLOAT layout_height
, FLOAT pixels_per_dip
,
723 DWRITE_MATRIX
const* transform
, BOOL use_gdi_natural
, IDWriteTextLayout
**layout
)
725 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
726 FIXME("(%p)->(%s:%u %p %f %f %f %p %d %p): semi-stub\n", This
, debugstr_wn(string
, len
), len
, format
, layout_width
, layout_height
,
727 pixels_per_dip
, transform
, use_gdi_natural
, layout
);
729 if (!format
) return E_INVALIDARG
;
730 return create_textlayout(string
, len
, format
, layout_width
, layout_height
, layout
);
733 static HRESULT WINAPI
dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory
*iface
, IDWriteTextFormat
*format
,
734 IDWriteInlineObject
**trimming_sign
)
736 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
737 FIXME("(%p)->(%p %p): semi-stub\n", This
, format
, trimming_sign
);
738 return create_trimmingsign(trimming_sign
);
741 static HRESULT WINAPI
dwritefactory_CreateTextAnalyzer(IDWriteFactory
*iface
, IDWriteTextAnalyzer
**analyzer
)
743 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
744 TRACE("(%p)->(%p)\n", This
, analyzer
);
745 return get_textanalyzer(analyzer
);
748 static HRESULT WINAPI
dwritefactory_CreateNumberSubstitution(IDWriteFactory
*iface
, DWRITE_NUMBER_SUBSTITUTION_METHOD method
,
749 WCHAR
const* locale
, BOOL ignore_user_override
, IDWriteNumberSubstitution
**substitution
)
751 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
752 FIXME("(%p)->(%d %s %d %p): stub\n", This
, method
, debugstr_w(locale
), ignore_user_override
, substitution
);
756 static HRESULT WINAPI
dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory
*iface
, DWRITE_GLYPH_RUN
const *glyph_run
,
757 FLOAT pixels_per_dip
, DWRITE_MATRIX
const* transform
, DWRITE_RENDERING_MODE rendering_mode
,
758 DWRITE_MEASURING_MODE measuring_mode
, FLOAT baseline_x
, FLOAT baseline_y
, IDWriteGlyphRunAnalysis
**analysis
)
760 struct dwritefactory
*This
= impl_from_IDWriteFactory(iface
);
761 FIXME("(%p)->(%p %f %p %d %d %f %f %p): stub\n", This
, glyph_run
, pixels_per_dip
, transform
, rendering_mode
,
762 measuring_mode
, baseline_x
, baseline_y
, analysis
);
766 static const struct IDWriteFactoryVtbl dwritefactoryvtbl
= {
767 dwritefactory_QueryInterface
,
768 dwritefactory_AddRef
,
769 dwritefactory_Release
,
770 dwritefactory_GetSystemFontCollection
,
771 dwritefactory_CreateCustomFontCollection
,
772 dwritefactory_RegisterFontCollectionLoader
,
773 dwritefactory_UnregisterFontCollectionLoader
,
774 dwritefactory_CreateFontFileReference
,
775 dwritefactory_CreateCustomFontFileReference
,
776 dwritefactory_CreateFontFace
,
777 dwritefactory_CreateRenderingParams
,
778 dwritefactory_CreateMonitorRenderingParams
,
779 dwritefactory_CreateCustomRenderingParams
,
780 dwritefactory_RegisterFontFileLoader
,
781 dwritefactory_UnregisterFontFileLoader
,
782 dwritefactory_CreateTextFormat
,
783 dwritefactory_CreateTypography
,
784 dwritefactory_GetGdiInterop
,
785 dwritefactory_CreateTextLayout
,
786 dwritefactory_CreateGdiCompatibleTextLayout
,
787 dwritefactory_CreateEllipsisTrimmingSign
,
788 dwritefactory_CreateTextAnalyzer
,
789 dwritefactory_CreateNumberSubstitution
,
790 dwritefactory_CreateGlyphRunAnalysis
793 HRESULT WINAPI
DWriteCreateFactory(DWRITE_FACTORY_TYPE type
, REFIID riid
, IUnknown
**factory
)
795 struct dwritefactory
*This
;
797 TRACE("(%d, %s, %p)\n", type
, debugstr_guid(riid
), factory
);
799 if (!IsEqualIID(riid
, &IID_IDWriteFactory
)) return E_FAIL
;
801 This
= heap_alloc(sizeof(struct dwritefactory
));
802 if (!This
) return E_OUTOFMEMORY
;
804 This
->IDWriteFactory_iface
.lpVtbl
= &dwritefactoryvtbl
;
806 This
->localfontfileloader
= NULL
;
807 This
->loader_count
= 2;
808 This
->loaders
= heap_alloc_zero(sizeof(*This
->loaders
) * 2);
809 This
->file_loader_count
= 2;
810 This
->file_loaders
= heap_alloc_zero(sizeof(*This
->file_loaders
) * 2);
811 This
->system_collection
= NULL
;
813 *factory
= (IUnknown
*)&This
->IDWriteFactory_iface
;