dwrite: Update to IDWriteFontFallback1.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-10-09 11:04:55 +03:00 committed by Alexandre Julliard
parent 28dc5ff191
commit cd4101dbba
4 changed files with 107 additions and 56 deletions

View File

@ -234,9 +234,10 @@ static const struct fallback_mapping fontfallback_neutral_data[] = {
#undef MAPPING_RANGE #undef MAPPING_RANGE
}; };
struct dwrite_fontfallback { struct dwrite_fontfallback
IDWriteFontFallback IDWriteFontFallback_iface; {
LONG ref; IDWriteFontFallback1 IDWriteFontFallback1_iface;
LONG refcount;
IDWriteFactory5 *factory; IDWriteFactory5 *factory;
IDWriteFontCollection1 *systemcollection; IDWriteFontCollection1 *systemcollection;
struct fallback_mapping *mappings; struct fallback_mapping *mappings;
@ -269,9 +270,9 @@ static inline struct dwrite_numbersubstitution *impl_from_IDWriteNumberSubstitut
static struct dwrite_numbersubstitution *unsafe_impl_from_IDWriteNumberSubstitution(IDWriteNumberSubstitution *iface); static struct dwrite_numbersubstitution *unsafe_impl_from_IDWriteNumberSubstitution(IDWriteNumberSubstitution *iface);
static inline struct dwrite_fontfallback *impl_from_IDWriteFontFallback(IDWriteFontFallback *iface) static inline struct dwrite_fontfallback *impl_from_IDWriteFontFallback1(IDWriteFontFallback1 *iface)
{ {
return CONTAINING_RECORD(iface, struct dwrite_fontfallback, IDWriteFontFallback_iface); return CONTAINING_RECORD(iface, struct dwrite_fontfallback, IDWriteFontFallback1_iface);
} }
static inline struct dwrite_fontfallback_builder *impl_from_IDWriteFontFallbackBuilder(IDWriteFontFallbackBuilder *iface) static inline struct dwrite_fontfallback_builder *impl_from_IDWriteFontFallbackBuilder(IDWriteFontFallbackBuilder *iface)
@ -1930,15 +1931,16 @@ HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD method, cons
} }
/* IDWriteFontFallback */ /* IDWriteFontFallback */
static HRESULT WINAPI fontfallback_QueryInterface(IDWriteFontFallback *iface, REFIID riid, void **obj) static HRESULT WINAPI fontfallback_QueryInterface(IDWriteFontFallback1 *iface, REFIID riid, void **obj)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
TRACE("(%p)->(%s %p)\n", fallback, debugstr_guid(riid), obj); if (IsEqualIID(riid, &IID_IDWriteFontFallback1) ||
IsEqualIID(riid, &IID_IDWriteFontFallback) ||
if (IsEqualIID(riid, &IID_IDWriteFontFallback) || IsEqualIID(riid, &IID_IUnknown)) { IsEqualIID(riid, &IID_IUnknown))
{
*obj = iface; *obj = iface;
IDWriteFontFallback_AddRef(iface); IDWriteFontFallback1_AddRef(iface);
return S_OK; return S_OK;
} }
@ -1948,17 +1950,21 @@ static HRESULT WINAPI fontfallback_QueryInterface(IDWriteFontFallback *iface, RE
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG WINAPI fontfallback_AddRef(IDWriteFontFallback *iface) static ULONG WINAPI fontfallback_AddRef(IDWriteFontFallback1 *iface)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
TRACE("(%p)\n", fallback);
TRACE("%p.\n", iface);
return IDWriteFactory5_AddRef(fallback->factory); return IDWriteFactory5_AddRef(fallback->factory);
} }
static ULONG WINAPI fontfallback_Release(IDWriteFontFallback *iface) static ULONG WINAPI fontfallback_Release(IDWriteFontFallback1 *iface)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
TRACE("(%p)\n", fallback);
TRACE("%p.\n", fallback);
return IDWriteFactory5_Release(fallback->factory); return IDWriteFactory5_Release(fallback->factory);
} }
@ -2085,18 +2091,18 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
return *mapped_length ? S_OK : E_FAIL; return *mapped_length ? S_OK : E_FAIL;
} }
static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback *iface, IDWriteTextAnalysisSource *source, static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback1 *iface, IDWriteTextAnalysisSource *source,
UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily, UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily,
DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length,
IDWriteFont **ret_font, FLOAT *scale) IDWriteFont **ret_font, FLOAT *scale)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
WCHAR *buff = NULL; WCHAR *buff = NULL;
const WCHAR *text; const WCHAR *text;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(%p %u %u %p, %s, %u, %u, %u, %p, %p, %p)\n", fallback, source, position, length, TRACE("%p, %p, %u, %u, %p, %s, %u, %u, %u, %p, %p, %p.\n", iface, source, position, length, basecollection,
basecollection, debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale); debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale);
*mapped_length = 0; *mapped_length = 0;
*scale = 1.0f; *scale = 1.0f;
@ -2148,14 +2154,27 @@ done:
return hr; return hr;
} }
static const IDWriteFontFallbackVtbl fontfallbackvtbl = { static HRESULT WINAPI fontfallback1_MapCharacters(IDWriteFontFallback1 *iface, IDWriteTextAnalysisSource *source,
UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily,
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 values_count, UINT32 *mapped_length, FLOAT *scale,
IDWriteFontFace5 **ret_fontface)
{
FIXME("%p, %p, %u, %u, %p, %s, %p, %u, %p, %p, %p.\n", iface, source, position, length, basecollection,
debugstr_w(basefamily), axis_values, values_count, mapped_length, scale, ret_fontface);
return E_NOTIMPL;
}
static const IDWriteFontFallback1Vtbl fontfallbackvtbl =
{
fontfallback_QueryInterface, fontfallback_QueryInterface,
fontfallback_AddRef, fontfallback_AddRef,
fontfallback_Release, fontfallback_Release,
fontfallback_MapCharacters fontfallback_MapCharacters,
fontfallback1_MapCharacters,
}; };
HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback **ret) HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback1 **ret)
{ {
struct dwrite_fontfallback *fallback; struct dwrite_fontfallback *fallback;
@ -2165,65 +2184,79 @@ HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback
if (!fallback) if (!fallback)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
fallback->IDWriteFontFallback_iface.lpVtbl = &fontfallbackvtbl; fallback->IDWriteFontFallback1_iface.lpVtbl = &fontfallbackvtbl;
fallback->factory = factory; fallback->factory = factory;
fallback->mappings = (struct fallback_mapping *)fontfallback_neutral_data; fallback->mappings = (struct fallback_mapping *)fontfallback_neutral_data;
fallback->mappings_count = ARRAY_SIZE(fontfallback_neutral_data); fallback->mappings_count = ARRAY_SIZE(fontfallback_neutral_data);
IDWriteFactory5_GetSystemFontCollection(fallback->factory, FALSE, &fallback->systemcollection, FALSE); IDWriteFactory5_GetSystemFontCollection(fallback->factory, FALSE, &fallback->systemcollection, FALSE);
*ret = &fallback->IDWriteFontFallback_iface; *ret = &fallback->IDWriteFontFallback1_iface;
return S_OK; return S_OK;
} }
void release_system_fontfallback(IDWriteFontFallback *iface) void release_system_fontfallback(IDWriteFontFallback1 *iface)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
IDWriteFontCollection1_Release(fallback->systemcollection); IDWriteFontCollection1_Release(fallback->systemcollection);
heap_free(fallback); heap_free(fallback);
} }
static ULONG WINAPI customfontfallback_AddRef(IDWriteFontFallback *iface) static ULONG WINAPI customfontfallback_AddRef(IDWriteFontFallback1 *iface)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
ULONG ref = InterlockedIncrement(&fallback->ref); ULONG refcount = InterlockedIncrement(&fallback->refcount);
TRACE("(%p)->(%d)\n", fallback, ref);
return ref; TRACE("%p, refcount %u.\n", iface, refcount);
return refcount;
} }
static ULONG WINAPI customfontfallback_Release(IDWriteFontFallback *iface) static ULONG WINAPI customfontfallback_Release(IDWriteFontFallback1 *iface)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface);
ULONG ref = InterlockedDecrement(&fallback->ref); ULONG refcount = InterlockedDecrement(&fallback->refcount);
TRACE("(%p)->(%d)\n", fallback, ref); TRACE("%p, refcount %u.\n", iface, refcount);
if (!ref) { if (!refcount)
{
IDWriteFactory5_Release(fallback->factory); IDWriteFactory5_Release(fallback->factory);
heap_free(fallback); heap_free(fallback);
} }
return ref; return refcount;
} }
static HRESULT WINAPI customfontfallback_MapCharacters(IDWriteFontFallback *iface, IDWriteTextAnalysisSource *source, static HRESULT WINAPI customfontfallback_MapCharacters(IDWriteFontFallback1 *iface, IDWriteTextAnalysisSource *source,
UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily, UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily,
DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length,
IDWriteFont **ret_font, FLOAT *scale) IDWriteFont **ret_font, FLOAT *scale)
{ {
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); FIXME("%p, %p, %u, %u, %p, %s, %u, %u, %u, %p, %p, %p.\n", iface, source, position, length,
FIXME("(%p)->(%p %u %u %p, %s, %u, %u, %u, %p, %p, %p)\n", fallback, source, position, length,
basecollection, debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale); basecollection, debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale);
return E_NOTIMPL; return E_NOTIMPL;
} }
static const IDWriteFontFallbackVtbl customfontfallbackvtbl = static HRESULT WINAPI customfontfallback1_MapCharacters(IDWriteFontFallback1 *iface, IDWriteTextAnalysisSource *source,
UINT32 position, UINT32 length, IDWriteFontCollection *basecollection, const WCHAR *basefamily,
DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 values_count, UINT32 *mapped_length, FLOAT *scale,
IDWriteFontFace5 **ret_fontface)
{
FIXME("%p, %p, %u, %u, %p, %s, %p, %u, %p, %p, %p.\n", iface, source, position, length, basecollection,
debugstr_w(basefamily), axis_values, values_count, mapped_length, scale, ret_fontface);
return E_NOTIMPL;
}
static const IDWriteFontFallback1Vtbl customfontfallbackvtbl =
{ {
fontfallback_QueryInterface, fontfallback_QueryInterface,
customfontfallback_AddRef, customfontfallback_AddRef,
customfontfallback_Release, customfontfallback_Release,
customfontfallback_MapCharacters, customfontfallback_MapCharacters,
customfontfallback1_MapCharacters,
}; };
static HRESULT WINAPI fontfallbackbuilder_QueryInterface(IDWriteFontFallbackBuilder *iface, REFIID riid, void **obj) static HRESULT WINAPI fontfallbackbuilder_QueryInterface(IDWriteFontFallbackBuilder *iface, REFIID riid, void **obj)
@ -2347,12 +2380,12 @@ static HRESULT WINAPI fontfallbackbuilder_CreateFontFallback(IDWriteFontFallback
if (!fallback) if (!fallback)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
fallback->IDWriteFontFallback_iface.lpVtbl = &customfontfallbackvtbl; fallback->IDWriteFontFallback1_iface.lpVtbl = &customfontfallbackvtbl;
fallback->ref = 1; fallback->refcount = 1;
fallback->factory = fallbackbuilder->factory; fallback->factory = fallbackbuilder->factory;
IDWriteFactory5_AddRef(fallback->factory); IDWriteFactory5_AddRef(fallback->factory);
*ret = &fallback->IDWriteFontFallback_iface; *ret = (IDWriteFontFallback *)&fallback->IDWriteFontFallback1_iface;
return S_OK; return S_OK;
} }

