dwrite: Implement another GetFontFamily() variant.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-06-11 15:09:00 +03:00 committed by Alexandre Julliard
parent 292dff589e
commit c440d87464
2 changed files with 39 additions and 4 deletions

View File

@ -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,

View File

@ -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);