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>
|
2017-04-07 13:06:12 +02:00
|
|
|
#include <math.h>
|
2012-07-24 12:05:18 +02:00
|
|
|
|
|
|
|
#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"
|
2021-12-08 12:10:42 +01:00
|
|
|
#include "unixlib.h"
|
2012-07-29 10:50:34 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
|
|
|
|
2021-03-29 09:48:51 +02:00
|
|
|
HMODULE dwrite_module = 0;
|
2021-12-08 12:10:42 +01:00
|
|
|
unixlib_handle_t unixlib_handle = 0;
|
2019-12-02 13:53:55 +01:00
|
|
|
static IDWriteFactory7 *shared_factory;
|
|
|
|
static void release_shared_factory(IDWriteFactory7 *factory);
|
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:
|
2021-03-29 09:48:51 +02:00
|
|
|
dwrite_module = hinstDLL;
|
2012-07-24 12:05:18 +02:00
|
|
|
DisableThreadLibraryCalls( hinstDLL );
|
2021-12-08 12:10:42 +01:00
|
|
|
if (!NtQueryVirtualMemory(GetCurrentProcess(), hinstDLL, MemoryWineUnixFuncs,
|
|
|
|
&unixlib_handle, sizeof(unixlib_handle), NULL))
|
|
|
|
UNIX_CALL(process_attach, NULL);
|
2017-09-24 23:08:40 +02:00
|
|
|
init_local_fontfile_loader();
|
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);
|
2021-12-08 12:10:42 +01:00
|
|
|
if (unixlib_handle) UNIX_CALL(process_detach, NULL);
|
2012-07-24 12:05:18 +02:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2012-07-29 10:50:34 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams
|
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 IDWriteRenderingParams3_iface;
|
2020-12-02 12:44:04 +01:00
|
|
|
LONG refcount;
|
2012-10-01 07:11:44 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
float gamma;
|
|
|
|
float contrast;
|
|
|
|
float grayscalecontrast;
|
|
|
|
float cleartype_level;
|
2012-10-01 07:11:44 +02:00
|
|
|
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
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-10-01 07:05:38 +02:00
|
|
|
|
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
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(¶ms->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static ULONG WINAPI renderingparams_Release(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(¶ms->refcount);
|
2012-10-01 07:05:38 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2012-10-01 07:05:38 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
if (!refcount)
|
2021-12-02 13:37:19 +01:00
|
|
|
free(params);
|
2012-10-01 07:05:38 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
return refcount;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
static float WINAPI renderingparams_GetGamma(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->gamma;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
static float WINAPI renderingparams_GetEnhancedContrast(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->contrast;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
static float WINAPI renderingparams_GetClearTypeLevel(IDWriteRenderingParams3 *iface)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->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
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->geometry;
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2017-02-03 13:20:28 +01:00
|
|
|
static DWRITE_RENDERING_MODE rendering_mode_from_mode1(DWRITE_RENDERING_MODE1 mode)
|
|
|
|
{
|
|
|
|
static const DWRITE_RENDERING_MODE rendering_modes[] = {
|
|
|
|
DWRITE_RENDERING_MODE_DEFAULT, /* DWRITE_RENDERING_MODE1_DEFAULT */
|
|
|
|
DWRITE_RENDERING_MODE_ALIASED, /* DWRITE_RENDERING_MODE1_ALIASED */
|
|
|
|
DWRITE_RENDERING_MODE_GDI_CLASSIC, /* DWRITE_RENDERING_MODE1_GDI_CLASSIC */
|
|
|
|
DWRITE_RENDERING_MODE_GDI_NATURAL, /* DWRITE_RENDERING_MODE1_GDI_NATURAL */
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL, /* DWRITE_RENDERING_MODE1_NATURAL */
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, /* DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC */
|
|
|
|
DWRITE_RENDERING_MODE_OUTLINE, /* DWRITE_RENDERING_MODE1_OUTLINE */
|
|
|
|
DWRITE_RENDERING_MODE_NATURAL_SYMMETRIC, /* DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC_DOWNSAMPLED */
|
|
|
|
};
|
|
|
|
|
|
|
|
return rendering_modes[mode];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
TRACE("%p.\n", iface);
|
2016-04-19 08:39:25 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
return rendering_mode_from_mode1(params->mode);
|
2012-10-01 07:05:38 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
static float WINAPI renderingparams1_GetGrayscaleEnhancedContrast(IDWriteRenderingParams3 *iface)
|
2015-03-31 10:39:59 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->grayscalecontrast;
|
2015-03-31 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->gridfit;
|
2015-03-31 10:39:59 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 08:39:25 +02:00
|
|
|
static DWRITE_RENDERING_MODE1 WINAPI renderingparams3_GetRenderingMode1(IDWriteRenderingParams3 *iface)
|
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *params = impl_from_IDWriteRenderingParams3(iface);
|
|
|
|
|
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
|
|
|
return params->mode;
|
2016-04-19 08:39:25 +02:00
|
|
|
}
|
|
|
|
|
2021-02-01 12:35:23 +01:00
|
|
|
static const IDWriteRenderingParams3Vtbl renderingparamsvtbl =
|
2020-12-02 12:44:04 +01:00
|
|
|
{
|
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
|
|
|
};
|
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
static HRESULT create_renderingparams(float gamma, float contrast, float grayscalecontrast, float cleartype_level,
|
2017-05-07 21:38:15 +02:00
|
|
|
DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE1 mode, DWRITE_GRID_FIT_MODE gridfit,
|
|
|
|
IDWriteRenderingParams3 **params)
|
2012-10-01 07:05:38 +02:00
|
|
|
{
|
2020-12-02 12:44:04 +01:00
|
|
|
struct renderingparams *object;
|
2012-10-01 07:05:38 +02:00
|
|
|
|
|
|
|
*params = NULL;
|
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
if (gamma <= 0.0f || contrast < 0.0f || grayscalecontrast < 0.0f || cleartype_level < 0.0f)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if ((UINT32)gridfit > DWRITE_GRID_FIT_MODE_ENABLED || (UINT32)geometry > DWRITE_PIXEL_GEOMETRY_BGR)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(object = malloc(sizeof(*object))))
|
2020-12-02 12:44:04 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2012-10-01 07:05:38 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
object->IDWriteRenderingParams3_iface.lpVtbl = &renderingparamsvtbl;
|
|
|
|
object->refcount = 1;
|
2012-10-01 07:05:38 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
object->gamma = gamma;
|
|
|
|
object->contrast = contrast;
|
|
|
|
object->grayscalecontrast = grayscalecontrast;
|
|
|
|
object->cleartype_level = cleartype_level;
|
|
|
|
object->geometry = geometry;
|
|
|
|
object->mode = mode;
|
|
|
|
object->gridfit = gridfit;
|
2012-10-01 07:11:44 +02:00
|
|
|
|
2020-12-02 12:44:04 +01:00
|
|
|
*params = &object->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;
|
|
|
|
};
|
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings
|
|
|
|
{
|
2012-10-07 19:11:04 +02:00
|
|
|
IDWriteLocalizedStrings IDWriteLocalizedStrings_iface;
|
2019-05-14 12:27:27 +02:00
|
|
|
LONG refcount;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
|
|
|
struct localizedpair *data;
|
2019-05-14 12:27:27 +02:00
|
|
|
size_t size;
|
|
|
|
size_t count;
|
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)
|
|
|
|
{
|
2020-12-02 12:44:03 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&strings->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI localizedstrings_Release(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&strings->refcount);
|
|
|
|
size_t i;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
TRACE("%p, refcount %d.\n", iface, refcount);
|
2012-10-07 23:13:29 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
if (!refcount)
|
|
|
|
{
|
|
|
|
for (i = 0; i < strings->count; ++i)
|
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
free(strings->data[i].locale);
|
|
|
|
free(strings->data[i].string);
|
2012-10-07 23:13:29 +02:00
|
|
|
}
|
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
free(strings->data);
|
|
|
|
free(strings);
|
2012-10-07 23:13:29 +02:00
|
|
|
}
|
2012-10-07 19:11:04 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
return refcount;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT32 WINAPI localizedstrings_GetCount(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2021-03-10 10:30:25 +01:00
|
|
|
return get_localizedstrings_count(iface);
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_FindLocaleName(IDWriteLocalizedStrings *iface,
|
|
|
|
WCHAR const *locale_name, UINT32 *index, BOOL *exists)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
size_t i;
|
2014-11-05 06:49:48 +01:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_w(locale_name), index, exists);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
|
|
|
*exists = FALSE;
|
|
|
|
*index = ~0;
|
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
for (i = 0; i < strings->count; ++i)
|
|
|
|
{
|
2021-03-30 13:06:18 +02:00
|
|
|
if (!wcsicmp(strings->data[i].locale, locale_name))
|
2019-05-14 12:27:27 +02:00
|
|
|
{
|
2014-11-05 06:49:48 +01:00
|
|
|
*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)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, length);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
if (index >= strings->count)
|
|
|
|
{
|
2014-11-05 06:49:48 +01:00
|
|
|
*length = (UINT32)-1;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
*length = wcslen(strings->data[index].locale);
|
2014-11-05 06:49:48 +01:00
|
|
|
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
|
|
|
{
|
2020-12-02 12:44:03 +01:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
TRACE("%p, %u, %p, %u.\n", iface, index, buffer, size);
|
2014-11-05 06:49:48 +01:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
if (index >= strings->count)
|
|
|
|
{
|
2014-11-05 06:49:48 +01:00
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
if (size < wcslen(strings->data[index].locale) + 1)
|
2020-12-02 12:44:03 +01:00
|
|
|
{
|
2014-11-05 06:49:48 +01:00
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
wcscpy(buffer, strings->data[index].locale);
|
2014-11-05 06:49:48 +01:00
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_GetStringLength(IDWriteLocalizedStrings *iface, UINT32 index, UINT32 *length)
|
|
|
|
{
|
2020-12-02 12:44:03 +01:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
2012-10-07 23:25:23 +02:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
TRACE("%p, %u, %p.\n", iface, index, length);
|
2012-10-07 23:25:23 +02:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
if (index >= strings->count)
|
|
|
|
{
|
|
|
|
*length = ~0u;
|
2012-10-07 23:25:23 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
*length = wcslen(strings->data[index].string);
|
2012-10-07 23:25:23 +02:00
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI localizedstrings_GetString(IDWriteLocalizedStrings *iface, UINT32 index, WCHAR *buffer, UINT32 size)
|
|
|
|
{
|
2020-12-02 12:44:03 +01:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
2012-10-08 00:43:15 +02:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
TRACE("%p, %u, %p, %u.\n", iface, index, buffer, size);
|
2012-10-08 00:43:15 +02:00
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
if (index >= strings->count)
|
|
|
|
{
|
2012-10-08 00:43:15 +02:00
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
if (size < wcslen(strings->data[index].string) + 1)
|
2020-12-02 12:44:03 +01:00
|
|
|
{
|
2012-10-08 00:43:15 +02:00
|
|
|
if (buffer) *buffer = 0;
|
|
|
|
return E_NOT_SUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
wcscpy(buffer, strings->data[index].string);
|
2012-10-08 00:43:15 +02:00
|
|
|
return S_OK;
|
2012-10-07 19:11:04 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
static const IDWriteLocalizedStringsVtbl localizedstringsvtbl =
|
|
|
|
{
|
2012-10-07 19:11:04 +02:00
|
|
|
localizedstrings_QueryInterface,
|
|
|
|
localizedstrings_AddRef,
|
|
|
|
localizedstrings_Release,
|
|
|
|
localizedstrings_GetCount,
|
|
|
|
localizedstrings_FindLocaleName,
|
|
|
|
localizedstrings_GetLocaleNameLength,
|
|
|
|
localizedstrings_GetLocaleName,
|
|
|
|
localizedstrings_GetStringLength,
|
|
|
|
localizedstrings_GetString
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_localizedstrings(IDWriteLocalizedStrings **strings)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *object;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
*strings = NULL;
|
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(object = calloc(1, sizeof(*object))))
|
2012-10-07 23:13:29 +02:00
|
|
|
return E_OUTOFMEMORY;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
object->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
|
|
|
|
object->refcount = 1;
|
|
|
|
|
|
|
|
*strings = &object->IDWriteLocalizedStrings_iface;
|
2012-10-07 19:11:04 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-07 23:13:29 +02:00
|
|
|
HRESULT add_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *locale, const WCHAR *string)
|
|
|
|
{
|
2019-05-14 12:27:27 +02:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
size_t i, count = strings->count;
|
2015-01-26 11:39:18 +01:00
|
|
|
|
2020-01-27 06:52:48 +01:00
|
|
|
/* Make sure there's no duplicates, unless it's empty. This is used by dlng/slng entries of 'meta' table. */
|
|
|
|
if (*locale)
|
|
|
|
{
|
|
|
|
for (i = 0; i < count; i++)
|
2021-03-30 13:06:18 +02:00
|
|
|
if (!wcsicmp(strings->data[i].locale, locale))
|
2020-01-27 06:52:48 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2012-10-07 23:13:29 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&strings->data, &strings->size, strings->count + 1, sizeof(*strings->data)))
|
|
|
|
return E_OUTOFMEMORY;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
strings->data[count].locale = wcsdup(locale);
|
|
|
|
strings->data[count].string = wcsdup(string);
|
2019-05-14 12:27:27 +02:00
|
|
|
if (!strings->data[count].locale || !strings->data[count].string)
|
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
free(strings->data[count].locale);
|
|
|
|
free(strings->data[count].string);
|
2015-01-26 11:39:18 +01:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2021-03-30 13:06:18 +02:00
|
|
|
wcslwr(strings->data[count].locale);
|
2015-01-26 11:39:18 +01:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
strings->count++;
|
2012-10-07 23:13:29 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2020-01-24 09:17:34 +01:00
|
|
|
HRESULT clone_localizedstrings(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;
|
2019-05-14 12:27:27 +02:00
|
|
|
size_t i;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
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);
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(strings_clone = calloc(1, sizeof(*strings_clone))))
|
2019-02-13 08:47:10 +01:00
|
|
|
return E_OUTOFMEMORY;
|
2014-09-05 00:45:37 +02:00
|
|
|
|
2019-05-14 12:27:27 +02:00
|
|
|
if (!dwrite_array_reserve((void **)&strings_clone->data, &strings_clone->size, strings->count,
|
|
|
|
sizeof(*strings_clone->data)))
|
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
free(strings_clone);
|
2014-09-05 00:45:37 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
2019-05-14 12:27:27 +02:00
|
|
|
|
|
|
|
strings_clone->IDWriteLocalizedStrings_iface.lpVtbl = &localizedstringsvtbl;
|
|
|
|
strings_clone->refcount = 1;
|
|
|
|
strings_clone->count = strings->count;
|
|
|
|
|
|
|
|
for (i = 0; i < strings_clone->count; ++i)
|
2014-09-05 00:45:37 +02:00
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
strings_clone->data[i].locale = wcsdup(strings->data[i].locale);
|
|
|
|
strings_clone->data[i].string = wcsdup(strings->data[i].string);
|
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)
|
|
|
|
{
|
2020-12-02 12:44:03 +01:00
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
2015-09-01 11:09:24 +02:00
|
|
|
UINT32 i;
|
|
|
|
|
2020-12-02 12:44:03 +01:00
|
|
|
for (i = 0; i < strings->count; i++)
|
|
|
|
{
|
2021-03-31 12:06:29 +02:00
|
|
|
if (!wcsicmp(strings->data[i].locale, L"en-US"))
|
2020-12-02 12:44:03 +01:00
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
free(strings->data[i].string);
|
|
|
|
strings->data[i].string = wcsdup(string);
|
2015-09-01 11:09:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
static int __cdecl localizedstrings_sorting_compare(const void *left, const void *right)
|
2019-09-19 16:41:02 +02:00
|
|
|
{
|
|
|
|
const struct localizedpair *_l = left, *_r = right;
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
return wcscmp(_l->locale, _r->locale);
|
2019-09-19 16:41:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
void sort_localizedstrings(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
|
|
|
|
qsort(strings->data, strings->count, sizeof(*strings->data), localizedstrings_sorting_compare);
|
|
|
|
}
|
|
|
|
|
2021-03-10 10:30:25 +01:00
|
|
|
unsigned int get_localizedstrings_count(IDWriteLocalizedStrings *iface)
|
|
|
|
{
|
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
return strings->count;
|
|
|
|
}
|
|
|
|
|
2021-03-10 10:30:29 +01:00
|
|
|
BOOL localizedstrings_contains(IDWriteLocalizedStrings *iface, const WCHAR *str)
|
|
|
|
{
|
|
|
|
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < strings->count; ++i)
|
|
|
|
{
|
2021-03-30 13:06:18 +02:00
|
|
|
if (!wcsicmp(strings->data[i].string, str)) return TRUE;
|
2021-03-10 10:30:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2014-10-20 10:50:27 +02:00
|
|
|
struct collectionloader
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
IDWriteFontCollectionLoader *loader;
|
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2019-10-09 10:04:55 +02:00
|
|
|
struct dwritefactory
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
IDWriteFactory7 IDWriteFactory7_iface;
|
|
|
|
LONG refcount;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2016-07-07 20:30:08 +02:00
|
|
|
IDWriteFontCollection1 *system_collection;
|
2017-04-27 17:20:03 +02:00
|
|
|
IDWriteFontCollection1 *eudc_collection;
|
2017-04-11 13:21:32 +02:00
|
|
|
IDWriteGdiInterop1 *gdiinterop;
|
2019-10-09 10:04:55 +02:00
|
|
|
IDWriteFontFallback1 *fallback;
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
IDWriteFontFileLoader *localfontfileloader;
|
2014-10-24 09:40:06 +02:00
|
|
|
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;
|
2017-08-15 13:40:24 +02:00
|
|
|
|
|
|
|
CRITICAL_SECTION cs;
|
2014-08-06 23:59:39 +02:00
|
|
|
};
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static inline struct dwritefactory *impl_from_IDWriteFactory7(IDWriteFactory7 *iface)
|
2014-08-06 23:59:39 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct dwritefactory, IDWriteFactory7_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;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(fontface, fontface2, fontfaces, struct fontfacecached, entry) {
|
|
|
|
list_remove(&fontface->entry);
|
2017-07-20 18:47:33 +02:00
|
|
|
fontface_detach_from_cache(fontface->fontface);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(fontface);
|
2014-10-24 09:40:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void release_fileloader(struct fileloader *fileloader)
|
|
|
|
{
|
|
|
|
list_remove(&fileloader->entry);
|
|
|
|
release_fontface_cache(&fileloader->fontfaces);
|
|
|
|
IDWriteFontFileLoader_Release(fileloader->loader);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(fileloader);
|
2014-10-24 09:40:06 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2017-08-15 13:40:24 +02:00
|
|
|
EnterCriticalSection(&factory->cs);
|
2014-10-24 09:40:06 +02:00
|
|
|
release_fontface_cache(&factory->localfontfaces);
|
2017-08-15 13:40:24 +02:00
|
|
|
LeaveCriticalSection(&factory->cs);
|
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);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(loader);
|
2014-10-20 10:50:27 +02:00
|
|
|
}
|
|
|
|
|
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)
|
2016-07-07 20:30:08 +02:00
|
|
|
IDWriteFontCollection1_Release(factory->system_collection);
|
2014-12-17 07:54:13 +01:00
|
|
|
if (factory->eudc_collection)
|
2017-04-27 17:20:03 +02:00
|
|
|
IDWriteFontCollection1_Release(factory->eudc_collection);
|
2016-02-14 17:05:06 +01:00
|
|
|
if (factory->fallback)
|
|
|
|
release_system_fontfallback(factory->fallback);
|
2017-08-15 13:40:24 +02:00
|
|
|
|
|
|
|
factory->cs.DebugInfo->Spare[0] = 0;
|
|
|
|
DeleteCriticalSection(&factory->cs);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(factory);
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static void release_shared_factory(IDWriteFactory7 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
|
|
|
struct dwritefactory *factory;
|
|
|
|
if (!iface) return;
|
2019-12-02 13:53:55 +01:00
|
|
|
factory = impl_from_IDWriteFactory7(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;
|
|
|
|
}
|
|
|
|
|
2017-05-07 21:38:15 +02:00
|
|
|
static struct collectionloader *factory_get_collection_loader(struct dwritefactory *factory,
|
|
|
|
IDWriteFontCollectionLoader *loader)
|
2014-10-24 09:41:46 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-08-22 11:42:12 +02:00
|
|
|
static IDWriteFontCollection1 *factory_get_system_collection(struct dwritefactory *factory)
|
|
|
|
{
|
|
|
|
IDWriteFontCollection1 *collection;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (factory->system_collection) {
|
|
|
|
IDWriteFontCollection1_AddRef(factory->system_collection);
|
|
|
|
return factory->system_collection;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
if (FAILED(hr = get_system_fontcollection(&factory->IDWriteFactory7_iface, &collection)))
|
2019-12-02 13:53:55 +01:00
|
|
|
{
|
2017-08-22 11:42:12 +02:00
|
|
|
WARN("Failed to create system font collection, hr %#x.\n", hr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InterlockedCompareExchangePointer((void **)&factory->system_collection, collection, NULL))
|
|
|
|
IDWriteFontCollection1_Release(collection);
|
|
|
|
|
|
|
|
return factory->system_collection;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_QueryInterface(IDWriteFactory7 *iface, REFIID riid, void **obj)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (IsEqualIID(riid, &IID_IDWriteFactory7) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory6) ||
|
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory5) ||
|
2017-05-07 21:38:15 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory4) ||
|
2016-10-11 14:20:26 +02:00
|
|
|
IsEqualIID(riid, &IID_IDWriteFactory3) ||
|
2016-03-28 12:33:57 +02:00
|
|
|
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;
|
2019-12-02 13:53:55 +01:00
|
|
|
IDWriteFactory7_AddRef(iface);
|
2012-07-31 06:07:49 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static ULONG WINAPI dwritefactory_AddRef(IDWriteFactory7 *iface)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
|
|
|
ULONG refcount = InterlockedIncrement(&factory->refcount);
|
|
|
|
|
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
return refcount;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static ULONG WINAPI dwritefactory_Release(IDWriteFactory7 *iface)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
|
|
|
ULONG refcount = InterlockedDecrement(&factory->refcount);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, refcount %u.\n", iface, refcount);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (!refcount)
|
|
|
|
release_dwritefactory(factory);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
return refcount;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollection **collection, BOOL check_for_updates)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
return IDWriteFactory5_GetSystemFontCollection((IDWriteFactory5 *)iface, FALSE, (IDWriteFontCollection1 **)collection,
|
2017-05-07 21:38:15 +02:00
|
|
|
check_for_updates);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader, void const *key, UINT32 key_size, IDWriteFontCollection **collection)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFileEnumerator *enumerator;
|
|
|
|
struct collectionloader *found;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %p, %u, %p.\n", iface, loader, key, key_size, collection);
|
2014-10-24 09:43:21 +02:00
|
|
|
|
|
|
|
*collection = NULL;
|
|
|
|
|
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
found = factory_get_collection_loader(factory, loader);
|
2014-10-24 09:43:21 +02:00
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFontCollectionLoader_CreateEnumeratorFromKey(found->loader, (IDWriteFactory *)iface,
|
2017-05-07 21:38:15 +02:00
|
|
|
key, key_size, &enumerator);
|
2014-10-24 09:43:21 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
hr = create_font_collection(iface, enumerator, FALSE, (IDWriteFontCollection3 **)collection);
|
2014-10-24 09:43:21 +02:00
|
|
|
IDWriteFontFileEnumerator_Release(enumerator);
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_RegisterFontCollectionLoader(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-20 10:50:27 +02:00
|
|
|
struct collectionloader *entry;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-10-08 12:49:12 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (factory_get_collection_loader(factory, loader))
|
2014-10-24 09:41:46 +02:00
|
|
|
return DWRITE_E_ALREADYREGISTERED;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(entry = malloc(sizeof(*entry))))
|
2014-10-20 10:50:27 +02:00
|
|
|
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);
|
2019-12-02 13:53:55 +01:00
|
|
|
list_add_tail(&factory->collection_loaders, &entry->entry);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_UnregisterFontCollectionLoader(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteFontCollectionLoader *loader)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-24 09:41:46 +02:00
|
|
|
struct collectionloader *found;
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, loader);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
2014-10-08 12:49:12 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
found = factory_get_collection_loader(factory, loader);
|
2014-10-20 10:50:27 +02:00
|
|
|
if (!found)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
IDWriteFontCollectionLoader_Release(found->loader);
|
|
|
|
list_remove(&found->entry);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(found);
|
2014-08-07 00:01:09 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateFontFileReference(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
WCHAR const *path, FILETIME const *writetime, IDWriteFontFile **font_file)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-11-15 17:19:00 +01:00
|
|
|
UINT32 key_size;
|
|
|
|
HRESULT hr;
|
|
|
|
void *key;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s, %p, %p.\n", iface, debugstr_w(path), writetime, font_file);
|
2014-08-26 17:11:59 +02:00
|
|
|
|
2016-04-20 09:50:59 +02:00
|
|
|
*font_file = NULL;
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
/* Get a reference key in local file loader format. */
|
2014-11-15 17:19:00 +01:00
|
|
|
hr = get_local_refkey(path, writetime, &key, &key_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = create_font_file(factory->localfontfileloader, key, key_size, font_file);
|
2021-12-02 13:37:19 +01:00
|
|
|
free(key);
|
2014-11-15 17:19:00 +01:00
|
|
|
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomFontFileReference(IDWriteFactory7 *iface,
|
2012-07-31 06:07:49 +02:00
|
|
|
void const *reference_key, UINT32 key_size, IDWriteFontFileLoader *loader, IDWriteFontFile **font_file)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-08-12 21:11:34 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %u, %p, %p.\n", iface, 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
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (!loader || !(factory_get_file_loader(factory, loader) || factory->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
|
|
|
}
|
|
|
|
|
2019-12-05 09:55:59 +01:00
|
|
|
void factory_lock(IDWriteFactory7 *iface)
|
2017-08-15 13:40:24 +02:00
|
|
|
{
|
2019-12-05 09:55:59 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2017-08-15 13:40:24 +02:00
|
|
|
EnterCriticalSection(&factory->cs);
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:55:59 +01:00
|
|
|
void factory_unlock(IDWriteFactory7 *iface)
|
2017-08-15 13:40:24 +02:00
|
|
|
{
|
2019-12-05 09:55:59 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2017-08-15 13:40:24 +02:00
|
|
|
LeaveCriticalSection(&factory->cs);
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
HRESULT factory_get_cached_fontface(IDWriteFactory7 *iface, IDWriteFontFile * const *font_files, UINT32 index,
|
2017-08-15 13:40:24 +02:00
|
|
|
DWRITE_FONT_SIMULATIONS simulations, struct list **cached_list, REFIID riid, void **obj)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-05 09:56:03 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-24 09:40:06 +02:00
|
|
|
struct fontfacecached *cached;
|
2016-07-05 11:55:53 +02:00
|
|
|
IDWriteFontFileLoader *loader;
|
2014-10-24 09:40:06 +02:00
|
|
|
struct list *fontfaces;
|
2016-07-05 11:55:53 +02:00
|
|
|
UINT32 key_size;
|
2014-10-24 09:40:06 +02:00
|
|
|
const void *key;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-08-15 13:40:24 +02:00
|
|
|
*obj = NULL;
|
2016-07-05 11:55:53 +02:00
|
|
|
*cached_list = NULL;
|
2015-09-04 11:15:41 +02:00
|
|
|
|
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;
|
|
|
|
|
2017-09-24 23:08:40 +02:00
|
|
|
if (loader == factory->localfontfileloader) {
|
2016-07-05 11:55:53 +02:00
|
|
|
fontfaces = &factory->localfontfaces;
|
2014-10-24 09:40:06 +02:00
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
}
|
|
|
|
else {
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fileloader *fileloader = factory_get_file_loader(factory, loader);
|
2014-10-24 09:40:06 +02:00
|
|
|
IDWriteFontFileLoader_Release(loader);
|
|
|
|
if (!fileloader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
fontfaces = &fileloader->fontfaces;
|
|
|
|
}
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
*cached_list = fontfaces;
|
|
|
|
|
2017-08-15 13:40:24 +02:00
|
|
|
EnterCriticalSection(&factory->cs);
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
/* 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;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
cached_face_index = IDWriteFontFace5_GetIndex(cached->fontface);
|
|
|
|
cached_simulations = IDWriteFontFace5_GetSimulations(cached->fontface);
|
2014-10-24 09:40:06 +02:00
|
|
|
|
|
|
|
/* skip earlier */
|
|
|
|
if (cached_face_index != index || cached_simulations != simulations)
|
|
|
|
continue;
|
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
hr = IDWriteFontFace5_GetFiles(cached->fontface, &count, &file);
|
2014-10-24 09:40:06 +02:00
|
|
|
if (FAILED(hr))
|
2017-08-15 13:40:24 +02:00
|
|
|
break;
|
2014-10-24 09:40:06 +02:00
|
|
|
|
|
|
|
hr = IDWriteFontFile_GetReferenceKey(file, &cached_key, &cached_key_size);
|
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
if (FAILED(hr))
|
2017-08-15 13:40:24 +02:00
|
|
|
break;
|
2014-10-24 09:40:06 +02:00
|
|
|
|
2019-12-02 13:53:53 +01:00
|
|
|
if (cached_key_size == key_size && !memcmp(cached_key, key, key_size))
|
|
|
|
{
|
|
|
|
if (FAILED(hr = IDWriteFontFace5_QueryInterface(cached->fontface, riid, obj)))
|
2017-08-15 13:40:24 +02:00
|
|
|
WARN("Failed to get %s from fontface, hr %#x.\n", debugstr_guid(riid), hr);
|
|
|
|
|
2014-10-24 09:40:06 +02:00
|
|
|
TRACE("returning cached fontface %p\n", cached->fontface);
|
2017-08-15 13:40:24 +02:00
|
|
|
break;
|
2014-10-24 09:40:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-15 13:40:24 +02:00
|
|
|
LeaveCriticalSection(&factory->cs);
|
|
|
|
|
|
|
|
return *obj ? S_OK : S_FALSE;
|
2016-07-05 11:55:53 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 09:55:59 +01:00
|
|
|
struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *iface, struct list *fontfaces,
|
2019-12-02 13:53:53 +01:00
|
|
|
IDWriteFontFace5 *fontface)
|
2016-07-05 11:55:53 +02:00
|
|
|
{
|
2019-12-05 09:55:59 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fontfacecached *cached;
|
2014-10-24 09:40:06 +02:00
|
|
|
|
|
|
|
/* new cache entry */
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(cached = malloc(sizeof(*cached))))
|
2017-04-11 13:21:32 +02:00
|
|
|
return NULL;
|
2014-10-24 09:40:06 +02:00
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
cached->fontface = fontface;
|
2017-08-15 13:40:24 +02:00
|
|
|
EnterCriticalSection(&factory->cs);
|
2014-10-24 09:40:06 +02:00
|
|
|
list_add_tail(fontfaces, &cached->entry);
|
2017-08-15 13:40:24 +02:00
|
|
|
LeaveCriticalSection(&factory->cs);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
|
|
|
return cached;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateFontFace(IDWriteFactory7 *iface, DWRITE_FONT_FACE_TYPE req_facetype,
|
2017-04-11 13:21:32 +02:00
|
|
|
UINT32 files_number, IDWriteFontFile* const* font_files, UINT32 index, DWRITE_FONT_SIMULATIONS simulations,
|
|
|
|
IDWriteFontFace **fontface)
|
2016-07-05 11:55:53 +02:00
|
|
|
{
|
|
|
|
DWRITE_FONT_FILE_TYPE file_type;
|
|
|
|
DWRITE_FONT_FACE_TYPE face_type;
|
2017-10-18 13:53:06 +02:00
|
|
|
IDWriteFontFileStream *stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
struct fontface_desc desc;
|
|
|
|
struct list *fontfaces;
|
|
|
|
BOOL is_supported;
|
2017-10-18 13:53:06 +02:00
|
|
|
UINT32 face_count;
|
2016-07-05 11:55:53 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %d, %u, %p, %u, %#x, %p.\n", iface, req_facetype, files_number, font_files, index,
|
2017-04-11 13:21:32 +02:00
|
|
|
simulations, fontface);
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2017-04-11 13:21:32 +02:00
|
|
|
*fontface = NULL;
|
2016-07-05 11:55:53 +02:00
|
|
|
|
|
|
|
if (!is_face_type_supported(req_facetype))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-05 22:12:37 +01:00
|
|
|
if (req_facetype != DWRITE_FONT_FACE_TYPE_OPENTYPE_COLLECTION && index)
|
2016-07-05 11:55:53 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (!is_simulation_valid(simulations))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (FAILED(hr = get_filestream_from_file(*font_files, &stream)))
|
|
|
|
return hr;
|
|
|
|
|
2016-07-05 11:55:53 +02:00
|
|
|
/* check actual file/face type */
|
|
|
|
is_supported = FALSE;
|
|
|
|
face_type = DWRITE_FONT_FACE_TYPE_UNKNOWN;
|
2017-10-18 13:53:06 +02:00
|
|
|
hr = opentype_analyze_font(stream, &is_supported, &file_type, &face_type, &face_count);
|
2016-07-05 11:55:53 +02:00
|
|
|
if (FAILED(hr))
|
2017-10-18 13:53:06 +02:00
|
|
|
goto failed;
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (!is_supported) {
|
|
|
|
hr = E_FAIL;
|
|
|
|
goto failed;
|
|
|
|
}
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2017-10-18 13:53:06 +02:00
|
|
|
if (face_type != req_facetype) {
|
|
|
|
hr = DWRITE_E_FILEFORMAT;
|
|
|
|
goto failed;
|
|
|
|
}
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
hr = factory_get_cached_fontface(iface, font_files, index, simulations, &fontfaces,
|
2017-08-15 13:40:24 +02:00
|
|
|
&IID_IDWriteFontFace, (void **)fontface);
|
2016-07-05 11:55:53 +02:00
|
|
|
if (hr != S_FALSE)
|
2017-10-18 13:53:06 +02:00
|
|
|
goto failed;
|
2016-07-05 11:55:53 +02:00
|
|
|
|
2019-12-05 09:55:59 +01:00
|
|
|
desc.factory = iface;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.face_type = req_facetype;
|
2021-03-08 09:30:47 +01:00
|
|
|
desc.file = *font_files;
|
2017-10-18 13:53:06 +02:00
|
|
|
desc.stream = stream;
|
2016-07-05 11:55:53 +02:00
|
|
|
desc.index = index;
|
|
|
|
desc.simulations = simulations;
|
|
|
|
desc.font_data = NULL;
|
2019-12-02 13:53:53 +01:00
|
|
|
hr = create_fontface(&desc, fontfaces, (IDWriteFontFace5 **)fontface);
|
2017-10-18 13:53:06 +02:00
|
|
|
|
|
|
|
failed:
|
|
|
|
IDWriteFontFileStream_Release(stream);
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateRenderingParams(IDWriteFactory7 *iface, IDWriteRenderingParams **params)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2012-10-01 07:35:00 +02:00
|
|
|
HMONITOR monitor;
|
|
|
|
POINT pt;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, params);
|
2012-10-01 07:35:00 +02:00
|
|
|
|
|
|
|
pt.x = pt.y = 0;
|
|
|
|
monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
2019-12-02 13:53:55 +01:00
|
|
|
return IDWriteFactory7_CreateMonitorRenderingParams(iface, monitor, params);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateMonitorRenderingParams(IDWriteFactory7 *iface, HMONITOR monitor,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteRenderingParams **params)
|
|
|
|
{
|
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
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, 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
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
/* FIXME: use actual per-monitor gamma factor */
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFactory7_CreateCustomRenderingParams(iface, 2.0f, 0.0f, 1.0f, 0.0f, DWRITE_PIXEL_GEOMETRY_FLAT,
|
2017-02-03 13:20:28 +01:00
|
|
|
DWRITE_RENDERING_MODE1_DEFAULT, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
2016-04-19 08:39:25 +02:00
|
|
|
*params = (IDWriteRenderingParams*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateCustomRenderingParams(IDWriteFactory7 *iface, FLOAT gamma,
|
2017-05-07 21:38:15 +02:00
|
|
|
FLOAT enhancedContrast, FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY geometry, DWRITE_RENDERING_MODE mode,
|
|
|
|
IDWriteRenderingParams **params)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2016-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %d, %d, %p.\n", iface, gamma, enhancedContrast, cleartype_level, geometry, mode, params);
|
2015-03-31 10:39:59 +02:00
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
if ((UINT32)mode > DWRITE_RENDERING_MODE_OUTLINE) {
|
|
|
|
*params = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFactory7_CreateCustomRenderingParams(iface, gamma, enhancedContrast, 1.0f, cleartype_level, geometry,
|
2017-07-17 22:18:43 +02:00
|
|
|
(DWRITE_RENDERING_MODE1)mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
2016-04-19 08:39:25 +02:00
|
|
|
*params = (IDWriteRenderingParams*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_RegisterFontFileLoader(IDWriteFactory7 *iface, IDWriteFontFileLoader *loader)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader *entry;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, loader);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (factory_get_file_loader(factory, loader))
|
2014-10-24 09:41:46 +02:00
|
|
|
return DWRITE_E_ALREADYREGISTERED;
|
2014-10-20 10:53:21 +02:00
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(entry = malloc(sizeof(*entry))))
|
2014-10-20 10:53:21 +02:00
|
|
|
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);
|
2019-12-02 13:53:55 +01:00
|
|
|
list_add_tail(&factory->file_loaders, &entry->entry);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_UnregisterFontFileLoader(IDWriteFactory7 *iface, IDWriteFontFileLoader *loader)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-10-20 10:53:21 +02:00
|
|
|
struct fileloader *found;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, loader);
|
2014-08-12 21:11:30 +02:00
|
|
|
|
2014-10-20 10:53:21 +02:00
|
|
|
if (!loader)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
found = factory_get_file_loader(factory, loader);
|
2014-10-20 10:53:21 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory7 *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)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-12-16 15:59:44 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s, %p, %d, %d, %d, %.8e, %s, %p.\n", iface, 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
|
|
|
|
2017-08-22 11:42:12 +02:00
|
|
|
if (collection)
|
|
|
|
IDWriteFontCollection_AddRef(collection);
|
|
|
|
else {
|
2019-12-02 13:53:55 +01:00
|
|
|
collection = (IDWriteFontCollection *)factory_get_system_collection(factory);
|
2017-08-22 11:42:12 +02:00
|
|
|
if (!collection) {
|
|
|
|
*format = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2014-09-02 14:17:57 +02:00
|
|
|
}
|
2014-12-16 15:59:44 +01:00
|
|
|
|
2017-08-22 11:42:12 +02:00
|
|
|
hr = create_textformat(family_name, collection, weight, style, stretch, size, locale, format);
|
|
|
|
IDWriteFontCollection_Release(collection);
|
2014-12-16 15:59:44 +01:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTypography(IDWriteFactory7 *iface, IDWriteTypography **typography)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, typography);
|
|
|
|
|
2014-09-19 05:54:00 +02:00
|
|
|
return create_typography(typography);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory7 *iface, IDWriteGdiInterop **gdi_interop)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2017-04-11 13:21:32 +02:00
|
|
|
HRESULT hr = S_OK;
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, gdi_interop);
|
2014-10-19 21:57:53 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (factory->gdiinterop)
|
|
|
|
IDWriteGdiInterop1_AddRef(factory->gdiinterop);
|
2017-04-11 13:21:32 +02:00
|
|
|
else
|
2019-12-05 09:56:05 +01:00
|
|
|
hr = create_gdiinterop(iface, &factory->gdiinterop);
|
2017-04-11 13:21:32 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
*gdi_interop = (IDWriteGdiInterop *)factory->gdiinterop;
|
2017-04-11 13:21:32 +02:00
|
|
|
|
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory7 *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-04-27 10:19:41 +02:00
|
|
|
struct textlayout_desc desc;
|
2016-01-28 02:17:15 +01:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s:%u, %p, %.8e, %.8e, %p.\n", iface, debugstr_wn(string, length), length, format, max_width, max_height, layout);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-12-05 09:56:04 +01:00
|
|
|
desc.factory = iface;
|
2016-04-27 10:19:41 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory7 *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-04-27 10:19:41 +02:00
|
|
|
struct textlayout_desc desc;
|
2015-01-08 22:35:14 +01:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s:%u, %p, %.8e, %.8e, %.8e, %p, %d, %p.\n", iface, debugstr_wn(string, length), length, format,
|
|
|
|
max_width, max_height, pixels_per_dip, transform, use_gdi_natural, layout);
|
2012-09-28 10:13:17 +02:00
|
|
|
|
2019-12-05 09:56:04 +01:00
|
|
|
desc.factory = iface;
|
2016-04-27 10:19:41 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory7 *iface, IDWriteTextFormat *format,
|
2012-07-31 06:07:49 +02:00
|
|
|
IDWriteInlineObject **trimming_sign)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %p.\n", iface, format, trimming_sign);
|
|
|
|
|
2019-12-05 09:56:04 +01:00
|
|
|
return create_trimmingsign(iface, format, trimming_sign);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateTextAnalyzer(IDWriteFactory7 *iface, IDWriteTextAnalyzer **analyzer)
|
2012-07-31 06:07:49 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, analyzer);
|
2017-08-22 11:42:11 +02:00
|
|
|
|
2021-02-22 19:29:37 +01:00
|
|
|
*analyzer = (IDWriteTextAnalyzer *)get_text_analyzer();
|
2017-08-22 11:42:11 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateNumberSubstitution(IDWriteFactory7 *iface,
|
2017-05-07 21:38:15 +02:00
|
|
|
DWRITE_NUMBER_SUBSTITUTION_METHOD method, WCHAR const* locale, BOOL ignore_user_override,
|
|
|
|
IDWriteNumberSubstitution **substitution)
|
2012-07-29 10:50:34 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %d, %s, %d, %p.\n", iface, method, debugstr_w(locale), ignore_user_override, substitution);
|
|
|
|
|
2014-10-01 14:14:41 +02:00
|
|
|
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
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
static inline void dwrite_matrix_multiply(DWRITE_MATRIX *a, const DWRITE_MATRIX *b)
|
|
|
|
{
|
|
|
|
DWRITE_MATRIX tmp = *a;
|
|
|
|
|
|
|
|
a->m11 = tmp.m11 * b->m11 + tmp.m12 * b->m21;
|
|
|
|
a->m12 = tmp.m11 * b->m12 + tmp.m12 * b->m22;
|
|
|
|
a->m21 = tmp.m21 * b->m11 + tmp.m22 * b->m21;
|
|
|
|
a->m22 = tmp.m21 * b->m12 + tmp.m22 * b->m22;
|
|
|
|
a->dx = tmp.dx * b->m11 + tmp.dy * b->m21 + b->dx;
|
|
|
|
a->dy = tmp.dy * b->m12 + tmp.dy * b->m22 + b->dx;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory_CreateGlyphRunAnalysis(IDWriteFactory7 *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-04-27 10:19:41 +02:00
|
|
|
struct glyphrunanalysis_desc desc;
|
2018-08-16 12:34:44 +02:00
|
|
|
DWRITE_MATRIX m, scale = { 0 };
|
2015-05-19 14:23:57 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %.8e, %p, %d, %d, %.8e, %.8e, %p.\n", iface, run, ppdip, transform, rendering_mode,
|
2015-07-31 00:29:39 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
m = transform ? *transform : identity;
|
|
|
|
scale.m11 = ppdip;
|
|
|
|
scale.m22 = ppdip;
|
|
|
|
dwrite_matrix_multiply(&m, &scale);
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.run = run;
|
2018-08-16 12:34:44 +02:00
|
|
|
desc.transform = &m;
|
2017-02-03 13:20:28 +01:00
|
|
|
desc.rendering_mode = (DWRITE_RENDERING_MODE1)rendering_mode;
|
2016-04-27 10:19:41 +02:00
|
|
|
desc.measuring_mode = measuring_mode;
|
|
|
|
desc.gridfit_mode = DWRITE_GRID_FIT_MODE_DEFAULT;
|
|
|
|
desc.aa_mode = DWRITE_TEXT_ANTIALIAS_MODE_CLEARTYPE;
|
2018-08-16 12:34:44 +02:00
|
|
|
desc.origin.x = originX;
|
|
|
|
desc.origin.y = originY;
|
2016-04-27 10:19:41 +02:00
|
|
|
return create_glyphrunanalysis(&desc, analysis);
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory7 *iface, IDWriteFontCollection **collection,
|
2014-12-09 14:31:00 +01:00
|
|
|
BOOL check_for_updates)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2014-12-17 07:54:13 +01:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %d.\n", iface, collection, check_for_updates);
|
2014-12-17 07:54:13 +01:00
|
|
|
|
|
|
|
if (check_for_updates)
|
|
|
|
FIXME("checking for eudc updates not implemented\n");
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (factory->eudc_collection)
|
|
|
|
IDWriteFontCollection1_AddRef(factory->eudc_collection);
|
2017-08-22 11:42:13 +02:00
|
|
|
else {
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3 *eudc_collection;
|
2017-08-22 11:42:13 +02:00
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
if (FAILED(hr = get_eudc_fontcollection(iface, &eudc_collection)))
|
2019-12-02 13:53:55 +01:00
|
|
|
{
|
2017-08-22 11:42:13 +02:00
|
|
|
*collection = NULL;
|
|
|
|
WARN("Failed to get EUDC collection, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
if (InterlockedCompareExchangePointer((void **)&factory->eudc_collection, eudc_collection, NULL))
|
2019-10-08 12:04:34 +02:00
|
|
|
IDWriteFontCollection3_Release(eudc_collection);
|
2017-08-22 11:42:13 +02:00
|
|
|
}
|
2014-12-17 07:54:13 +01:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
*collection = (IDWriteFontCollection *)factory->eudc_collection;
|
2014-12-17 07:54:13 +01:00
|
|
|
|
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory1_CreateCustomRenderingParams(IDWriteFactory7 *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-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %p.\n", iface, gamma, enhcontrast, enhcontrast_grayscale,
|
2014-12-09 14:31:00 +01:00
|
|
|
cleartype_level, geometry, mode, params);
|
2017-07-17 22:18:43 +02:00
|
|
|
|
|
|
|
if ((UINT32)mode > DWRITE_RENDERING_MODE_OUTLINE) {
|
|
|
|
*params = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFactory7_CreateCustomRenderingParams(iface, gamma, enhcontrast, enhcontrast_grayscale,
|
2017-02-03 13:20:28 +01:00
|
|
|
cleartype_level, geometry, (DWRITE_RENDERING_MODE1)mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
2016-04-19 08:39:25 +02:00
|
|
|
*params = (IDWriteRenderingParams1*)params3;
|
2015-03-31 10:39:59 +02:00
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory2_GetSystemFontFallback(IDWriteFactory7 *iface, IDWriteFontFallback **fallback)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2016-02-14 17:05:06 +01:00
|
|
|
|
2019-10-09 10:04:55 +02:00
|
|
|
TRACE("%p, %p.\n", iface, fallback);
|
2016-02-14 17:05:06 +01:00
|
|
|
|
|
|
|
*fallback = NULL;
|
|
|
|
|
2019-10-09 10:04:55 +02:00
|
|
|
if (!factory->fallback)
|
|
|
|
{
|
2019-12-06 11:57:47 +01:00
|
|
|
HRESULT hr = create_system_fontfallback(iface, &factory->fallback);
|
2016-02-14 17:05:06 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-10-09 10:04:55 +02:00
|
|
|
*fallback = (IDWriteFontFallback *)factory->fallback;
|
2016-02-14 17:05:06 +01:00
|
|
|
IDWriteFontFallback_AddRef(*fallback);
|
|
|
|
return S_OK;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateFontFallbackBuilder(IDWriteFactory7 *iface,
|
2017-05-07 21:38:15 +02:00
|
|
|
IDWriteFontFallbackBuilder **fallbackbuilder)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p.\n", iface, fallbackbuilder);
|
2017-09-20 19:24:46 +02:00
|
|
|
|
2019-12-06 11:57:47 +01:00
|
|
|
return create_fontfallback_builder(iface, fallbackbuilder);
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory2_TranslateColorGlyphRun(IDWriteFactory7 *iface, FLOAT originX, FLOAT originY,
|
2022-01-21 13:57:16 +01:00
|
|
|
const DWRITE_GLYPH_RUN *run, const DWRITE_GLYPH_RUN_DESCRIPTION *run_desc, DWRITE_MEASURING_MODE measuring_mode,
|
|
|
|
const DWRITE_MATRIX *transform, UINT32 palette, IDWriteColorGlyphRunEnumerator **layers)
|
2014-12-09 14:31:00 +01:00
|
|
|
{
|
2022-01-21 13:57:16 +01:00
|
|
|
D2D1_POINT_2F origin = { originX, originY };
|
2019-12-02 13:53:55 +01:00
|
|
|
|
2022-01-21 13:57:16 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %p, %p, %d, %p, %u, %p.\n", iface, originX, originY, run, run_desc, measuring_mode,
|
|
|
|
transform, palette, layers);
|
|
|
|
|
|
|
|
return create_colorglyphenum(origin, run, run_desc, DWRITE_GLYPH_IMAGE_FORMATS_TRUETYPE
|
|
|
|
| DWRITE_GLYPH_IMAGE_FORMATS_CFF | DWRITE_GLYPH_IMAGE_FORMATS_COLR,
|
|
|
|
measuring_mode, transform, palette, (IDWriteColorGlyphRunEnumerator1 **)layers);
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateCustomRenderingParams(IDWriteFactory7 *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-04-19 08:39:25 +02:00
|
|
|
IDWriteRenderingParams3 *params3;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %d, %p.\n", iface, gamma, contrast, grayscalecontrast, cleartype_level,
|
2015-03-31 10:39:59 +02:00
|
|
|
geometry, mode, gridfit, params);
|
2016-04-19 08:39:25 +02:00
|
|
|
|
2017-07-17 22:18:43 +02:00
|
|
|
if ((UINT32)mode > DWRITE_RENDERING_MODE_OUTLINE) {
|
|
|
|
*params = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFactory7_CreateCustomRenderingParams(iface, gamma, contrast, grayscalecontrast,
|
2017-02-03 13:20:28 +01:00
|
|
|
cleartype_level, geometry, (DWRITE_RENDERING_MODE1)mode, DWRITE_GRID_FIT_MODE_DEFAULT, ¶ms3);
|
2016-04-19 08:39:25 +02:00
|
|
|
*params = (IDWriteRenderingParams2*)params3;
|
|
|
|
return hr;
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
static HRESULT factory_create_glyphrun_analysis(const DWRITE_GLYPH_RUN *run, const DWRITE_MATRIX *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 glyphrunanalysis_desc desc;
|
|
|
|
|
|
|
|
desc.run = run;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory2_CreateGlyphRunAnalysis(IDWriteFactory7 *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)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %p, %d, %d, %d, %d, %.8e, %.8e, %p.\n", iface, run, transform, rendering_mode, measuring_mode,
|
2015-08-06 18:42:48 +02:00
|
|
|
gridfit_mode, aa_mode, originX, originY, analysis);
|
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
return factory_create_glyphrun_analysis(run, transform, (DWRITE_RENDERING_MODE1)rendering_mode, measuring_mode,
|
|
|
|
gridfit_mode, aa_mode, originX, originY, analysis);
|
2014-12-09 14:31:00 +01:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateGlyphRunAnalysis(IDWriteFactory7 *iface, DWRITE_GLYPH_RUN const *run,
|
2016-03-28 12:33:57 +02:00
|
|
|
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)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %p, %d, %d, %d, %d, %.8e, %.8e, %p.\n", iface, run, transform, rendering_mode, measuring_mode,
|
2016-03-28 12:33:57 +02:00
|
|
|
gridfit_mode, aa_mode, originX, originY, analysis);
|
|
|
|
|
2018-08-16 12:34:44 +02:00
|
|
|
return factory_create_glyphrun_analysis(run, transform, rendering_mode, measuring_mode, gridfit_mode,
|
|
|
|
aa_mode, originX, originY, analysis);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateCustomRenderingParams(IDWriteFactory7 *iface, FLOAT gamma, FLOAT contrast,
|
2017-05-07 21:38:15 +02:00
|
|
|
FLOAT grayscale_contrast, FLOAT cleartype_level, DWRITE_PIXEL_GEOMETRY pixel_geometry,
|
|
|
|
DWRITE_RENDERING_MODE1 rendering_mode, DWRITE_GRID_FIT_MODE gridfit_mode, IDWriteRenderingParams3 **params)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %.8e, %.8e, %d, %d, %d, %p.\n", iface, 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
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory7 *iface, IDWriteFontFile *file,
|
2017-05-07 21:38:15 +02:00
|
|
|
UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %u, %x, %p.\n", iface, file, index, simulations, reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
return create_fontfacereference(iface, file, index, simulations, NULL, 0, (IDWriteFontFaceReference1 **)reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory7 *iface, WCHAR const *path,
|
2017-05-07 21:38:15 +02:00
|
|
|
FILETIME const *writetime, UINT32 index, DWRITE_FONT_SIMULATIONS simulations,
|
|
|
|
IDWriteFontFaceReference **reference)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFile *file;
|
|
|
|
HRESULT hr;
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %s, %p, %u, %#x, %p.\n", iface, debugstr_w(path), writetime, index, simulations, reference);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2019-12-05 09:56:01 +01:00
|
|
|
hr = IDWriteFactory7_CreateFontFileReference(iface, path, writetime, &file);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2016-04-20 09:51:01 +02:00
|
|
|
*reference = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
hr = create_fontfacereference(iface, file, index, simulations, NULL, 0, (IDWriteFontFaceReference1 **)reference);
|
2016-04-20 09:51:01 +02:00
|
|
|
IDWriteFontFile_Release(file);
|
|
|
|
return hr;
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2021-03-11 10:41:23 +01:00
|
|
|
static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
|
|
|
|
{
|
2022-02-01 08:39:38 +01:00
|
|
|
unsigned int index = 0, value_size, max_name_count;
|
2021-03-11 10:41:23 +01:00
|
|
|
WCHAR **paths = NULL, *name, *value = NULL;
|
2022-02-01 08:39:38 +01:00
|
|
|
DWORD name_count, type, data_size;
|
2021-03-11 10:41:23 +01:00
|
|
|
size_t capacity = 0, count = 0;
|
|
|
|
HKEY hkey;
|
|
|
|
LONG r;
|
|
|
|
|
|
|
|
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts",
|
|
|
|
0, GENERIC_READ, &hkey))
|
|
|
|
{
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
value_size = MAX_PATH * sizeof(*value);
|
2021-12-02 13:37:19 +01:00
|
|
|
value = malloc(value_size);
|
2021-03-11 10:41:23 +01:00
|
|
|
|
|
|
|
max_name_count = MAX_PATH;
|
2021-12-02 13:37:19 +01:00
|
|
|
name = malloc(max_name_count * sizeof(*name));
|
2021-03-11 10:41:23 +01:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!value)
|
|
|
|
{
|
|
|
|
value_size = MAX_PATH * sizeof(*value);
|
2021-12-02 13:37:19 +01:00
|
|
|
value = malloc(value_size);
|
2021-03-11 10:41:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
name_count = max_name_count;
|
|
|
|
data_size = value_size - sizeof(*value);
|
|
|
|
|
|
|
|
r = RegEnumValueW(hkey, index, name, &name_count, NULL, &type, (BYTE *)value, &data_size);
|
|
|
|
if (r == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
if (name_count >= max_name_count)
|
|
|
|
{
|
|
|
|
max_name_count *= 2;
|
2021-12-02 13:37:19 +01:00
|
|
|
free(name);
|
|
|
|
name = malloc(max_name_count * sizeof(*name));
|
2021-03-11 10:41:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data_size > value_size - sizeof(*value))
|
|
|
|
{
|
2021-12-02 13:37:19 +01:00
|
|
|
free(value);
|
2021-03-11 10:41:23 +01:00
|
|
|
value_size = max(data_size + sizeof(*value), value_size * 2);
|
2021-12-02 13:37:19 +01:00
|
|
|
value = malloc(value_size);
|
2021-03-11 10:41:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (r == ERROR_MORE_DATA);
|
|
|
|
|
|
|
|
if (r != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
value[data_size / sizeof(*value)] = 0;
|
|
|
|
if (type == REG_SZ && *name != '@')
|
|
|
|
{
|
|
|
|
if (dwrite_array_reserve((void **)&paths, &capacity, count + 1, sizeof(*paths)))
|
|
|
|
{
|
2021-03-30 13:06:18 +02:00
|
|
|
if (!wcschr(value, '\\'))
|
2021-03-11 10:41:23 +01:00
|
|
|
{
|
|
|
|
WCHAR *ptrW;
|
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
ptrW = malloc((MAX_PATH + wcslen(value)) * sizeof(WCHAR));
|
2021-03-11 10:41:23 +01:00
|
|
|
GetWindowsDirectoryW(ptrW, MAX_PATH);
|
2021-03-31 12:06:29 +02:00
|
|
|
wcscat(ptrW, L"\\fonts\\");
|
2021-03-30 13:06:18 +02:00
|
|
|
wcscat(ptrW, value);
|
2021-03-11 10:41:23 +01:00
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
free(value);
|
2021-03-11 10:41:23 +01:00
|
|
|
value = ptrW;
|
|
|
|
}
|
|
|
|
|
|
|
|
paths[count++] = value;
|
|
|
|
value = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
free(value);
|
|
|
|
free(name);
|
2021-03-11 10:41:23 +01:00
|
|
|
|
|
|
|
*ret = paths;
|
|
|
|
*ret_count = count;
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2021-03-30 13:06:18 +02:00
|
|
|
static int __cdecl create_system_fontset_compare(const void *left, const void *right)
|
2021-03-11 10:41:23 +01:00
|
|
|
{
|
|
|
|
const WCHAR *_l = *(WCHAR **)left, *_r = *(WCHAR **)right;
|
2021-03-30 13:06:18 +02:00
|
|
|
return wcsicmp(_l, _r);
|
2021-03-11 10:41:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT create_system_fontset(IDWriteFactory7 *factory, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
IDWriteFontSetBuilder2 *builder;
|
|
|
|
IDWriteFontSet *fontset;
|
|
|
|
unsigned int i, j, count;
|
|
|
|
WCHAR **paths;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (FAILED(hr = create_fontset_builder(factory, &builder))) return hr;
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = create_system_path_list(&paths, &count)))
|
|
|
|
{
|
|
|
|
/* Sort, skip duplicates. */
|
|
|
|
|
|
|
|
qsort(paths, count, sizeof(*paths), create_system_fontset_compare);
|
|
|
|
|
|
|
|
for (i = 0, j = 0; i < count; ++i)
|
|
|
|
{
|
2021-03-30 13:06:18 +02:00
|
|
|
if (i != j && !wcsicmp(paths[i], paths[j])) continue;
|
2021-03-11 10:41:23 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = IDWriteFontSetBuilder2_AddFontFile(builder, paths[i])) && hr != DWRITE_E_FILEFORMAT)
|
|
|
|
WARN("Failed to add font file, hr %#x, path %s.\n", hr, debugstr_w(paths[i]));
|
|
|
|
|
|
|
|
j = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
2021-12-02 13:37:19 +01:00
|
|
|
free(paths[i]);
|
|
|
|
free(paths);
|
2021-03-11 10:41:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SUCCEEDED(hr = IDWriteFontSetBuilder2_CreateFontSet(builder, &fontset)))
|
|
|
|
{
|
|
|
|
hr = IDWriteFontSet_QueryInterface(fontset, riid, obj);
|
|
|
|
IDWriteFontSet_Release(fontset);
|
|
|
|
}
|
|
|
|
|
|
|
|
IDWriteFontSetBuilder2_Release(builder);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_GetSystemFontSet(IDWriteFactory7 *iface, IDWriteFontSet **fontset)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2021-03-11 10:41:23 +01:00
|
|
|
TRACE("%p, %p.\n", iface, fontset);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2021-03-11 10:41:23 +01:00
|
|
|
return create_system_fontset(iface, &IID_IDWriteFontSet, (void **)fontset);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder **builder)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2021-01-21 14:36:52 +01:00
|
|
|
TRACE("%p, %p.\n", iface, builder);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2021-01-21 14:36:52 +01:00
|
|
|
return create_fontset_builder(iface, (IDWriteFontSetBuilder2 **)builder);
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_CreateFontCollectionFromFontSet(IDWriteFactory7 *iface, IDWriteFontSet *fontset,
|
2016-03-28 12:33:57 +02:00
|
|
|
IDWriteFontCollection1 **collection)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
FIXME("%p, %p, %p: stub\n", iface, fontset, collection);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_GetSystemFontCollection(IDWriteFactory7 *iface, BOOL include_downloadable,
|
2016-03-28 12:33:57 +02:00
|
|
|
IDWriteFontCollection1 **collection, BOOL check_for_updates)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %d, %p, %d.\n", iface, include_downloadable, collection, check_for_updates);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
2016-07-07 20:30:08 +02:00
|
|
|
if (include_downloadable)
|
|
|
|
FIXME("remote fonts are not supported\n");
|
|
|
|
|
|
|
|
if (check_for_updates)
|
|
|
|
FIXME("checking for system font updates not implemented\n");
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
*collection = factory_get_system_collection(factory);
|
2016-07-07 20:30:08 +02:00
|
|
|
|
2017-08-22 11:42:12 +02:00
|
|
|
return *collection ? S_OK : E_FAIL;
|
2016-03-28 12:33:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory3_GetFontDownloadQueue(IDWriteFactory7 *iface, IDWriteFontDownloadQueue **queue)
|
2016-03-28 12:33:57 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
FIXME("%p, %p: stub\n", iface, queue);
|
2016-03-28 12:33:57 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2022-01-21 13:57:16 +01:00
|
|
|
static HRESULT WINAPI dwritefactory4_TranslateColorGlyphRun(IDWriteFactory7 *iface, D2D1_POINT_2F origin,
|
2017-05-07 21:38:15 +02:00
|
|
|
DWRITE_GLYPH_RUN const *run, DWRITE_GLYPH_RUN_DESCRIPTION const *run_desc,
|
|
|
|
DWRITE_GLYPH_IMAGE_FORMATS desired_formats, DWRITE_MEASURING_MODE measuring_mode, DWRITE_MATRIX const *transform,
|
|
|
|
UINT32 palette, IDWriteColorGlyphRunEnumerator1 **layers)
|
2016-10-11 14:20:26 +02:00
|
|
|
{
|
2022-01-21 13:57:16 +01:00
|
|
|
TRACE("%p, %.8e, %.8e, %p, %p, %u, %d, %p, %u, %p.\n", iface, origin.x, origin.y, run, run_desc, desired_formats,
|
|
|
|
measuring_mode, transform, palette, layers);
|
2016-10-11 14:20:26 +02:00
|
|
|
|
2022-01-21 13:57:16 +01:00
|
|
|
return create_colorglyphenum(origin, run, run_desc, desired_formats, measuring_mode, transform, palette, layers);
|
2016-10-11 14:20:26 +02:00
|
|
|
}
|
|
|
|
|
2021-02-22 19:29:36 +01:00
|
|
|
HRESULT compute_glyph_origins(DWRITE_GLYPH_RUN const *run, DWRITE_MEASURING_MODE measuring_mode,
|
2021-02-22 19:29:35 +01:00
|
|
|
D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform, D2D1_POINT_2F *origins)
|
2017-04-07 13:06:12 +02:00
|
|
|
{
|
2021-02-22 19:29:35 +01:00
|
|
|
struct dwrite_fontface *font_obj;
|
|
|
|
unsigned int i;
|
|
|
|
float advance;
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
font_obj = unsafe_impl_from_IDWriteFontFace(run->fontFace);
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
for (i = 0; i < run->glyphCount; ++i)
|
|
|
|
{
|
|
|
|
origins[i] = baseline_origin;
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
if (run->bidiLevel & 1)
|
|
|
|
{
|
|
|
|
advance = fontface_get_scaled_design_advance(font_obj, measuring_mode, run->fontEmSize,
|
|
|
|
1.0f, transform, run->glyphIndices[i], run->isSideways);
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
origins[i].x -= advance;
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
if (run->glyphOffsets)
|
2017-04-07 13:06:12 +02:00
|
|
|
{
|
2021-02-22 19:29:35 +01:00
|
|
|
origins[i].x -= run->glyphOffsets[i].advanceOffset;
|
|
|
|
origins[i].y -= run->glyphOffsets[i].ascenderOffset;
|
2017-04-07 13:06:12 +02:00
|
|
|
}
|
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
baseline_origin.x -= run->glyphAdvances ? run->glyphAdvances[i] : advance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (run->glyphOffsets)
|
|
|
|
{
|
|
|
|
origins[i].x += run->glyphOffsets[i].advanceOffset;
|
|
|
|
origins[i].y -= run->glyphOffsets[i].ascenderOffset;
|
|
|
|
}
|
2017-04-07 13:06:12 +02:00
|
|
|
|
2021-02-22 19:29:35 +01:00
|
|
|
baseline_origin.x += run->glyphAdvances ? run->glyphAdvances[i] :
|
|
|
|
fontface_get_scaled_design_advance(font_obj, measuring_mode, run->fontEmSize, 1.0f, transform,
|
|
|
|
run->glyphIndices[i], run->isSideways);
|
2017-04-07 13:06:12 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory4_ComputeGlyphOrigins_(IDWriteFactory7 *iface, DWRITE_GLYPH_RUN const *run,
|
2016-10-11 14:20:26 +02:00
|
|
|
D2D1_POINT_2F baseline_origin, D2D1_POINT_2F *origins)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, {%.8e,%.8e}, %p.\n", iface, run, baseline_origin.x, baseline_origin.y, origins);
|
2016-10-11 14:20:26 +02:00
|
|
|
|
2017-04-07 13:06:12 +02:00
|
|
|
return compute_glyph_origins(run, DWRITE_MEASURING_MODE_NATURAL, baseline_origin, NULL, origins);
|
2016-10-11 14:20:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory4_ComputeGlyphOrigins(IDWriteFactory7 *iface, DWRITE_GLYPH_RUN const *run,
|
2016-10-11 14:20:26 +02:00
|
|
|
DWRITE_MEASURING_MODE measuring_mode, D2D1_POINT_2F baseline_origin, DWRITE_MATRIX const *transform,
|
|
|
|
D2D1_POINT_2F *origins)
|
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %d, {%.8e,%.8e}, %p, %p.\n", iface, run, measuring_mode, baseline_origin.x, baseline_origin.y,
|
2017-04-07 13:06:12 +02:00
|
|
|
transform, origins);
|
2016-10-11 14:20:26 +02:00
|
|
|
|
2017-04-07 13:06:12 +02:00
|
|
|
return compute_glyph_origins(run, measuring_mode, baseline_origin, transform, origins);
|
2016-10-11 14:20:26 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory5_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder1 **builder)
|
2017-05-07 21:38:15 +02:00
|
|
|
{
|
2021-01-21 14:36:52 +01:00
|
|
|
TRACE("%p, %p.\n", iface, builder);
|
2019-12-02 13:53:55 +01:00
|
|
|
|
2021-01-21 14:36:52 +01:00
|
|
|
return create_fontset_builder(iface, (IDWriteFontSetBuilder2 **)builder);
|
2019-12-02 13:53:55 +01:00
|
|
|
}
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2020-06-10 16:21:32 +02:00
|
|
|
static HRESULT WINAPI dwritefactory5_CreateInMemoryFontFileLoader(IDWriteFactory7 *iface,
|
|
|
|
IDWriteInMemoryFontFileLoader **loader)
|
2019-12-02 13:53:55 +01:00
|
|
|
{
|
|
|
|
TRACE("%p, %p.\n", iface, loader);
|
|
|
|
|
|
|
|
return create_inmemory_fileloader(loader);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory5_CreateHttpFontFileLoader(IDWriteFactory7 *iface, WCHAR const *referrer_url,
|
|
|
|
WCHAR const *extra_headers, IDWriteRemoteFontFileLoader **loader)
|
|
|
|
{
|
|
|
|
FIXME("%p, %s, %s, %p: stub\n", iface, debugstr_w(referrer_url), wine_dbgstr_w(extra_headers), loader);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static DWRITE_CONTAINER_TYPE WINAPI dwritefactory5_AnalyzeContainerType(IDWriteFactory7 *iface, void const *data,
|
|
|
|
UINT32 data_size)
|
2017-05-07 21:38:15 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p, %p, %u.\n", iface, data, data_size);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
return opentype_analyze_container_type(data, data_size);
|
|
|
|
}
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory5_UnpackFontFile(IDWriteFactory7 *iface, DWRITE_CONTAINER_TYPE container_type, void const *data,
|
|
|
|
UINT32 data_size, IDWriteFontFileStream **stream)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d, %p, %u, %p: stub\n", iface, container_type, data, data_size, stream);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
2017-05-07 21:38:15 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory6_CreateFontFaceReference(IDWriteFactory7 *iface, IDWriteFontFile *file,
|
|
|
|
UINT32 face_index, DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values,
|
2019-12-05 09:56:01 +01:00
|
|
|
UINT32 axis_values_count, IDWriteFontFaceReference1 **reference)
|
2017-05-07 21:38:15 +02:00
|
|
|
{
|
2019-12-05 09:56:01 +01:00
|
|
|
TRACE("%p, %p, %u, %#x, %p, %u, %p.\n", iface, file, face_index, simulations, axis_values, axis_values_count,
|
|
|
|
reference);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-05 09:56:02 +01:00
|
|
|
return create_fontfacereference(iface, file, face_index, simulations, axis_values, axis_values_count, reference);
|
2019-12-02 13:53:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory6_CreateFontResource(IDWriteFactory7 *iface, IDWriteFontFile *file,
|
|
|
|
UINT32 face_index, IDWriteFontResource **resource)
|
|
|
|
{
|
2019-12-05 09:55:57 +01:00
|
|
|
TRACE("%p, %p, %u, %p.\n", iface, file, face_index, resource);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-05 09:55:57 +01:00
|
|
|
return create_font_resource(iface, file, face_index, resource);
|
2017-05-07 21:38:15 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory6_GetSystemFontSet(IDWriteFactory7 *iface, BOOL include_downloadable,
|
|
|
|
IDWriteFontSet1 **fontset)
|
2017-05-07 21:38:15 +02:00
|
|
|
{
|
2021-03-11 10:41:23 +01:00
|
|
|
TRACE("%p, %d, %p.\n", iface, include_downloadable, fontset);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2021-03-11 10:41:23 +01:00
|
|
|
if (include_downloadable)
|
|
|
|
FIXME("Downloadable fonts are not supported.\n");
|
|
|
|
|
|
|
|
return create_system_fontset(iface, &IID_IDWriteFontSet1, (void **)fontset);
|
2019-12-02 13:53:55 +01:00
|
|
|
}
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory6_GetSystemFontCollection(IDWriteFactory7 *iface, BOOL include_downloadable,
|
|
|
|
DWRITE_FONT_FAMILY_MODEL family_model, IDWriteFontCollection2 **collection)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d, %d, %p.\n", iface, include_downloadable, family_model, collection);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
2017-05-07 21:38:15 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory6_CreateFontCollectionFromFontSet(IDWriteFactory7 *iface, IDWriteFontSet *fontset,
|
|
|
|
DWRITE_FONT_FAMILY_MODEL family_model, IDWriteFontCollection2 **collection)
|
2017-05-07 21:38:15 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
FIXME("%p, %p, %d, %p.\n", iface, fontset, family_model, collection);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory6_CreateFontSetBuilder(IDWriteFactory7 *iface, IDWriteFontSetBuilder2 **builder)
|
|
|
|
{
|
2021-01-21 14:36:52 +01:00
|
|
|
TRACE("%p, %p.\n", iface, builder);
|
2017-05-07 21:38:15 +02:00
|
|
|
|
2021-01-21 14:36:52 +01:00
|
|
|
return create_fontset_builder(iface, builder);
|
2017-05-07 21:38:15 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static HRESULT WINAPI dwritefactory6_CreateTextFormat(IDWriteFactory7 *iface, const WCHAR *familyname,
|
|
|
|
IDWriteFontCollection *collection, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 num_axis,
|
|
|
|
FLOAT fontsize, const WCHAR *localename, IDWriteTextFormat3 **format)
|
|
|
|
{
|
|
|
|
FIXME("%p, %s, %p, %p, %u, %.8e, %s, %p.\n", iface, debugstr_w(familyname), collection, axis_values, num_axis,
|
|
|
|
fontsize, debugstr_w(localename), format);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory7_GetSystemFontSet(IDWriteFactory7 *iface, BOOL include_downloadable,
|
|
|
|
IDWriteFontSet2 **fontset)
|
|
|
|
{
|
2021-03-11 10:41:23 +01:00
|
|
|
TRACE("%p, %d, %p.\n", iface, include_downloadable, fontset);
|
2019-12-02 13:53:55 +01:00
|
|
|
|
2021-03-11 10:41:23 +01:00
|
|
|
if (include_downloadable)
|
|
|
|
FIXME("Downloadable fonts are not supported.\n");
|
|
|
|
|
|
|
|
return create_system_fontset(iface, &IID_IDWriteFontSet2, (void **)fontset);
|
2019-12-02 13:53:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI dwritefactory7_GetSystemFontCollection(IDWriteFactory7 *iface, BOOL include_downloadable,
|
|
|
|
DWRITE_FONT_FAMILY_MODEL family_model, IDWriteFontCollection3 **collection)
|
|
|
|
{
|
|
|
|
FIXME("%p, %d, %d, %p.\n", iface, include_downloadable, family_model, collection);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2021-02-01 12:35:23 +01:00
|
|
|
static const IDWriteFactory7Vtbl dwritefactoryvtbl =
|
2019-12-02 13:53:55 +01:00
|
|
|
{
|
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,
|
2016-10-11 14:20:26 +02:00
|
|
|
dwritefactory3_GetFontDownloadQueue,
|
|
|
|
dwritefactory4_TranslateColorGlyphRun,
|
|
|
|
dwritefactory4_ComputeGlyphOrigins_,
|
2017-05-07 21:38:15 +02:00
|
|
|
dwritefactory4_ComputeGlyphOrigins,
|
|
|
|
dwritefactory5_CreateFontSetBuilder,
|
|
|
|
dwritefactory5_CreateInMemoryFontFileLoader,
|
|
|
|
dwritefactory5_CreateHttpFontFileLoader,
|
|
|
|
dwritefactory5_AnalyzeContainerType,
|
|
|
|
dwritefactory5_UnpackFontFile,
|
2019-12-02 13:53:55 +01:00
|
|
|
dwritefactory6_CreateFontFaceReference,
|
|
|
|
dwritefactory6_CreateFontResource,
|
|
|
|
dwritefactory6_GetSystemFontSet,
|
|
|
|
dwritefactory6_GetSystemFontCollection,
|
|
|
|
dwritefactory6_CreateFontCollectionFromFontSet,
|
|
|
|
dwritefactory6_CreateFontSetBuilder,
|
|
|
|
dwritefactory6_CreateTextFormat,
|
|
|
|
dwritefactory7_GetSystemFontSet,
|
|
|
|
dwritefactory7_GetSystemFontCollection,
|
2012-07-31 06:07:49 +02:00
|
|
|
};
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static ULONG WINAPI shareddwritefactory_AddRef(IDWriteFactory7 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
static ULONG WINAPI shareddwritefactory_Release(IDWriteFactory7 *iface)
|
2014-10-09 07:05:27 +02:00
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
TRACE("%p.\n", iface);
|
|
|
|
|
2014-10-09 07:05:27 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-02-01 12:35:23 +01:00
|
|
|
static const IDWriteFactory7Vtbl shareddwritefactoryvtbl =
|
2019-12-02 13:53:55 +01:00
|
|
|
{
|
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,
|
2016-12-20 00:09:27 +01:00
|
|
|
dwritefactory3_GetFontDownloadQueue,
|
|
|
|
dwritefactory4_TranslateColorGlyphRun,
|
|
|
|
dwritefactory4_ComputeGlyphOrigins_,
|
2017-05-07 21:38:15 +02:00
|
|
|
dwritefactory4_ComputeGlyphOrigins,
|
|
|
|
dwritefactory5_CreateFontSetBuilder,
|
|
|
|
dwritefactory5_CreateInMemoryFontFileLoader,
|
|
|
|
dwritefactory5_CreateHttpFontFileLoader,
|
|
|
|
dwritefactory5_AnalyzeContainerType,
|
|
|
|
dwritefactory5_UnpackFontFile,
|
2019-12-02 13:53:55 +01:00
|
|
|
dwritefactory6_CreateFontFaceReference,
|
|
|
|
dwritefactory6_CreateFontResource,
|
|
|
|
dwritefactory6_GetSystemFontSet,
|
|
|
|
dwritefactory6_GetSystemFontCollection,
|
|
|
|
dwritefactory6_CreateFontCollectionFromFontSet,
|
|
|
|
dwritefactory6_CreateFontSetBuilder,
|
|
|
|
dwritefactory6_CreateTextFormat,
|
|
|
|
dwritefactory7_GetSystemFontSet,
|
|
|
|
dwritefactory7_GetSystemFontCollection,
|
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
|
|
|
{
|
2019-12-02 13:53:55 +01:00
|
|
|
factory->IDWriteFactory7_iface.lpVtbl = type == DWRITE_FACTORY_TYPE_SHARED ?
|
2017-05-07 21:38:15 +02:00
|
|
|
&shareddwritefactoryvtbl : &dwritefactoryvtbl;
|
2019-12-02 13:53:55 +01:00
|
|
|
factory->refcount = 1;
|
2017-09-24 23:08:40 +02:00
|
|
|
factory->localfontfileloader = get_local_fontfile_loader();
|
2014-10-09 07:05:27 +02:00
|
|
|
factory->system_collection = NULL;
|
2014-12-17 07:54:13 +01:00
|
|
|
factory->eudc_collection = NULL;
|
2017-04-11 13:21:32 +02:00
|
|
|
factory->gdiinterop = NULL;
|
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);
|
2017-08-15 13:40:24 +02:00
|
|
|
|
|
|
|
InitializeCriticalSection(&factory->cs);
|
|
|
|
factory->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": dwritefactory.lock");
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:03 +01:00
|
|
|
void factory_detach_fontcollection(IDWriteFactory7 *iface, IDWriteFontCollection3 *collection)
|
2017-04-11 13:21:32 +02:00
|
|
|
{
|
2019-12-05 09:56:03 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2017-08-22 11:42:12 +02:00
|
|
|
InterlockedCompareExchangePointer((void **)&factory->system_collection, NULL, collection);
|
2017-08-22 11:42:13 +02:00
|
|
|
InterlockedCompareExchangePointer((void **)&factory->eudc_collection, NULL, collection);
|
2019-12-05 09:56:03 +01:00
|
|
|
IDWriteFactory7_Release(iface);
|
2017-04-11 13:21:32 +02:00
|
|
|
}
|
|
|
|
|
2019-12-05 09:56:05 +01:00
|
|
|
void factory_detach_gdiinterop(IDWriteFactory7 *iface, IDWriteGdiInterop1 *interop)
|
2017-04-11 13:21:32 +02:00
|
|
|
{
|
2019-12-05 09:56:05 +01:00
|
|
|
struct dwritefactory *factory = impl_from_IDWriteFactory7(iface);
|
2017-04-11 13:21:32 +02:00
|
|
|
factory->gdiinterop = NULL;
|
2019-12-05 09:56:05 +01:00
|
|
|
IDWriteFactory7_Release(iface);
|
2017-04-11 13:21:32 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2021-02-04 11:19:46 +01:00
|
|
|
TRACE("%d, %s, %p.\n", type, debugstr_guid(riid), ret);
|
2014-10-09 07:05:27 +02:00
|
|
|
|
|
|
|
*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)
|
2019-12-02 13:53:55 +01:00
|
|
|
return IDWriteFactory7_QueryInterface(shared_factory, riid, (void**)ret);
|
2014-08-06 23:59:39 +02:00
|
|
|
|
2021-12-02 13:37:19 +01:00
|
|
|
if (!(factory = calloc(1, sizeof(*factory))))
|
|
|
|
return E_OUTOFMEMORY;
|
2014-10-09 07:05:27 +02:00
|
|
|
|
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)
|
2019-12-02 13:53:55 +01:00
|
|
|
if (InterlockedCompareExchangePointer((void **)&shared_factory, &factory->IDWriteFactory7_iface, NULL))
|
|
|
|
{
|
|
|
|
release_shared_factory(&factory->IDWriteFactory7_iface);
|
|
|
|
return IDWriteFactory7_QueryInterface(shared_factory, riid, (void**)ret);
|
2014-10-09 07:05:27 +02:00
|
|
|
}
|
2012-07-31 06:07:49 +02:00
|
|
|
|
2019-12-02 13:53:55 +01:00
|
|
|
hr = IDWriteFactory7_QueryInterface(&factory->IDWriteFactory7_iface, riid, (void**)ret);
|
|
|
|
IDWriteFactory7_Release(&factory->IDWriteFactory7_iface);
|
2016-03-28 12:33:56 +02:00
|
|
|
return hr;
|
2012-07-31 06:07:49 +02:00
|
|
|
}
|