From cd4101dbba176b2627bfbf5f8a15ec80c8bdd858 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 9 Oct 2019 11:04:55 +0300 Subject: [PATCH] dwrite: Update to IDWriteFontFallback1. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/analyzer.c | 127 ++++++++++++++++++++++------------- dlls/dwrite/dwrite_private.h | 4 +- dlls/dwrite/main.c | 16 +++-- dlls/dwrite/tests/layout.c | 16 +++++ 4 files changed, 107 insertions(+), 56 deletions(-) diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index 7fc955eaf8e..8db5cc709ba 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -234,9 +234,10 @@ static const struct fallback_mapping fontfallback_neutral_data[] = { #undef MAPPING_RANGE }; -struct dwrite_fontfallback { - IDWriteFontFallback IDWriteFontFallback_iface; - LONG ref; +struct dwrite_fontfallback +{ + IDWriteFontFallback1 IDWriteFontFallback1_iface; + LONG refcount; IDWriteFactory5 *factory; IDWriteFontCollection1 *systemcollection; 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 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) @@ -1930,15 +1931,16 @@ HRESULT create_numbersubstitution(DWRITE_NUMBER_SUBSTITUTION_METHOD method, cons } /* 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_IDWriteFontFallback) || IsEqualIID(riid, &IID_IUnknown)) { + if (IsEqualIID(riid, &IID_IDWriteFontFallback1) || + IsEqualIID(riid, &IID_IDWriteFontFallback) || + IsEqualIID(riid, &IID_IUnknown)) + { *obj = iface; - IDWriteFontFallback_AddRef(iface); + IDWriteFontFallback1_AddRef(iface); return S_OK; } @@ -1948,17 +1950,21 @@ static HRESULT WINAPI fontfallback_QueryInterface(IDWriteFontFallback *iface, RE 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); - TRACE("(%p)\n", fallback); + struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface); + + TRACE("%p.\n", iface); + 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); - TRACE("(%p)\n", fallback); + struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface); + + TRACE("%p.\n", fallback); + 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; } -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, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length, IDWriteFont **ret_font, FLOAT *scale) { - struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface); + struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface); WCHAR *buff = NULL; const WCHAR *text; HRESULT hr; - TRACE("(%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); + TRACE("%p, %p, %u, %u, %p, %s, %u, %u, %u, %p, %p, %p.\n", iface, source, position, length, basecollection, + debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale); *mapped_length = 0; *scale = 1.0f; @@ -2148,14 +2154,27 @@ done: 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_AddRef, 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; @@ -2165,65 +2184,79 @@ HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback if (!fallback) return E_OUTOFMEMORY; - fallback->IDWriteFontFallback_iface.lpVtbl = &fontfallbackvtbl; + fallback->IDWriteFontFallback1_iface.lpVtbl = &fontfallbackvtbl; fallback->factory = factory; fallback->mappings = (struct fallback_mapping *)fontfallback_neutral_data; fallback->mappings_count = ARRAY_SIZE(fontfallback_neutral_data); IDWriteFactory5_GetSystemFontCollection(fallback->factory, FALSE, &fallback->systemcollection, FALSE); - *ret = &fallback->IDWriteFontFallback_iface; + *ret = &fallback->IDWriteFontFallback1_iface; + 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); 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); - ULONG ref = InterlockedIncrement(&fallback->ref); - TRACE("(%p)->(%d)\n", fallback, ref); - return ref; + struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface); + ULONG refcount = InterlockedIncrement(&fallback->refcount); + + 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); - ULONG ref = InterlockedDecrement(&fallback->ref); + struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback1(iface); + 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); 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, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length, 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", fallback, source, position, length, + FIXME("%p, %p, %u, %u, %p, %s, %u, %u, %u, %p, %p, %p.\n", iface, source, position, length, basecollection, debugstr_w(basefamily), weight, style, stretch, mapped_length, ret_font, scale); 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, customfontfallback_AddRef, customfontfallback_Release, customfontfallback_MapCharacters, + customfontfallback1_MapCharacters, }; static HRESULT WINAPI fontfallbackbuilder_QueryInterface(IDWriteFontFallbackBuilder *iface, REFIID riid, void **obj) @@ -2347,12 +2380,12 @@ static HRESULT WINAPI fontfallbackbuilder_CreateFontFallback(IDWriteFontFallback if (!fallback) return E_OUTOFMEMORY; - fallback->IDWriteFontFallback_iface.lpVtbl = &customfontfallbackvtbl; - fallback->ref = 1; + fallback->IDWriteFontFallback1_iface.lpVtbl = &customfontfallbackvtbl; + fallback->refcount = 1; fallback->factory = fallbackbuilder->factory; IDWriteFactory5_AddRef(fallback->factory); - *ret = &fallback->IDWriteFontFallback_iface; + *ret = (IDWriteFontFallback *)&fallback->IDWriteFontFallback1_iface; return S_OK; } diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 406664a5909..d3d74e07090 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -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, const DWRITE_MATRIX*,UINT32,IDWriteColorGlyphRunEnumerator**) DECLSPEC_HIDDEN; extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN; -extern HRESULT create_system_fontfallback(IDWriteFactory5*,IDWriteFontFallback**) DECLSPEC_HIDDEN; -extern void release_system_fontfallback(IDWriteFontFallback*) DECLSPEC_HIDDEN; +extern HRESULT create_system_fontfallback(IDWriteFactory5 *factory, IDWriteFontFallback1 **fallback) DECLSPEC_HIDDEN; +extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) 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, IDWriteFont**) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index ccf4cb51b96..fb3ed090e60 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -547,14 +547,15 @@ struct fileloader IDWriteFontFileLoader *loader; }; -struct dwritefactory { +struct dwritefactory +{ IDWriteFactory5 IDWriteFactory5_iface; LONG ref; IDWriteFontCollection1 *system_collection; IDWriteFontCollection1 *eudc_collection; IDWriteGdiInterop1 *gdiinterop; - IDWriteFontFallback *fallback; + IDWriteFontFallback1 *fallback; IDWriteFontFileLoader *localfontfileloader; struct list localfontfaces; @@ -1333,19 +1334,20 @@ static HRESULT WINAPI dwritefactory1_CreateCustomRenderingParams(IDWriteFactory5 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; - if (!This->fallback) { - HRESULT hr = create_system_fontfallback(iface, &This->fallback); + if (!factory->fallback) + { + HRESULT hr = create_system_fontfallback(iface, &factory->fallback); if (FAILED(hr)) return hr; } - *fallback = This->fallback; + *fallback = (IDWriteFontFallback *)factory->fallback; IDWriteFontFallback_AddRef(*fallback); return S_OK; } diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index b153bcbb69a..b96c0f4b37d 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4704,6 +4704,7 @@ static void test_FontFallbackBuilder(void) static const WCHAR strW[] = {'A',0}; IDWriteFontFallback *fallback, *fallback2; IDWriteFontFallbackBuilder *builder; + IDWriteFontFallback1 *fallback1; DWRITE_UNICODE_RANGE range; IDWriteFactory2 *factory2; IDWriteFactory *factory; @@ -4891,6 +4892,13 @@ todo_wine { if (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); IDWriteFontFallbackBuilder_Release(builder); @@ -4902,6 +4910,7 @@ static void test_fallback(void) { static const WCHAR strW[] = {'a','b','c','d',0}; IDWriteFontFallback *fallback, *fallback2; + IDWriteFontFallback1 *fallback1; DWRITE_CLUSTER_METRICS clusters[4]; DWRITE_TEXT_METRICS metrics; IDWriteTextLayout2 *layout2; @@ -5002,6 +5011,13 @@ todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); 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); IDWriteTextFormat1_Release(format1); IDWriteTextLayout2_Release(layout2);