2012-07-24 12:05:18 +02:00
|
|
|
/*
|
|
|
|
* DWrite
|
|
|
|
*
|
|
|
|
* Copyright 2012 Nikolay Sivov for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-10-01 07:05:38 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2012-07-24 12:05:18 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2012-10-01 07:35:00 +02:00
|
|
|
#include "winuser.h"
|
2012-07-24 12:05:18 +02:00
|
|
|
|
2012-07-31 06:07:49 +02:00
|
|
|
#include "initguid.h"
|
2012-07-29 10:50:34 +02:00
|
|
|
|
2012-07-31 06:12:35 +02:00
|
|
|
#include "dwrite_private.h"
|
2012-07-29 10:50:34 +02:00
|
|
|
#include "wine/debug.h"
|
2014-10-20 10:50:27 +02:00
|
|
|
#include "wine/list.h"
|
2012-07-29 10:50:34 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static IDWriteFactory3 *shared_factory;
|
|
|
|
static void release_shared_factory(IDWriteFactory3*);
|
2014-10-09 07:05:27 +02:00
|
|
|
|
2012-07-24 12:05:18 +02:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls( hinstDLL );
|
2014-11-21 09:48:23 +01:00
|
|
|
init_freetype();
|
2012-07-24 12:05:18 +02:00
|
|
|
break;
|
2014-10-09 07:05:27 +02:00
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
if (reserved) break;
|
|
|
|
release_shared_factory(shared_factory);
|
2015-01-05 20:17:14 +01:00
|
|
|
release_freetype();
|
2012-07-24 12:05:18 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-07-29 10:50:34 +02:00
|
|
|
|
2012-10-01 07:05:38 +02:00
|
|
|
struct renderingparams {
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 IDWriteRenderingParams3_iface;
|
2012-10-01 07:05:38 +02:00
|
|
|
LONG ref;
|
2012-10-01 07:11:44 +02:00
|
|
|
|
|
|
|
FLOAT gamma;
|
2015-03-31 10:39:59 +02:00
|
|
|
FLOAT contrast;
|
|
|
|
FLOAT grayscalecontrast;
|
2012-10-01 07:11:44 +02:00
|
|
|
FLOAT cleartype_level;
|
|
|
|
DWRITE_PIXEL_GEOMETRY geometry;
|
2016-04-19 08:39:25 +02:00
|
|
|
DWRITE_RENDERING_MODE1 mode;
|
2015-03-31 10:39:59 +02:00
|
|
|
DWRITE_GRID_FIT_MODE gridfit;
|
2012-10-01 07:05:38 +02:00
|
|
|
};
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static inline struct renderingparams *impl_from_IDWriteRenderingParams3(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct renderingparams, IDWriteRenderingParams3_iface);
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static HRESULT WINAPI renderingparams_QueryInterface(IDWriteRenderingParams3 *iface, REFIID riid, void **obj)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:05:38 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteRenderingParams3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteRenderingParams2) ||
|
2015-03-31 10:39:59 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteRenderingParams1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteRenderingParams) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
|
|
|
*obj = iface;
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3_AddRef(iface);
|
2012-10-01 07:05:38 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static ULONG WINAPI renderingparams_AddRef(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:05:38 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:05:38 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
heap_free(This);
|
|
|
|
|
2012-10-21 03:47:22 +02:00
|
|
|
return ref;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static FLOAT WINAPI renderingparams_GetGamma(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->gamma;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static FLOAT WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2015-03-31 10:39:59 +02:00
|
|
|
return This->contrast;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static FLOAT WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->cleartype_level;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static DWRITE_PIXEL_GEOMETRY WINAPI renderingparams_GetPixelGeometry(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2012-10-01 07:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->geometry;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static DWRITE_RENDERING_MODE WINAPI renderingparams_GetRenderingMode(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
2012-10-01 07:11:44 +02:00
|
|
|
TRACE("(%p)\n", This);
|
2016-04-19 08:39:25 +02:00
|
|
|
|
|
|
|
if (This->mode == DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED)
|
|
|
|
return DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC;
|
|
|
|
|
2012-10-01 07:11:44 +02:00
|
|
|
return This->mode;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static FLOAT WINAPI renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3 *iface)
|
2015-03-31 10:39:59 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2015-03-31 10:39:59 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->grayscalecontrast;
|
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static DWRITE_GRID_FIT_MODE WINAPI renderingparams2_GetGridFitMode(IDWriteRenderingParams3 *iface)
|
2015-03-31 10:39:59 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
2015-03-31 10:39:59 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->gridfit;
|
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static DWRITE_RENDERING_MODE1 WINAPI renderingparams3_GetRenderingMode1(IDWriteRenderingParams3 *iface)
|
|
|
|
{
|
|
|
|
struct renderingparams *This = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteRenderingParams3Vtbl renderingparamsvtbl = {
|
2012-10-01 07:05:38 +02:00
|
|
|
renderingparams_QueryInterface,
|
|
|
|
renderingparams_AddRef,
|
|
|
|
renderingparams_Release,
|
|
|
|
renderingparams_GetGamma,
|
|
|
|
renderingparams_GetEnhancedContrast,
|
|
|
|
renderingparams_GetClearTypeLevel,
|
|
|
|
renderingparams_GetPixelGeometry,
|
2015-03-31 10:39:59 +02:00
|
|
|
renderingparams_GetRenderingMode,
|
2016-04-19 08:39:25 +02:00
|
|
|
renderingparams1_GetGrayscaleEnhancedContrast,
|
|
|
|
renderingparams2_GetGridFitMode,
|
|
|
|
renderingparams3_GetRenderingMode1
|
2012-10-01 07:05:38 +02:00
|
|
|
};
|
|
|
|
|
2015-03-31 10:39:59 +02:00
|
|
|
static HRESULT create_renderingparams(FLOAT gamma, FLOAT contrast, FLOAT grayscalecontrast, FLOAT cleartype_level,
|
2016-04-19 08:39:25 +02:00
|
|
|
DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, DWRITE_GRID_FIT_MODE gridfit, IDWriteRenderingParams3 **params)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
|
|
|
struct renderingparams *This;
|
|
|
|
|
|
|
|
*params = NULL;
|
|
|
|
|
|
|
|
This = heap_alloc(sizeof(struct renderingparams));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
This->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl;
|
2012-10-01 07:05:38 +02:00
|
|
|
This->ref = 1;
|
|
|
|
|
2012-10-01 07:11:44 +02:00
|
|
|
This->gamma = gamma;
|
2015-03-31 10:39:59 +02:00
|
|
|
This->contrast = contrast;
|
|
|
|
This->grayscalecontrast = grayscalecontrast;
|
2012-10-01 07:11:44 +02:00
|
|
|
This->cleartype_level = cleartype_level;
|
|
|
|
This->geometry = geometry;
|
|
|
|
This->mode = mode;
|
2015-03-31 10:39:59 +02:00
|
|
|
This->gridfit = gridfit;
|
2012-10-01 07:11:44 +02:00
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
*params = &This->IDWriteRenderingParams3_iface;
|
2012-10-01 07:05:38 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
struct localizedpair {
|
|
|
|
WCHAR *locale;
|
|
|
|
WCHAR *string;
|
|
|
|
};
|
|
|
|
|
2012-10-07 19:11:04 +02:00
|
|
|
struct localizedstrings {
|
|
|
|
IDWriteLocalizedStrings IDWriteLocalizedStrings_iface;
|
|
|
|
LONG ref;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
|
|
|
struct localizedpair *data;
|
|
|
|
UINT32 count;
|
|
|
|
UINT32 alloc;
|
2012-10-07 19:11:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct localizedstrings *impl_from_IDWriteLocalizedStrings(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, struct localizedstrings, IDWriteLocalizedStrings_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_QueryInterface(IDWriteLocalizedStrings *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteLocalizedStrings))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
IDWriteLocalizedStrings_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localizedstrings_AddRef(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
if (!ref) {
|
2013-03-09 22:48:49 +01:00
|
|
|
unsigned int i;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
|
|
|
for (i = 0; i < This->count; i++) {
|
|
|
|
heap_free(This->data[i].locale);
|
|
|
|
heap_free(This->data[i].string);
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(This->data);
|
2012-10-07 19:11:04 +02:00
|
|
|
heap_free(This);
|
2012-10-07 23:13:29 +02:00
|
|
|
}
|
2012-10-07 19:11:04 +02:00
|
|
|
|
2012-10-21 03:47:22 +02:00
|
|
|
return ref;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2012-10-07 23:13:29 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return This->count;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
|
|
|
|
WCHAR const *locale_name, UINT32 *index, BOOL *exists)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2014-11-05 06:49:48 +01:00
|
|
|
UINT32 i;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(locale_name), index, exists);
|
|
|
|
|
|
|
|
*exists = FALSE;
|
|
|
|
*index = ~0;
|
|
|
|
|
|
|
|
for (i = 0; i < This->count; i++) {
|
|
|
|
if (!strcmpiW(This->data[i].locale, locale_name)) {
|
|
|
|
*exists = TRUE;
|
|
|
|
*index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_GetLocaleNameLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p)\n", This, index, length);
|
|
|
|
|
|
|
|
if (index >= This->count) {
|
|
|
|
*length = (UINT32)-1;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*length = strlenW(This->data[index].locale);
|
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
2014-11-05 06:49:48 +01:00
|
|
|
static HRESULT WINAPI localizedstrings_GetLocaleName(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
|
2012-10-07 19:11:04 +02:00
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size);
|
|
|
|
|
|
|
|
if (index >= This->count) {
|
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < strlenW(This->data[index].locale)+1) {
|
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(buffer, This->data[index].locale);
|
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2012-10-07 23:25:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p)\n", This, index, length);
|
|
|
|
|
|
|
|
if (index >= This->count) {
|
|
|
|
*length = (UINT32)-1;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*length = strlenW(This->data[index].string);
|
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2012-10-08 00:43:15 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%u %p %u)\n", This, index, buffer, size);
|
|
|
|
|
|
|
|
if (index >= This->count) {
|
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < strlenW(This->data[index].string)+1) {
|
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpyW(buffer, This->data[index].string);
|
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IDWriteLocalizedStringsVtbl localizedstringsvtbl = {
|
|
|
|
localizedstrings_QueryInterface,
|
|
|
|
localizedstrings_AddRef,
|
|
|
|
localizedstrings_Release,
|
|
|
|
localizedstrings_GetCount,
|
|
|
|
localizedstrings_FindLocaleName,
|
|
|
|
localizedstrings_GetLocaleNameLength,
|
|
|
|
localizedstrings_GetLocaleName,
|
|
|
|
localizedstrings_GetStringLength,
|
|
|
|
localizedstrings_GetString
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This;
|
|
|
|
|
|
|
|
*strings = NULL;
|
|
|
|
|
|
|
|
This = heap_alloc(sizeof(struct localizedstrings));
|
|
|
|
if (!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
|
|
|
|
This->ref = 1;
|
2012-10-07 23:13:29 +02:00
|
|
|
This->count = 0;
|
|
|
|
This->data = heap_alloc_zero(sizeof(struct localizedpair));
|
|
|
|
if (!This->data) {
|
|
|
|
heap_free(This);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
This->alloc = 1;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
*strings = &This->IDWriteLocalizedStrings_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale, const WCHAR *string)
|
|
|
|
{
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
2015-01-26 11:39:18 +01:00
|
|
|
UINT32 i;
|
|
|
|
|
|
|
|
/* make sure there's no duplicates */
|
|
|
|
for (i = 0; i < This->count; i++)
|
|
|
|
if (!strcmpW(This->data[i].locale, locale))
|
|
|
|
return S_OK;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
|
|
|
if (This->count == This->alloc) {
|
2015-01-26 11:39:18 +01:00
|
|
|
void *ptr;
|
|
|
|
|
|
|
|
ptr = heap_realloc(This->data, 2*This->alloc*sizeof(struct localizedpair));
|
|
|
|
if (!ptr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
This->alloc *= 2;
|
2015-01-26 11:39:18 +01:00
|
|
|
This->data = ptr;
|
2012-10-07 23:13:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
This->data[This->count].locale = heap_strdupW(locale);
|
|
|
|
This->data[This->count].string = heap_strdupW(string);
|
2015-01-26 11:39:18 +01:00
|
|
|
if (!This->data[This->count].locale || !This->data[This->count].string) {
|
|
|
|
heap_free(This->data[This->count].locale);
|
|
|
|
heap_free(This->data[This->count].string);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
This->count++;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-10-24 09:42:35 +02:00
|
|
|
HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **ret)
|
2015-09-01 11:09:24 +02:00
|
|
|
{
|
2014-10-24 09:42:35 +02:00
|
|
|
struct localizedstrings *strings, *strings_clone;
|
2014-09-05 00:45:37 +02:00
|
|
|
int i;
|
|
|
|
|
2014-10-24 09:42:35 +02:00
|
|
|
*ret = NULL;
|
|
|
|
|
|
|
|
if (!iface)
|
|
|
|
return S_FALSE;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
2014-10-24 09:42:35 +02:00
|
|
|
strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
strings_clone = heap_alloc(sizeof(struct localizedstrings));
|
|
|
|
if (!strings_clone) return E_OUTOFMEMORY;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
2014-10-24 09:42:35 +02:00
|
|
|
strings_clone->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
|
|
|
|
strings_clone->ref = 1;
|
|
|
|
strings_clone->count = strings->count;
|
|
|
|
strings_clone->data = heap_alloc(sizeof(struct localizedpair) * strings_clone->count);
|
|
|
|
if (!strings_clone->data) {
|
|
|
|
heap_free(strings_clone);
|
2014-09-05 00:45:37 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2014-10-24 09:42:35 +02:00
|
|
|
for (i = 0; i < strings_clone->count; i++)
|
2014-09-05 00:45:37 +02:00
|
|
|
{
|
2014-10-24 09:42:35 +02:00
|
|
|
strings_clone->data[i].locale = heap_strdupW(strings->data[i].locale);
|
|
|
|
strings_clone->data[i].string = heap_strdupW(strings->data[i].string);
|
2014-09-05 00:45:37 +02:00
|
|
|
}
|
2014-10-24 09:42:35 +02:00
|
|
|
strings_clone->alloc = strings_clone->count;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
2014-10-24 09:42:35 +02:00
|
|
|
*ret = &strings_clone->IDWriteLocalizedStrings_iface;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-01 11:09:24 +02:00
|
|
|
void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string)
|
|
|
|
{
|
|
|
|
static const WCHAR enusW[] = {'e','n','-','U','S',0};
|
|
|
|
struct localizedstrings *This = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
UINT32 i;
|
|
|
|
|
|
|
|
for (i = 0; i < This->count; i++) {
|
|
|
|
if (!strcmpiW(This->data[i].locale, enusW)) {
|
|
|
|
heap_free(This->data[i].string);
|
|
|
|
This->data[i].string = heap_strdupW(string);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
struct collectionloader
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IDWriteFontCollectionLoader *loader;
|
|
|
|
};
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
struct fontfacecached
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IDWriteFontFace *fontface;
|
|
|
|
};
|
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader
|
|
|
|
{
|
|
|
|
struct list entry;
|
2014-10-24 09:40:06 +02:00
|
|
|
struct list fontfaces;
|
2014-10-20 10:53:21 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
};
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
struct dwritefactory {
|
2016-03-28 12:33:57 +02:00
|
|
|
IDWriteFactory3 IDWriteFactory3_iface;
|
2014-08-06 23:59:39 +02:00
|
|
|
LONG ref;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-09-02 14:17:57 +02:00
|
|
|
IDWriteFontCollection *system_collection;
|
2014-12-17 07:54:13 +01:00
|
|
|
IDWriteFontCollection *eudc_collection;
|
2016-05-03 11:56:57 +02:00
|
|
|
struct gdiinterop interop;
|
2016-02-14 17:05:06 +01:00
|
|
|
IDWriteFontFallback *fallback;
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
IDWriteLocalFontFileLoader* localfontfileloader;
|
|
|
|
struct list localfontfaces;
|
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
struct list collection_loaders;
|
2014-10-20 10:53:21 +02:00
|
|
|
struct list file_loaders;
|
2014-08-06 23:59:39 +02:00
|
|
|
};
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static inline struct dwritefactory *impl_from_IDWriteFactory3(IDWriteFactory3 *iface)
|
2014-08-06 23:59:39 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
return CONTAINING_RECORD(iface, struct dwritefactory, IDWriteFactory3_iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
}
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
static void release_fontface_cache(struct list *fontfaces)
|
|
|
|
{
|
|
|
|
struct fontfacecached *fontface, *fontface2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(fontface, fontface2, fontfaces, struct fontfacecached, entry) {
|
|
|
|
list_remove(&fontface->entry);
|
|
|
|
IDWriteFontFace_Release(fontface->fontface);
|
|
|
|
heap_free(fontface);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_fileloader(struct fileloader *fileloader)
|
|
|
|
{
|
|
|
|
list_remove(&fileloader->entry);
|
|
|
|
release_fontface_cache(&fileloader->fontfaces);
|
|
|
|
IDWriteFontFileLoader_Release(fileloader->loader);
|
|
|
|
heap_free(fileloader);
|
|
|
|
}
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
static void release_dwritefactory(struct dwritefactory *factory)
|
|
|
|
{
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader *fileloader, *fileloader2;
|
2014-10-20 10:50:27 +02:00
|
|
|
struct collectionloader *loader, *loader2;
|
2014-10-09 07:05:27 +02:00
|
|
|
|
|
|
|
if (factory->localfontfileloader)
|
|
|
|
IDWriteLocalFontFileLoader_Release(factory->localfontfileloader);
|
2014-10-24 09:40:06 +02:00
|
|
|
release_fontface_cache(&factory->localfontfaces);
|
2014-10-20 10:50:27 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(loader, loader2, &factory->collection_loaders, struct collectionloader, entry) {
|
|
|
|
list_remove(&loader->entry);
|
|
|
|
IDWriteFontCollectionLoader_Release(loader->loader);
|
|
|
|
heap_free(loader);
|
|
|
|
}
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(fileloader, fileloader2, &factory->file_loaders, struct fileloader, entry)
|
|
|
|
release_fileloader(fileloader);
|
2014-10-20 10:53:21 +02:00
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
if (factory->system_collection)
|
|
|
|
IDWriteFontCollection_Release(factory->system_collection);
|
2014-12-17 07:54:13 +01:00
|
|
|
if (factory->eudc_collection)
|
|
|
|
IDWriteFontCollection_Release(factory->eudc_collection);
|
2016-02-14 17:05:06 +01:00
|
|
|
if (factory->fallback)
|
|
|
|
release_system_fontfallback(factory->fallback);
|
2014-10-09 07:05:27 +02:00
|
|
|
heap_free(factory);
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static void release_shared_factory(IDWriteFactory3 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
|
|
|
struct dwritefactory *factory;
|
|
|
|
if (!iface) return;
|
2016-03-28 12:33:57 +02:00
|
|
|
factory = impl_from_IDWriteFactory3(iface);
|
2014-10-09 07:05:27 +02:00
|
|
|
release_dwritefactory(factory);
|
|
|
|
}
|
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
static struct fileloader *factory_get_file_loader(struct dwritefactory *factory, IDWriteFontFileLoader *loader)
|
|
|
|
{
|
|
|
|
struct fileloader *entry, *found = NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(entry, &factory->file_loaders, struct fileloader, entry) {
|
|
|
|
if (entry->loader == loader) {
|
|
|
|
found = entry;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2014-10-24 09:41:46 +02:00
|
|
|
static struct collectionloader *factory_get_collection_loader(struct dwritefactory *factory, IDWriteFontCollectionLoader *loader)
|
|
|
|
{
|
|
|
|
struct collectionloader *entry, *found = NULL;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(entry, &factory->collection_loaders, struct collectionloader, entry) {
|
|
|
|
if (entry->loader == loader) {
|
|
|
|
found = entry;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory3 *iface, REFIID riid, void **obj)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
2012-07-31 06:07:49 +02:00
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFactory3) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory2) ||
|
2014-12-09 14:31:00 +01:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory1) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
2012-07-31 06:07:49 +02:00
|
|
|
*obj = iface;
|
2016-03-28 12:33:57 +02:00
|
|
|
IDWriteFactory3_AddRef(iface);
|
2012-07-31 06:07:49 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static ULONG WINAPI dwritefactory_AddRef(IDWriteFactory3 *iface)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
return ref;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static ULONG WINAPI dwritefactory_Release(IDWriteFactory3 *iface)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref);
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
if (!ref)
|
|
|
|
release_dwritefactory(This);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
|
|
|
return ref;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollection **collection, BOOL check_for_updates)
|
|
|
|
{
|
2014-09-02 14:17:57 +02:00
|
|
|
HRESULT hr = S_OK;
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%p %d)\n", This, collection, check_for_updates);
|
2012-10-21 06:24:35 +02:00
|
|
|
|
|
|
|
if (check_for_updates)
|
|
|
|
FIXME("checking for system font updates not implemented\n");
|
|
|
|
|
2014-09-02 14:17:57 +02:00
|
|
|
if (!This->system_collection)
|
2014-10-29 20:41:47 +01:00
|
|
|
hr = get_system_fontcollection(iface, &This->system_collection);
|
2014-09-02 14:17:57 +02:00
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IDWriteFontCollection_AddRef(This->system_collection);
|
|
|
|
|
|
|
|
*collection = This->system_collection;
|
|
|
|
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader, void const *key, UINT32 key_size, IDWriteFontCollection **collection)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFileEnumerator *enumerator;
|
|
|
|
struct collectionloader *found;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %u %p)\n", This, loader, key, key_size, collection);
|
|
|
|
|
|
|
|
*collection = NULL;
|
|
|
|
|
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
found = factory_get_collection_loader(This, loader);
|
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-12-09 14:31:00 +01:00
|
|
|
hr = IDWriteFontCollectionLoader_CreateEnumeratorFromKey(found->loader, (IDWriteFactory*)iface, key, key_size, &enumerator);
|
2014-10-24 09:43:21 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2014-11-07 11:17:38 +01:00
|
|
|
hr = create_font_collection(iface, enumerator, FALSE, collection);
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFileEnumerator_Release(enumerator);
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-20 10:50:27 +02:00
|
|
|
struct collectionloader *entry;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, loader);
|
|
|
|
|
2014-10-08 12:49:12 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-24 09:41:46 +02:00
|
|
|
if (factory_get_collection_loader(This, loader))
|
|
|
|
return DWRITE_E_ALREADYREGISTERED;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
entry = heap_alloc(sizeof(*entry));
|
|
|
|
if (!entry)
|
|
|
|
return E_OUTOFMEMORY;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
entry->loader = loader;
|
2014-08-07 00:01:09 +02:00
|
|
|
IDWriteFontCollectionLoader_AddRef(loader);
|
2014-10-20 10:50:27 +02:00
|
|
|
list_add_tail(&This->collection_loaders, &entry->entry);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-24 09:41:46 +02:00
|
|
|
struct collectionloader *found;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, loader);
|
|
|
|
|
2014-10-08 12:49:12 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-24 09:41:46 +02:00
|
|
|
found = factory_get_collection_loader(This, loader);
|
2014-10-20 10:50:27 +02:00
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
IDWriteFontCollectionLoader_Release(found->loader);
|
|
|
|
list_remove(&found->entry);
|
|
|
|
heap_free(found);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
WCHAR const *path, FILETIME const *writetime, IDWriteFontFile **font_file)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-11-15 17:19:00 +01:00
|
|
|
UINT32 key_size;
|
|
|
|
HRESULT hr;
|
|
|
|
void *key;
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(path), writetime, font_file);
|
|
|
|
|
2016-04-20 09:50:59 +02:00
|
|
|
*font_file = NULL;
|
|
|
|
|
2014-08-26 17:11:59 +02:00
|
|
|
if (!This->localfontfileloader)
|
|
|
|
{
|
|
|
|
hr = create_localfontfileloader(&This->localfontfileloader);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
2014-11-15 17:19:00 +01:00
|
|
|
|
|
|
|
/* get a reference key used by local loader */
|
|
|
|
hr = get_local_refkey(path, writetime, &key, &key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = create_font_file((IDWriteFontFileLoader*)This->localfontfileloader, key, key_size, font_file);
|
|
|
|
heap_free(key);
|
|
|
|
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory3 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-12 21:11:34 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %u %p %p)\n", This, reference_key, key_size, loader, font_file);
|
2016-01-28 21:27:20 +01:00
|
|
|
|
|
|
|
*font_file = NULL;
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2016-04-20 09:51:00 +02:00
|
|
|
/* local loader is accepted as well */
|
|
|
|
if (!loader || !(factory_get_file_loader(This, loader) ||
|
|
|
|
(IDWriteFontFileLoader*)This->localfontfileloader == loader))
|
2014-08-12 21:11:34 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
return create_font_file(loader, reference_key, key_size, font_file);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory3 *iface,
|
2014-12-11 10:33:29 +01:00
|
|
|
DWRITE_FONT_FACE_TYPE req_facetype, UINT32 files_number, IDWriteFontFile* const* font_files,
|
2014-10-24 09:40:06 +02:00
|
|
|
UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFace **font_face)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-12-11 10:33:29 +01:00
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
2014-10-24 09:40:06 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
|
|
|
struct fontfacecached *cached;
|
|
|
|
struct list *fontfaces;
|
2016-03-03 06:16:25 +01:00
|
|
|
IDWriteFontFace3 *face;
|
2014-12-11 10:33:29 +01:00
|
|
|
UINT32 key_size, count;
|
|
|
|
BOOL is_supported;
|
2014-10-24 09:40:06 +02:00
|
|
|
const void *key;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-12-11 10:33:29 +01:00
|
|
|
TRACE("(%p)->(%d %u %p %u 0x%x %p)\n", This, req_facetype, files_number, font_files, index, simulations, font_face);
|
2014-10-24 09:40:06 +02:00
|
|
|
|
|
|
|
*font_face = NULL;
|
|
|
|
|
2014-12-11 10:33:29 +01:00
|
|
|
if (!is_face_type_supported(req_facetype))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (req_facetype != DWRITE_FONT_FACE_TYPE_TRUETYPE_COLLECTION && index)
|
2014-10-24 09:40:06 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-05-05 13:35:24 +02:00
|
|
|
if (!is_simulation_valid(simulations))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-12-11 10:33:29 +01:00
|
|
|
/* check actual file/face type */
|
|
|
|
is_supported = FALSE;
|
|
|
|
face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
|
|
|
|
hr = IDWriteFontFile_Analyze(*font_files, &is_supported, &file_type, &face_type, &count);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2015-09-04 11:15:41 +02:00
|
|
|
if (!is_supported)
|
2014-12-11 10:33:29 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2015-09-04 11:15:41 +02:00
|
|
|
if (face_type != req_facetype)
|
|
|
|
return DWRITE_E_FILEFORMAT;
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
hr = IDWriteFontFile_GetReferenceKey(*font_files, &key, &key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetLoader(*font_files, &loader);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (loader == (IDWriteFontFileLoader*)This->localfontfileloader) {
|
|
|
|
fontfaces = &This->localfontfaces;
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
struct fileloader *fileloader = factory_get_file_loader(This, loader);
|
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
if (!fileloader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
fontfaces = &fileloader->fontfaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* search through cache list */
|
|
|
|
LIST_FOR_EACH_ENTRY(cached, fontfaces, struct fontfacecached, entry) {
|
|
|
|
UINT32 cached_key_size, count = 1, cached_face_index;
|
|
|
|
DWRITE_FONT_SIMULATIONS cached_simulations;
|
|
|
|
const void *cached_key;
|
|
|
|
IDWriteFontFile *file;
|
|
|
|
|
|
|
|
cached_face_index = IDWriteFontFace_GetIndex(cached->fontface);
|
|
|
|
cached_simulations = IDWriteFontFace_GetSimulations(cached->fontface);
|
|
|
|
|
|
|
|
/* skip earlier */
|
|
|
|
if (cached_face_index != index || cached_simulations != simulations)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hr = IDWriteFontFace_GetFiles(cached->fontface, &count, &file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &cached_key, &cached_key_size);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
if (cached_key_size == key_size && !memcmp(cached_key, key, key_size)) {
|
|
|
|
TRACE("returning cached fontface %p\n", cached->fontface);
|
|
|
|
*font_face = cached->fontface;
|
|
|
|
IDWriteFontFace_AddRef(*font_face);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-11 10:33:29 +01:00
|
|
|
hr = create_fontface(req_facetype, files_number, font_files, index, simulations, &face);
|
2014-10-24 09:40:06 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
/* new cache entry */
|
|
|
|
cached = heap_alloc(sizeof(*cached));
|
|
|
|
if (!cached) {
|
2016-03-03 06:16:25 +01:00
|
|
|
IDWriteFontFace3_Release(face);
|
2016-03-07 15:09:55 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2014-10-24 09:40:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cached->fontface = (IDWriteFontFace*)face;
|
|
|
|
list_add_tail(fontfaces, &cached->entry);
|
|
|
|
|
|
|
|
*font_face = cached->fontface;
|
|
|
|
IDWriteFontFace_AddRef(*font_face);
|
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory3 *iface, IDWriteRenderingParams **params)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2012-10-01 07:35:00 +02:00
|
|
|
HMONITOR monitor;
|
|
|
|
POINT pt;
|
|
|
|
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, params);
|
2012-10-01 07:35:00 +02:00
|
|
|
|
|
|
|
pt.x = pt.y = 0;
|
|
|
|
monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
2016-03-28 12:33:57 +02:00
|
|
|
return IDWriteFactory3_CreateMonitorRenderingParams(iface, monitor, params);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateMonitorRenderingParams(IDWriteFactory3 *iface, HMONITOR monitor,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteRenderingParams **params)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
2012-10-01 07:29:35 +02:00
|
|
|
static int fixme_once = 0;
|
2015-03-31 10:39:59 +02:00
|
|
|
HRESULT hr;
|
2012-10-01 07:29:35 +02:00
|
|
|
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, monitor, params);
|
2012-10-01 07:29:35 +02:00
|
|
|
|
|
|
|
if (!fixme_once++)
|
|
|
|
FIXME("(%p): monitor setting ignored\n", monitor);
|
2015-03-31 10:39:59 +02:00
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(iface, 0.0f, 0.0f, 1.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT, DWRITE_RENDERING_MODE_DEFAULT,
|
|
|
|
DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
|
|
|
*params = (IDWriteRenderingParams*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory3 *iface, FLOAT gamma, FLOAT enhancedContrast,
|
2012-07-31 06:07:49 +02:00
|
|
|
FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode, IDWriteRenderingParams **params)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%f %f %f %d %d %p)\n", This, gamma, enhancedContrast, cleartype_level, geometry, mode, params);
|
2015-03-31 10:39:59 +02:00
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(iface, gamma, enhancedContrast, 1.0f, cleartype_level, geometry,
|
|
|
|
mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
|
|
|
*params = (IDWriteRenderingParams*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory3 *iface, IDWriteFontFileLoader *loader)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader *entry;
|
|
|
|
|
2014-08-12 21:11:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, loader);
|
|
|
|
|
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-27 09:24:47 +01:00
|
|
|
if ((IDWriteFontFileLoader*)This->localfontfileloader == loader)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-10-24 09:41:46 +02:00
|
|
|
if (factory_get_file_loader(This, loader))
|
|
|
|
return DWRITE_E_ALREADYREGISTERED;
|
2014-10-20 10:53:21 +02:00
|
|
|
|
|
|
|
entry = heap_alloc(sizeof(*entry));
|
|
|
|
if (!entry)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
entry->loader = loader;
|
2014-10-24 09:40:06 +02:00
|
|
|
list_init(&entry->fontfaces);
|
2014-08-12 21:11:30 +02:00
|
|
|
IDWriteFontFileLoader_AddRef(loader);
|
2014-10-20 10:53:21 +02:00
|
|
|
list_add_tail(&This->file_loaders, &entry->entry);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory3 *iface, IDWriteFontFileLoader *loader)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader *found;
|
|
|
|
|
2014-08-12 21:11:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, loader);
|
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-27 09:24:47 +01:00
|
|
|
if ((IDWriteFontFileLoader*)This->localfontfileloader == loader)
|
|
|
|
return S_OK;
|
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
found = factory_get_file_loader(This, loader);
|
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
release_fileloader(found);
|
2014-08-12 21:11:30 +02:00
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory3 *iface, WCHAR const* family_name,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style,
|
|
|
|
DWRITE_FONT_STRETCH stretch, FLOAT size, WCHAR const *locale, IDWriteTextFormat **format)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-12-16 15:59:44 +01:00
|
|
|
IDWriteFontCollection *syscollection = NULL;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%s %p %d %d %d %f %s %p)\n", This, debugstr_w(family_name), collection, weight, style, stretch,
|
2012-07-31 06:07:49 +02:00
|
|
|
size, debugstr_w(locale), format);
|
2014-09-02 14:17:57 +02:00
|
|
|
|
2014-12-16 15:59:44 +01:00
|
|
|
if (!collection) {
|
2016-03-28 12:33:57 +02:00
|
|
|
hr = IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2*)iface, &syscollection, FALSE);
|
2014-12-16 15:59:44 +01:00
|
|
|
if (FAILED(hr))
|
2014-09-02 14:17:57 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2014-12-16 15:59:44 +01:00
|
|
|
|
|
|
|
hr = create_textformat(family_name, collection ? collection : syscollection, weight, style, stretch, size, locale, format);
|
|
|
|
if (syscollection)
|
|
|
|
IDWriteFontCollection_Release(syscollection);
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory3 *iface, IDWriteTypography **typography)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-09-19 05:54:00 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, typography);
|
|
|
|
return create_typography(typography);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory3 *iface, IDWriteGdiInterop **gdi_interop)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, gdi_interop);
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2016-05-03 11:56:57 +02:00
|
|
|
*gdi_interop = (IDWriteGdiInterop*)&This->interop.IDWriteGdiInterop1_iface;
|
2014-10-19 21:57:53 +02:00
|
|
|
IDWriteGdiInterop_AddRef(*gdi_interop);
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory3 *iface, WCHAR const* string,
|
2016-04-27 10:19:41 +02:00
|
|
|
UINT32 length, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-27 10:19:41 +02:00
|
|
|
struct textlayout_desc desc;
|
2016-01-28 02:17:15 +01:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
TRACE("(%p)->(%s:%u %p %f %f %p)\n", This, debugstr_wn(string, length), length, format, max_width, max_height, layout);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.factory = iface;
|
|
|
|
desc.string = string;
|
|
|
|
desc.length = length;
|
|
|
|
desc.format = format;
|
|
|
|
desc.max_width = max_width;
|
|
|
|
desc.max_height = max_height;
|
|
|
|
desc.is_gdi_compatible = FALSE;
|
|
|
|
desc.ppdip = 1.0f;
|
|
|
|
desc.transform = NULL;
|
|
|
|
desc.use_gdi_natural = FALSE;
|
|
|
|
return create_textlayout(&desc, layout);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory3 *iface, WCHAR const* string,
|
2016-04-27 10:19:41 +02:00
|
|
|
UINT32 length, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, FLOAT pixels_per_dip,
|
2012-07-31 06:07:49 +02:00
|
|
|
DWRITE_MATRIX const* transform, BOOL use_gdi_natural, IDWriteTextLayout **layout)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-27 10:19:41 +02:00
|
|
|
struct textlayout_desc desc;
|
2015-01-08 22:35:14 +01:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
TRACE("(%p)->(%s:%u %p %f %f %f %p %d %p)\n", This, debugstr_wn(string, length), length, format, max_width, max_height,
|
2012-07-31 06:07:49 +02:00
|
|
|
pixels_per_dip, transform, use_gdi_natural, layout);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.factory = iface;
|
|
|
|
desc.string = string;
|
|
|
|
desc.length = length;
|
|
|
|
desc.format = format;
|
|
|
|
desc.max_width = max_width;
|
|
|
|
desc.max_height = max_height;
|
|
|
|
desc.is_gdi_compatible = TRUE;
|
|
|
|
desc.ppdip = pixels_per_dip;
|
|
|
|
desc.transform = transform;
|
|
|
|
desc.use_gdi_natural = use_gdi_natural;
|
|
|
|
return create_textlayout(&desc, layout);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory3 *iface, IDWriteTextFormat *format,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2015-06-14 23:39:32 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, format, trimming_sign);
|
2015-06-15 00:13:00 +02:00
|
|
|
return create_trimmingsign(iface, format, trimming_sign);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory3 *iface, IDWriteTextAnalyzer **analyzer)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-08-06 23:59:39 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, analyzer);
|
2012-10-28 22:58:10 +01:00
|
|
|
return get_textanalyzer(analyzer);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory3 *iface, DWRITE_NUMBER_SUBSTITUTION_METHOD method,
|
2012-07-31 06:07:49 +02:00
|
|
|
WCHAR const* locale, BOOL ignore_user_override, IDWriteNumberSubstitution **substitution)
|
2012-07-29 10:50:34 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-01 14:14:41 +02:00
|
|
|
TRACE("(%p)->(%d %s %d %p)\n", This, method, debugstr_w(locale), ignore_user_override, substitution);
|
|
|
|
return create_numbersubstitution(method, locale, ignore_user_override, substitution);
|
2012-07-29 10:50:34 +02:00
|
|
|
}
|
2012-07-31 06:07:49 +02:00
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory3 *iface, DWRITE_GLYPH_RUN const *run,
|
2015-07-29 10:57:52 +02:00
|
|
|
FLOAT ppdip, DWRITE_MATRIX const* transform, DWRITE_RENDERING_MODE rendering_mode,
|
2015-07-31 00:29:39 +02:00
|
|
|
DWRITE_MEASURING_MODE measuring_mode, FLOAT originX, FLOAT originY, IDWriteGlyphRunAnalysis **analysis)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-27 10:19:41 +02:00
|
|
|
struct glyphrunanalysis_desc desc;
|
2015-05-19 14:23:57 +02:00
|
|
|
|
2015-07-31 00:29:39 +02:00
|
|
|
TRACE("(%p)->(%p %.2f %p %d %d %.2f %.2f %p)\n", This, run, ppdip, transform, rendering_mode,
|
|
|
|
measuring_mode, originX, originY, analysis);
|
2015-05-19 14:23:57 +02:00
|
|
|
|
2015-10-16 12:21:53 +02:00
|
|
|
if (ppdip <= 0.0f) {
|
|
|
|
*analysis = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.run = run;
|
|
|
|
desc.ppdip = ppdip;
|
|
|
|
desc.transform = transform;
|
|
|
|
desc.rendering_mode = rendering_mode;
|
|
|
|
desc.measuring_mode = measuring_mode;
|
|
|
|
desc.gridfit_mode = DWRITE_GRID_FIT_MODE_DEFAULT;
|
|
|
|
desc.aa_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
|
|
|
|
desc.origin_x = originX;
|
|
|
|
desc.origin_y = originY;
|
|
|
|
return create_glyphrunanalysis(&desc, analysis);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory3 *iface, IDWriteFontCollection **collection,
|
2014-12-09 14:31:00 +01:00
|
|
|
BOOL check_for_updates)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-12-17 07:54:13 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %d)\n", This, collection, check_for_updates);
|
|
|
|
|
|
|
|
if (check_for_updates)
|
|
|
|
FIXME("checking for eudc updates not implemented\n");
|
|
|
|
|
|
|
|
if (!This->eudc_collection)
|
|
|
|
hr = get_eudc_fontcollection(iface, &This->eudc_collection);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
IDWriteFontCollection_AddRef(This->eudc_collection);
|
|
|
|
|
|
|
|
*collection = This->eudc_collection;
|
|
|
|
|
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory1_CreateCustomRenderingParams(IDWriteFactory3 *iface, FLOAT gamma,
|
2014-12-09 14:31:00 +01:00
|
|
|
FLOAT enhcontrast, FLOAT enhcontrast_grayscale, FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry,
|
|
|
|
DWRITE_RENDERING_MODE mode, IDWriteRenderingParams1** params)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %p)\n", This, gamma, enhcontrast, enhcontrast_grayscale,
|
2014-12-09 14:31:00 +01:00
|
|
|
cleartype_level, geometry, mode, params);
|
2016-04-19 08:39:25 +02:00
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(iface, gamma, enhcontrast, enhcontrast_grayscale,
|
|
|
|
cleartype_level, geometry, mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
|
|
|
*params = (IDWriteRenderingParams1*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory2_GetSystemFontFallback(IDWriteFactory3 *iface, IDWriteFontFallback **fallback)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-02-14 17:05:06 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, fallback);
|
|
|
|
|
|
|
|
*fallback = NULL;
|
|
|
|
|
|
|
|
if (!This->fallback) {
|
|
|
|
HRESULT hr = create_system_fontfallback(iface, &This->fallback);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*fallback = This->fallback;
|
|
|
|
IDWriteFontFallback_AddRef(*fallback);
|
|
|
|
return S_OK;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory3 *iface, IDWriteFontFallbackBuilder **fallbackbuilder)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-12-09 14:31:00 +01:00
|
|
|
FIXME("(%p)->(%p): stub\n", This, fallbackbuilder);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory2_TranslateColorGlyphRun(IDWriteFactory3 *iface, FLOAT originX, FLOAT originY,
|
2014-12-09 14:31:00 +01:00
|
|
|
const DWRITE_GLYPH_RUN *run, const DWRITE_GLYPH_RUN_DESCRIPTION *rundescr, DWRITE_MEASURING_MODE mode,
|
2015-08-06 18:44:53 +02:00
|
|
|
const DWRITE_MATRIX *transform, UINT32 palette, IDWriteColorGlyphRunEnumerator **colorlayers)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2015-08-06 18:44:53 +02:00
|
|
|
TRACE("(%p)->(%.2f %.2f %p %p %d %p %u %p)\n", This, originX, originY, run, rundescr, mode,
|
|
|
|
transform, palette, colorlayers);
|
|
|
|
return create_colorglyphenum(originX, originY, run, rundescr, mode, transform, palette, colorlayers);
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateCustomRenderingParams(IDWriteFactory3 *iface, FLOAT gamma, FLOAT contrast,
|
2015-03-31 10:39:59 +02:00
|
|
|
FLOAT grayscalecontrast, FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode,
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit, IDWriteRenderingParams2 **params)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-03-31 10:39:59 +02:00
|
|
|
TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This, gamma, contrast, grayscalecontrast, cleartype_level,
|
|
|
|
geometry, mode, gridfit, params);
|
2016-04-19 08:39:25 +02:00
|
|
|
|
|
|
|
hr = IDWriteFactory3_CreateCustomRenderingParams(iface, gamma, contrast, grayscalecontrast,
|
|
|
|
cleartype_level, geometry, mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
|
|
|
*params = (IDWriteRenderingParams2*)params3;
|
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateGlyphRunAnalysis(IDWriteFactory3 *iface, const DWRITE_GLYPH_RUN *run,
|
2015-08-06 18:42:48 +02:00
|
|
|
const DWRITE_MATRIX *transform, DWRITE_RENDERING_MODE rendering_mode, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit_mode, DWRITE_TEXT_ANTIALIAS_MODE aa_mode, FLOAT originX, FLOAT originY,
|
2014-12-09 14:31:00 +01:00
|
|
|
IDWriteGlyphRunAnalysis **analysis)
|
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-27 10:19:41 +02:00
|
|
|
struct glyphrunanalysis_desc desc;
|
2015-08-06 18:42:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %d %d %d %d %.2f %.2f %p)\n", This, run, transform, rendering_mode, measuring_mode,
|
|
|
|
gridfit_mode, aa_mode, originX, originY, analysis);
|
|
|
|
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.run = run;
|
|
|
|
desc.ppdip = 1.0f;
|
|
|
|
desc.transform = transform;
|
|
|
|
desc.rendering_mode = rendering_mode;
|
|
|
|
desc.measuring_mode = measuring_mode;
|
|
|
|
desc.gridfit_mode = gridfit_mode;
|
|
|
|
desc.aa_mode = aa_mode;
|
|
|
|
desc.origin_x = originX;
|
|
|
|
desc.origin_y = originY;
|
|
|
|
return create_glyphrunanalysis(&desc, analysis);
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory3 *iface, DWRITE_GLYPH_RUN const *run,
|
|
|
|
DWRITE_MATRIX const *transform, DWRITE_RENDERING_MODE1 rendering_mode, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit_mode, DWRITE_TEXT_ANTIALIAS_MODE aa_mode, FLOAT originX, FLOAT originY,
|
|
|
|
IDWriteGlyphRunAnalysis **analysis)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p %p %d %d %d %d %.2f %.2f %p): stub\n", This, run, transform, rendering_mode, measuring_mode,
|
|
|
|
gridfit_mode, aa_mode, originX, originY, analysis);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_CreateCustomRenderingParams(IDWriteFactory3 *iface, FLOAT gamma, FLOAT contrast,
|
|
|
|
FLOAT grayscale_contrast, FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY pixel_geometry, DWRITE_RENDERING_MODE1 rendering_mode,
|
|
|
|
DWRITE_GRID_FIT_MODE gridfit_mode, IDWriteRenderingParams3 **params)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
TRACE("(%p)->(%.2f %.2f %.2f %.2f %d %d %d %p)\n", This, gamma, contrast, grayscale_contrast, cleartype_level,
|
2016-03-28 12:33:57 +02:00
|
|
|
pixel_geometry, rendering_mode, gridfit_mode, params);
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
return create_renderingparams(gamma, contrast, grayscale_contrast, cleartype_level, pixel_geometry, rendering_mode,
|
|
|
|
gridfit_mode, params);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory3 *iface, IDWriteFontFile *file, UINT32 index,
|
|
|
|
DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
2016-04-20 09:51:01 +02:00
|
|
|
TRACE("(%p)->(%p %u %x %p)\n", This, file, index, simulations, reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2016-04-20 09:51:01 +02:00
|
|
|
return create_fontfacereference(iface, file, index, simulations, reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:27 +02:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory3 *iface, WCHAR const *path, FILETIME const *writetime,
|
|
|
|
UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFile *file;
|
|
|
|
HRESULT hr;
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2016-04-20 09:51:01 +02:00
|
|
|
TRACE("(%p)->(%s %p %u %x, %p)\n", This, debugstr_w(path), writetime, index, simulations, reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2016-04-20 09:51:01 +02:00
|
|
|
hr = IDWriteFactory3_CreateFontFileReference(iface, path, writetime, &file);
|
|
|
|
if (FAILED(hr)) {
|
|
|
|
*reference = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IDWriteFactory3_CreateFontFaceReference_(iface, file, index, simulations, reference);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
return hr;
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_GetSystemFontSet(IDWriteFactory3 *iface, IDWriteFontSet **fontset)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, fontset);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontSetBuilder(IDWriteFactory3 *iface, IDWriteFontSetBuilder **builder)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, builder);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory3 *iface, IDWriteFontSet *fontset,
|
|
|
|
IDWriteFontCollection1 **collection)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p %p): stub\n", This, fontset, collection);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_GetSystemFontCollection(IDWriteFactory3 *iface, BOOL include_downloadable,
|
|
|
|
IDWriteFontCollection1 **collection, BOOL check_for_updates)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%d %p %d): stub\n", This, include_downloadable, collection, check_for_updates);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory3_GetFontDownloadQueue(IDWriteFactory3 *iface, IDWriteFontDownloadQueue **queue)
|
|
|
|
{
|
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, queue);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IDWriteFactory3Vtbl dwritefactoryvtbl = {
|
2012-07-31 06:07:49 +02:00
|
|
|
dwritefactory_QueryInterface,
|
|
|
|
dwritefactory_AddRef,
|
|
|
|
dwritefactory_Release,
|
|
|
|
dwritefactory_GetSystemFontCollection,
|
|
|
|
dwritefactory_CreateCustomFontCollection,
|
|
|
|
dwritefactory_RegisterFontCollectionLoader,
|
|
|
|
dwritefactory_UnregisterFontCollectionLoader,
|
|
|
|
dwritefactory_CreateFontFileReference,
|
|
|
|
dwritefactory_CreateCustomFontFileReference,
|
|
|
|
dwritefactory_CreateFontFace,
|
|
|
|
dwritefactory_CreateRenderingParams,
|
|
|
|
dwritefactory_CreateMonitorRenderingParams,
|
|
|
|
dwritefactory_CreateCustomRenderingParams,
|
|
|
|
dwritefactory_RegisterFontFileLoader,
|
|
|
|
dwritefactory_UnregisterFontFileLoader,
|
|
|
|
dwritefactory_CreateTextFormat,
|
|
|
|
dwritefactory_CreateTypography,
|
|
|
|
dwritefactory_GetGdiInterop,
|
|
|
|
dwritefactory_CreateTextLayout,
|
|
|
|
dwritefactory_CreateGdiCompatibleTextLayout,
|
|
|
|
dwritefactory_CreateEllipsisTrimmingSign,
|
|
|
|
dwritefactory_CreateTextAnalyzer,
|
|
|
|
dwritefactory_CreateNumberSubstitution,
|
2014-12-09 14:31:00 +01:00
|
|
|
dwritefactory_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory1_GetEudcFontCollection,
|
|
|
|
dwritefactory1_CreateCustomRenderingParams,
|
|
|
|
dwritefactory2_GetSystemFontFallback,
|
|
|
|
dwritefactory2_CreateFontFallbackBuilder,
|
|
|
|
dwritefactory2_TranslateColorGlyphRun,
|
|
|
|
dwritefactory2_CreateCustomRenderingParams,
|
2016-03-28 12:33:57 +02:00
|
|
|
dwritefactory2_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory3_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory3_CreateCustomRenderingParams,
|
|
|
|
dwritefactory3_CreateFontFaceReference_,
|
2016-04-19 08:39:27 +02:00
|
|
|
dwritefactory3_CreateFontFaceReference,
|
2016-03-28 12:33:57 +02:00
|
|
|
dwritefactory3_GetSystemFontSet,
|
|
|
|
dwritefactory3_CreateFontSetBuilder,
|
|
|
|
dwritefactory3_CreateFontCollectionFromFontSet,
|
|
|
|
dwritefactory3_GetSystemFontCollection,
|
|
|
|
dwritefactory3_GetFontDownloadQueue
|
2012-07-31 06:07:49 +02:00
|
|
|
};
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static ULONG WINAPI shareddwritefactory_AddRef(IDWriteFactory3 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-09 07:05:27 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static ULONG WINAPI shareddwritefactory_Release(IDWriteFactory3 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
|
2014-10-09 07:05:27 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
static const struct IDWriteFactory3Vtbl shareddwritefactoryvtbl = {
|
2014-10-09 07:05:27 +02:00
|
|
|
dwritefactory_QueryInterface,
|
|
|
|
shareddwritefactory_AddRef,
|
|
|
|
shareddwritefactory_Release,
|
|
|
|
dwritefactory_GetSystemFontCollection,
|
|
|
|
dwritefactory_CreateCustomFontCollection,
|
|
|
|
dwritefactory_RegisterFontCollectionLoader,
|
|
|
|
dwritefactory_UnregisterFontCollectionLoader,
|
|
|
|
dwritefactory_CreateFontFileReference,
|
|
|
|
dwritefactory_CreateCustomFontFileReference,
|
|
|
|
dwritefactory_CreateFontFace,
|
|
|
|
dwritefactory_CreateRenderingParams,
|
|
|
|
dwritefactory_CreateMonitorRenderingParams,
|
|
|
|
dwritefactory_CreateCustomRenderingParams,
|
|
|
|
dwritefactory_RegisterFontFileLoader,
|
|
|
|
dwritefactory_UnregisterFontFileLoader,
|
|
|
|
dwritefactory_CreateTextFormat,
|
|
|
|
dwritefactory_CreateTypography,
|
|
|
|
dwritefactory_GetGdiInterop,
|
|
|
|
dwritefactory_CreateTextLayout,
|
|
|
|
dwritefactory_CreateGdiCompatibleTextLayout,
|
|
|
|
dwritefactory_CreateEllipsisTrimmingSign,
|
|
|
|
dwritefactory_CreateTextAnalyzer,
|
|
|
|
dwritefactory_CreateNumberSubstitution,
|
2014-12-09 14:31:00 +01:00
|
|
|
dwritefactory_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory1_GetEudcFontCollection,
|
|
|
|
dwritefactory1_CreateCustomRenderingParams,
|
|
|
|
dwritefactory2_GetSystemFontFallback,
|
|
|
|
dwritefactory2_CreateFontFallbackBuilder,
|
|
|
|
dwritefactory2_TranslateColorGlyphRun,
|
|
|
|
dwritefactory2_CreateCustomRenderingParams,
|
2016-03-28 12:33:57 +02:00
|
|
|
dwritefactory2_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory3_CreateGlyphRunAnalysis,
|
|
|
|
dwritefactory3_CreateCustomRenderingParams,
|
|
|
|
dwritefactory3_CreateFontFaceReference_,
|
2016-04-19 08:39:27 +02:00
|
|
|
dwritefactory3_CreateFontFaceReference,
|
2016-03-28 12:33:57 +02:00
|
|
|
dwritefactory3_GetSystemFontSet,
|
|
|
|
dwritefactory3_CreateFontSetBuilder,
|
|
|
|
dwritefactory3_CreateFontCollectionFromFontSet,
|
|
|
|
dwritefactory3_GetSystemFontCollection,
|
|
|
|
dwritefactory3_GetFontDownloadQueue
|
2014-10-09 07:05:27 +02:00
|
|
|
};
|
|
|
|
|
2014-11-26 10:23:46 +01:00
|
|
|
static void init_dwritefactory(struct dwritefactory *factory, DWRITE_FACTORY_TYPE type)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
2016-03-28 12:33:57 +02:00
|
|
|
factory->IDWriteFactory3_iface.lpVtbl = type == DWRITE_FACTORY_TYPE_SHARED ? &shareddwritefactoryvtbl : &dwritefactoryvtbl;
|
2014-10-09 07:05:27 +02:00
|
|
|
factory->ref = 1;
|
|
|
|
factory->localfontfileloader = NULL;
|
|
|
|
factory->system_collection = NULL;
|
2014-12-17 07:54:13 +01:00
|
|
|
factory->eudc_collection = NULL;
|
2016-05-03 11:56:57 +02:00
|
|
|
gdiinterop_init(&factory->interop, &factory->IDWriteFactory3_iface);
|
2016-02-14 17:05:06 +01:00
|
|
|
factory->fallback = NULL;
|
2014-10-09 07:05:27 +02:00
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
list_init(&factory->collection_loaders);
|
2014-10-20 10:53:21 +02:00
|
|
|
list_init(&factory->file_loaders);
|
2014-10-24 09:40:06 +02:00
|
|
|
list_init(&factory->localfontfaces);
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI DWriteCreateFactory(DWRITE_FACTORY_TYPE type, REFIID riid, IUnknown **ret)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2014-10-09 07:05:27 +02:00
|
|
|
struct dwritefactory *factory;
|
2016-03-28 12:33:56 +02:00
|
|
|
HRESULT hr;
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
TRACE("(%d, %s, %p)\n", type, debugstr_guid(riid), ret);
|
|
|
|
|
|
|
|
*ret = NULL;
|
2012-07-31 06:07:49 +02:00
|
|
|
|
2016-03-28 12:33:56 +02:00
|
|
|
if (type == DWRITE_FACTORY_TYPE_SHARED && shared_factory)
|
2016-03-28 12:33:57 +02:00
|
|
|
return IDWriteFactory3_QueryInterface(shared_factory, riid, (void**)ret);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
factory = heap_alloc(sizeof(struct dwritefactory));
|
|
|
|
if (!factory) return E_OUTOFMEMORY;
|
|
|
|
|
2014-11-26 10:23:46 +01:00
|
|
|
init_dwritefactory(factory, type);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
if (type == DWRITE_FACTORY_TYPE_SHARED)
|
2016-03-28 12:33:57 +02:00
|
|
|
if (InterlockedCompareExchangePointer((void**)&shared_factory, &factory->IDWriteFactory3_iface, NULL)) {
|
|
|
|
release_shared_factory(&factory->IDWriteFactory3_iface);
|
|
|
|
return IDWriteFactory3_QueryInterface(shared_factory, riid, (void**)ret);
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
2012-07-31 06:07:49 +02:00
|
|
|
|
2016-03-28 12:33:57 +02:00
|
|
|
hr = IDWriteFactory3_QueryInterface(&factory->IDWriteFactory3_iface, riid, (void**)ret);
|
|
|
|
IDWriteFactory3_Release(&factory->IDWriteFactory3_iface);
|
2016-03-28 12:33:56 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|