Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/dwrite/font.c | 18 +++++++++++++++--- dlls/dwrite/tests/font.c | 25 ++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index baee8d1e491..19fe911420f 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -3002,11 +3002,23 @@ static HRESULT WINAPI dwritefontcollection1_GetFontFamily(IDWriteFontCollection3 }
static HRESULT WINAPI dwritefontcollection2_GetFontFamily(IDWriteFontCollection3 *iface, - UINT32 index, IDWriteFontFamily2 **family) + UINT32 index, IDWriteFontFamily2 **ret) { - FIXME("%p, %u, %p.\n", iface, index, family); + struct dwrite_fontcollection *collection = impl_from_IDWriteFontCollection3(iface); + struct dwrite_fontfamily *family; + HRESULT hr;
- return E_NOTIMPL; + TRACE("%p, %u, %p.\n", iface, index, ret); + + *ret = NULL; + + if (index >= collection->count) + return E_FAIL; + + if (SUCCEEDED(hr = create_fontfamily(collection, index, &family))) + *ret = &family->IDWriteFontFamily2_iface; + + return hr; }
static HRESULT WINAPI dwritefontcollection2_GetMatchingFonts(IDWriteFontCollection3 *iface, diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 07baf112eed..e1024d0263b 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -1521,14 +1521,15 @@ static void test_GetFontFamily(void) { IDWriteFontCollection *collection, *collection2; IDWriteFontCollection *syscoll; + IDWriteFontCollection2 *coll2; IDWriteFontFamily *family, *family2; IDWriteFontFamily1 *family1; IDWriteGdiInterop *interop; IDWriteFont *font, *font2; IDWriteFactory *factory; LOGFONTW logfont; + ULONG ref, count; HRESULT hr; - ULONG ref;
factory = create_factory();
@@ -1656,6 +1657,28 @@ if (0) /* crashes on native */ else win_skip("IDWriteFontFamily1 is not supported.\n");
+ /* IDWriteFontCollection2::GetFontFamily() */ + if (SUCCEEDED(IDWriteFontCollection_QueryInterface(syscoll, &IID_IDWriteFontCollection2, (void **)&coll2))) + { + IDWriteFontFamily2 *family2; + + count = IDWriteFontCollection2_GetFontFamilyCount(coll2); + ok(!!count, "Unexpected family count.\n"); + + family2 = (void *)0xdeadbeef; + hr = IDWriteFontCollection2_GetFontFamily(coll2, count, &family2); + ok(hr == E_FAIL, "Unexpected hr %#x.\n", hr); + ok(!family2, "Unexpected pointer.\n"); + + hr = IDWriteFontCollection2_GetFontFamily(coll2, 0, &family2); + ok(hr == S_OK, "Failed to get family, hr %#x.\n", hr); + IDWriteFontFamily2_Release(family2); + + IDWriteFontCollection2_Release(coll2); + } + else + win_skip("IDWriteFontCollection2 is not supported.\n"); + IDWriteFontCollection_Release(syscoll); IDWriteFontCollection_Release(collection2); IDWriteFontCollection_Release(collection);