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 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls( hinstDLL );
50 struct renderingparams {
51 IDWriteRenderingParams IDWriteRenderingParams_iface;
56 FLOAT cleartype_level;
57 DWRITE_PIXEL_GEOMETRY geometry;
58 DWRITE_RENDERING_MODE mode;
61 static inline struct renderingparams *impl_from_IDWriteRenderingParams(IDWriteRenderingParams *iface)
63 return CONTAINING_RECORD(iface, struct renderingparams, IDWriteRenderingParams_iface);
66 static HRESULT WINAPI renderingparams_QueryInterface(IDWriteRenderingParams *iface, REFIID riid, void **obj)
68 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
70 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
72 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteRenderingParams))
75 IDWriteRenderingParams_AddRef(iface);
84 static ULONG WINAPI renderingparams_AddRef(IDWriteRenderingParams *iface)
86 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
87 ULONG ref = InterlockedIncrement(&This->ref);
88 TRACE("(%p)->(%d)\n", This, ref);
92 static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams *iface)
94 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
95 ULONG ref = InterlockedDecrement(&This->ref);
97 TRACE("(%p)->(%d)\n", This, ref);
105 static FLOAT WINAPI renderingparams_GetGamma(IDWriteRenderingParams *iface)
107 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
108 TRACE("(%p)\n", This);
112 static FLOAT WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams *iface)
114 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
115 TRACE("(%p)\n", This);
116 return This->enh_contrast;
119 static FLOAT WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams *iface)
121 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
122 TRACE("(%p)\n", This);
123 return This->cleartype_level;
126 static DWRITE_PIXEL_GEOMETRY WINAPI renderingparams_GetPixelGeometry(IDWriteRenderingParams *iface)
128 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
129 TRACE("(%p)\n", This);
130 return This->geometry;
133 static DWRITE_RENDERING_MODE WINAPI renderingparams_GetRenderingMode(IDWriteRenderingParams *iface)
135 struct renderingparams *This = impl_from_IDWriteRenderingParams(iface);
136 TRACE("(%p)\n", This);
140 static const struct IDWriteRenderingParamsVtbl renderingparamsvtbl = {
141 renderingparams_QueryInterface,
142 renderingparams_AddRef,
143 renderingparams_Release,
144 renderingparams_GetGamma,
145 renderingparams_GetEnhancedContrast,
146 renderingparams_GetClearTypeLevel,
147 renderingparams_GetPixelGeometry,
148 renderingparams_GetRenderingMode
151 static HRESULT create_renderingparams(FLOAT gamma, FLOAT enhancedContrast, FLOAT cleartype_level,
152 DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
154 struct renderingparams *This;
158 This = heap_alloc(sizeof(struct renderingparams));
159 if (!This) return E_OUTOFMEMORY;
161 This->IDWriteRenderingParams_iface.lpVtbl = &renderingparamsvtbl;
165 This->enh_contrast = enhancedContrast;
166 This->cleartype_level = cleartype_level;
167 This->geometry = geometry;
170 *params = &This->IDWriteRenderingParams_iface;
175 static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory *iface, REFIID riid, void **obj)
177 TRACE("(%s %p)\n", debugstr_guid(riid), obj);
179 if (IsEqualIID(riid, &IID_IUnknown) ||
180 IsEqualIID(riid, &IID_IDWriteFactory))
188 return E_NOINTERFACE;
191 static ULONG WINAPI dwritefactory_AddRef(IDWriteFactory *iface)
196 static ULONG WINAPI dwritefactory_Release(IDWriteFactory *iface)
201 static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory *iface,
202 IDWriteFontCollection **collection, BOOL check_for_updates)
204 FIXME("(%p %d): stub\n", collection, check_for_updates);
208 static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory *iface,
209 IDWriteFontCollectionLoader *loader, void const *key, UINT32 key_size, IDWriteFontCollection **collection)
211 FIXME("(%p %p %u %p): stub\n", loader, key, key_size, collection);
215 static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory *iface,
216 IDWriteFontCollectionLoader *loader)
218 FIXME("(%p): stub\n", loader);
222 static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory *iface,
223 IDWriteFontCollectionLoader *loader)
225 FIXME("(%p): stub\n", loader);
229 static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory *iface,
230 WCHAR const *path, FILETIME const *writetime, IDWriteFontFile **font_file)
232 FIXME("(%s %p %p): stub\n", debugstr_w(path), writetime, font_file);
236 static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory *iface,
237 void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file)
239 FIXME("(%p %u %p %p): stub\n", reference_key, key_size, loader, font_file);
243 static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory *iface,
244 DWRITE_FONT_FACE_TYPE facetype, UINT32 files_number, IDWriteFontFile* const* font_files,
245 UINT32 index, DWRITE_FONT_SIMULATIONS sim_flags, IDWriteFontFace **font_face)
247 FIXME("(%d %u %p %u 0x%x %p): stub\n", facetype, files_number, font_files, index, sim_flags, font_face);
251 static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory *iface, IDWriteRenderingParams **params)
256 TRACE("(%p)\n", params);
259 monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
260 return IDWriteFactory_CreateMonitorRenderingParams(iface, monitor, params);
263 static HRESULT WINAPI dwritefactory_CreateMonitorRenderingParams(IDWriteFactory *iface, HMONITOR monitor,
264 IDWriteRenderingParams **params)
266 static int fixme_once = 0;
268 TRACE("(%p %p)\n", monitor, params);
271 FIXME("(%p): monitor setting ignored\n", monitor);
272 return IDWriteFactory_CreateCustomRenderingParams(iface, 0.0, 0.0, 0.0, DWRITE_PIXEL_GEOMETRY_FLAT,
273 DWRITE_RENDERING_MODE_DEFAULT, params);
276 static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory *iface, FLOAT gamma, FLOAT enhancedContrast,
277 FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
279 TRACE("(%f %f %f %d %d %p)\n", gamma, enhancedContrast, cleartype_level, geometry, mode, params);
280 return create_renderingparams(gamma, enhancedContrast, cleartype_level, geometry, mode, params);
283 static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
285 FIXME("(%p): stub\n", loader);
289 static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory *iface, IDWriteFontFileLoader *loader)
291 FIXME("(%p): stub\n", loader);
295 static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory *iface, WCHAR const* family_name,
296 IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
297 DWRITE_FONT_STRETCH stretch, FLOAT size, WCHAR const *locale, IDWriteTextFormat **format)
299 FIXME("(%s %p %d %d %d %f %s %p): stub\n", debugstr_w(family_name), collection, weight, style, stretch,
300 size, debugstr_w(locale), format);
304 static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory *iface, IDWriteTypography **typography)
306 FIXME("(%p): stub\n", typography);
310 static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory *iface, IDWriteGdiInterop **gdi_interop)
312 TRACE("(%p)\n", gdi_interop);
313 return create_gdiinterop(gdi_interop);
316 static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHAR const* string,
317 UINT32 len, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout)
319 FIXME("(%s %u %p %f %f %p): stub\n", debugstr_w(string), len, format, max_width, max_height, layout);
321 if (!format) return E_INVALIDARG;
322 return create_textlayout(layout);
325 static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
326 UINT32 len, IDWriteTextFormat *format, FLOAT layout_width, FLOAT layout_height, FLOAT pixels_per_dip,
327 DWRITE_MATRIX const* transform, BOOL use_gdi_natural, IDWriteTextLayout **layout)
329 FIXME("(%s:%u %p %f %f %f %p %d %p): semi-stub\n", debugstr_wn(string, len), len, format, layout_width, layout_height,
330 pixels_per_dip, transform, use_gdi_natural, layout);
332 if (!format) return E_INVALIDARG;
333 return create_textlayout(layout);
336 static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
337 IDWriteInlineObject **trimming_sign)
339 FIXME("(%p %p): stub\n", format, trimming_sign);
343 static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory *iface, IDWriteTextAnalyzer **analyzer)
345 FIXME("(%p): stub\n", analyzer);
349 static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory *iface, DWRITE_NUMBER_SUBSTITUTION_METHOD method,
350 WCHAR const* locale, BOOL ignore_user_override, IDWriteNumberSubstitution **substitution)
352 FIXME("(%d %s %d %p): stub\n", method, debugstr_w(locale), ignore_user_override, substitution);
356 static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory *iface, DWRITE_GLYPH_RUN const *glyph_run,
357 FLOAT pixels_per_dip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
358 DWRITE_MEASURING_MODE measuring_mode, FLOAT baseline_x, FLOAT baseline_y, IDWriteGlyphRunAnalysis **analysis)
360 FIXME("(%p %f %p %d %d %f %f %p): stub\n", glyph_run, pixels_per_dip, transform, rendering_mode,
361 measuring_mode, baseline_x, baseline_y, analysis);
365 static const struct IDWriteFactoryVtbl dwritefactoryvtbl = {
366 dwritefactory_QueryInterface,
367 dwritefactory_AddRef,
368 dwritefactory_Release,
369 dwritefactory_GetSystemFontCollection,
370 dwritefactory_CreateCustomFontCollection,
371 dwritefactory_RegisterFontCollectionLoader,
372 dwritefactory_UnregisterFontCollectionLoader,
373 dwritefactory_CreateFontFileReference,
374 dwritefactory_CreateCustomFontFileReference,
375 dwritefactory_CreateFontFace,
376 dwritefactory_CreateRenderingParams,
377 dwritefactory_CreateMonitorRenderingParams,
378 dwritefactory_CreateCustomRenderingParams,
379 dwritefactory_RegisterFontFileLoader,
380 dwritefactory_UnregisterFontFileLoader,
381 dwritefactory_CreateTextFormat,
382 dwritefactory_CreateTypography,
383 dwritefactory_GetGdiInterop,
384 dwritefactory_CreateTextLayout,
385 dwritefactory_CreateGdiCompatibleTextLayout,
386 dwritefactory_CreateEllipsisTrimmingSign,
387 dwritefactory_CreateTextAnalyzer,
388 dwritefactory_CreateNumberSubstitution,
389 dwritefactory_CreateGlyphRunAnalysis
392 static IDWriteFactory dwritefactory = { &dwritefactoryvtbl };
394 HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **factory)
396 TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), factory);
398 if (!IsEqualIID(riid, &IID_IDWriteFactory)) return E_FAIL;
400 *factory = (IUnknown*)&dwritefactory;