View File

@ -256,8 +256,8 @@ extern HRESULT get_family_names_from_stream(IDWriteFontFileStream*,UINT32,DWRITE
extern HRESULT create_colorglyphenum(FLOAT,FLOAT,const DWRITE_GLYPH_RUN*,const DWRITE_GLYPH_RUN_DESCRIPTION*,DWRITE_MEASURING_MODE, extern HRESULT create_colorglyphenum(FLOAT,FLOAT,const DWRITE_GLYPH_RUN*,const DWRITE_GLYPH_RUN_DESCRIPTION*,DWRITE_MEASURING_MODE,
const DWRITE_MATRIX*,UINT32,IDWriteColorGlyphRunEnumerator**) DECLSPEC_HIDDEN; const DWRITE_MATRIX*,UINT32,IDWriteColorGlyphRunEnumerator**) DECLSPEC_HIDDEN;
extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN; extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN;
extern HRESULT create_system_fontfallback(IDWriteFactory5*,IDWriteFontFallback**) DECLSPEC_HIDDEN; extern HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback1 **fallback) DECLSPEC_HIDDEN;
extern void release_system_fontfallback(IDWriteFontFallback*) DECLSPEC_HIDDEN; extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC_HIDDEN;
extern HRESULT create_fontfallback_builder(IDWriteFactory5*,IDWriteFontFallbackBuilder**) DECLSPEC_HIDDEN; extern HRESULT create_fontfallback_builder(IDWriteFactory5*,IDWriteFontFallbackBuilder**) DECLSPEC_HIDDEN;
extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH, extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
IDWriteFont**) DECLSPEC_HIDDEN; IDWriteFont**) DECLSPEC_HIDDEN;

View File

@ -547,14 +547,15 @@ struct fileloader
IDWriteFontFileLoader *loader; IDWriteFontFileLoader *loader;
}; };
struct dwritefactory { struct dwritefactory
{
IDWriteFactory5 IDWriteFactory5_iface; IDWriteFactory5 IDWriteFactory5_iface;
LONG ref; LONG ref;
IDWriteFontCollection1 *system_collection; IDWriteFontCollection1 *system_collection;
IDWriteFontCollection1 *eudc_collection; IDWriteFontCollection1 *eudc_collection;
IDWriteGdiInterop1 *gdiinterop; IDWriteGdiInterop1 *gdiinterop;
IDWriteFontFallback *fallback; IDWriteFontFallback1 *fallback;
IDWriteFontFileLoader *localfontfileloader; IDWriteFontFileLoader *localfontfileloader;
struct list localfontfaces; struct list localfontfaces;
@ -1333,19 +1334,20 @@ static HRESULT WINAPI dwritefactory1_CreateCustomRenderingParams(IDWriteFactory5
static HRESULT WINAPI dwritefactory2_GetSystemFontFallback(IDWriteFactory5 *iface, IDWriteFontFallback **fallback) static HRESULT WINAPI dwritefactory2_GetSystemFontFallback(IDWriteFactory5 *iface, IDWriteFontFallback **fallback)
{ {
struct dwritefactory *This = impl_from_IDWriteFactory5(iface); struct dwritefactory *factory = impl_from_IDWriteFactory5(iface);
TRACE("(%p)->(%p)\n", This, fallback); TRACE("%p, %p.\n", iface, fallback);
*fallback = NULL; *fallback = NULL;
if (!This->fallback) { if (!factory->fallback)
HRESULT hr = create_system_fontfallback(iface, &This->fallback); {
HRESULT hr = create_system_fontfallback(iface, &factory->fallback);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
} }
*fallback = This->fallback; *fallback = (IDWriteFontFallback *)factory->fallback;
IDWriteFontFallback_AddRef(*fallback); IDWriteFontFallback_AddRef(*fallback);
return S_OK; return S_OK;
} }

View File

@ -4704,6 +4704,7 @@ static void test_FontFallbackBuilder(void)
static const WCHAR strW[] = {'A',0}; static const WCHAR strW[] = {'A',0};
IDWriteFontFallback *fallback, *fallback2; IDWriteFontFallback *fallback, *fallback2;
IDWriteFontFallbackBuilder *builder; IDWriteFontFallbackBuilder *builder;
IDWriteFontFallback1 *fallback1;
DWRITE_UNICODE_RANGE range; DWRITE_UNICODE_RANGE range;
IDWriteFactory2 *factory2; IDWriteFactory2 *factory2;
IDWriteFactory *factory; IDWriteFactory *factory;
@ -4891,6 +4892,13 @@ todo_wine {
if (font) if (font)
IDWriteFont_Release(font); IDWriteFont_Release(font);
if (SUCCEEDED(IDWriteFontFallback_QueryInterface(fallback, &IID_IDWriteFontFallback1, (void **)&fallback1)))
{
IDWriteFontFallback1_Release(fallback1);
}
else
win_skip("IDWriteFontFallback1 is not supported.\n");
IDWriteFontFallback_Release(fallback); IDWriteFontFallback_Release(fallback);
IDWriteFontFallbackBuilder_Release(builder); IDWriteFontFallbackBuilder_Release(builder);
@ -4902,6 +4910,7 @@ static void test_fallback(void)
{ {
static const WCHAR strW[] = {'a','b','c','d',0}; static const WCHAR strW[] = {'a','b','c','d',0};
IDWriteFontFallback *fallback, *fallback2; IDWriteFontFallback *fallback, *fallback2;
IDWriteFontFallback1 *fallback1;
DWRITE_CLUSTER_METRICS clusters[4]; DWRITE_CLUSTER_METRICS clusters[4];
DWRITE_TEXT_METRICS metrics; DWRITE_TEXT_METRICS metrics;
IDWriteTextLayout2 *layout2; IDWriteTextLayout2 *layout2;
@ -5002,6 +5011,13 @@ todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(fallback2 == NULL, "got %p\n", fallback2); ok(fallback2 == NULL, "got %p\n", fallback2);
if (SUCCEEDED(IDWriteFontFallback_QueryInterface(fallback, &IID_IDWriteFontFallback1, (void **)&fallback1)))
{
IDWriteFontFallback1_Release(fallback1);
}
else
win_skip("IDWriteFontFallback1 is not supported.\n");
IDWriteFontFallback_Release(fallback); IDWriteFontFallback_Release(fallback);
IDWriteTextFormat1_Release(format1); IDWriteTextFormat1_Release(format1);
IDWriteTextLayout2_Release(layout2); IDWriteTextLayout2_Release(layout2);