dwrite: Update to IDWriteFontList1.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
42de7a468c
commit
6ff1f38ba2
|
@ -97,7 +97,7 @@ struct dwrite_font_data {
|
|||
};
|
||||
|
||||
struct dwrite_fontlist {
|
||||
IDWriteFontList IDWriteFontList_iface;
|
||||
IDWriteFontList1 IDWriteFontList1_iface;
|
||||
LONG ref;
|
||||
|
||||
IDWriteFontFamily1 *family;
|
||||
|
@ -277,9 +277,9 @@ static inline struct dwrite_colorglyphenum *impl_from_IDWriteColorGlyphRunEnumer
|
|||
return CONTAINING_RECORD(iface, struct dwrite_colorglyphenum, IDWriteColorGlyphRunEnumerator_iface);
|
||||
}
|
||||
|
||||
static inline struct dwrite_fontlist *impl_from_IDWriteFontList(IDWriteFontList *iface)
|
||||
static inline struct dwrite_fontlist *impl_from_IDWriteFontList1(IDWriteFontList1 *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct dwrite_fontlist, IDWriteFontList_iface);
|
||||
return CONTAINING_RECORD(iface, struct dwrite_fontlist, IDWriteFontList1_iface);
|
||||
}
|
||||
|
||||
static inline const char *debugstr_tag(UINT32 tag)
|
||||
|
@ -1561,18 +1561,19 @@ static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily1 *fa
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
/* IDWriteFontList */
|
||||
static HRESULT WINAPI dwritefontlist_QueryInterface(IDWriteFontList *iface, REFIID riid, void **obj)
|
||||
/* IDWriteFontList1 */
|
||||
static HRESULT WINAPI dwritefontlist_QueryInterface(IDWriteFontList1 *iface, REFIID riid, void **obj)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
|
||||
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
|
||||
|
||||
if (IsEqualIID(riid, &IID_IDWriteFontList) ||
|
||||
if (IsEqualIID(riid, &IID_IDWriteFontList1) ||
|
||||
IsEqualIID(riid, &IID_IDWriteFontList) ||
|
||||
IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
*obj = iface;
|
||||
IDWriteFontList_AddRef(iface);
|
||||
IDWriteFontList1_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -1580,17 +1581,17 @@ static HRESULT WINAPI dwritefontlist_QueryInterface(IDWriteFontList *iface, REFI
|
|||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI dwritefontlist_AddRef(IDWriteFontList *iface)
|
||||
static ULONG WINAPI dwritefontlist_AddRef(IDWriteFontList1 *iface)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
ULONG ref = InterlockedIncrement(&This->ref);
|
||||
TRACE("(%p)->(%d)\n", This, ref);
|
||||
return ref;
|
||||
}
|
||||
|
||||
static ULONG WINAPI dwritefontlist_Release(IDWriteFontList *iface)
|
||||
static ULONG WINAPI dwritefontlist_Release(IDWriteFontList1 *iface)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
ULONG ref = InterlockedDecrement(&This->ref);
|
||||
|
||||
TRACE("(%p)->(%d)\n", This, ref);
|
||||
|
@ -1607,22 +1608,22 @@ static ULONG WINAPI dwritefontlist_Release(IDWriteFontList *iface)
|
|||
return ref;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontlist_GetFontCollection(IDWriteFontList *iface, IDWriteFontCollection **collection)
|
||||
static HRESULT WINAPI dwritefontlist_GetFontCollection(IDWriteFontList1 *iface, IDWriteFontCollection **collection)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
return IDWriteFontFamily1_GetFontCollection(This->family, collection);
|
||||
}
|
||||
|
||||
static UINT32 WINAPI dwritefontlist_GetFontCount(IDWriteFontList *iface)
|
||||
static UINT32 WINAPI dwritefontlist_GetFontCount(IDWriteFontList1 *iface)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
TRACE("(%p)\n", This);
|
||||
return This->font_count;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontlist_GetFont(IDWriteFontList *iface, UINT32 index, IDWriteFont **font)
|
||||
static HRESULT WINAPI dwritefontlist_GetFont(IDWriteFontList1 *iface, UINT32 index, IDWriteFont **font)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList(iface);
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
|
||||
TRACE("(%p)->(%u %p)\n", This, index, font);
|
||||
|
||||
|
@ -1637,13 +1638,44 @@ static HRESULT WINAPI dwritefontlist_GetFont(IDWriteFontList *iface, UINT32 inde
|
|||
return create_font(This->fonts[index], This->family, (IDWriteFont3**)font);
|
||||
}
|
||||
|
||||
static const IDWriteFontListVtbl dwritefontlistvtbl = {
|
||||
static DWRITE_LOCALITY WINAPI dwritefontlist1_GetFontLocality(IDWriteFontList1 *iface, UINT32 index)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
|
||||
FIXME("(%p)->(%u): stub\n", This, index);
|
||||
|
||||
return DWRITE_LOCALITY_LOCAL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontlist1_GetFont(IDWriteFontList1 *iface, UINT32 index, IDWriteFont3 **font)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
|
||||
FIXME("(%p)->(%u %p): stub\n", This, index, font);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontlist1_GetFontFaceReference(IDWriteFontList1 *iface, UINT32 index,
|
||||
IDWriteFontFaceReference **reference)
|
||||
{
|
||||
struct dwrite_fontlist *This = impl_from_IDWriteFontList1(iface);
|
||||
|
||||
FIXME("(%p)->(%u %p): stub\n", This, index, reference);
|
||||
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const IDWriteFontList1Vtbl dwritefontlistvtbl = {
|
||||
dwritefontlist_QueryInterface,
|
||||
dwritefontlist_AddRef,
|
||||
dwritefontlist_Release,
|
||||
dwritefontlist_GetFontCollection,
|
||||
dwritefontlist_GetFontCount,
|
||||
dwritefontlist_GetFont
|
||||
dwritefontlist_GetFont,
|
||||
dwritefontlist1_GetFontLocality,
|
||||
dwritefontlist1_GetFont,
|
||||
dwritefontlist1_GetFontFaceReference
|
||||
};
|
||||
|
||||
static HRESULT WINAPI dwritefontfamily_QueryInterface(IDWriteFontFamily1 *iface, REFIID riid, void **obj)
|
||||
|
@ -1856,7 +1888,7 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
fonts->IDWriteFontList_iface.lpVtbl = &dwritefontlistvtbl;
|
||||
fonts->IDWriteFontList1_iface.lpVtbl = &dwritefontlistvtbl;
|
||||
fonts->ref = 1;
|
||||
fonts->family = iface;
|
||||
IDWriteFontFamily1_AddRef(fonts->family);
|
||||
|
@ -1884,7 +1916,7 @@ static HRESULT WINAPI dwritefontfamily_GetMatchingFonts(IDWriteFontFamily1 *ifac
|
|||
init_font_prop_vec(weight, stretch, style, &req);
|
||||
matchingfonts_sort(fonts, &req);
|
||||
|
||||
*ret = &fonts->IDWriteFontList_iface;
|
||||
*ret = (IDWriteFontList*)&fonts->IDWriteFontList1_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -1123,6 +1123,7 @@ if (0) /* crashes on native */
|
|||
|
||||
hr = IDWriteFontFamily_QueryInterface(family, &IID_IDWriteFontFamily1, (void**)&family1);
|
||||
if (hr == S_OK) {
|
||||
IDWriteFontList *fontlist;
|
||||
IDWriteFont3 *font3;
|
||||
IDWriteFont1 *font1;
|
||||
|
||||
|
@ -1142,6 +1143,13 @@ if (0) /* crashes on native */
|
|||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
IDWriteFont1_Release(font1);
|
||||
|
||||
hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList1, (void**)&fontlist);
|
||||
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontFamily1_QueryInterface(family1, &IID_IDWriteFontList, (void**)&fontlist);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
IDWriteFontList_Release(fontlist);
|
||||
|
||||
IDWriteFont3_Release(font3);
|
||||
IDWriteFontFamily1_Release(family1);
|
||||
}
|
||||
|
@ -2473,22 +2481,88 @@ static void test_GetFontFromFontFace(void)
|
|||
static void test_GetFirstMatchingFont(void)
|
||||
{
|
||||
DWRITE_FONT_SIMULATIONS simulations;
|
||||
IDWriteFontCollection *collection;
|
||||
IDWriteFontFamily *family;
|
||||
IDWriteFont *font, *font2;
|
||||
IDWriteFactory *factory;
|
||||
HRESULT hr;
|
||||
|
||||
factory = create_factory();
|
||||
|
||||
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
||||
font2 = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
|
||||
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontFamily_GetFirstMatchingFont(family, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &font2);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(font != font2, "got %p, %p\n", font, font2);
|
||||
IDWriteFont_Release(font);
|
||||
IDWriteFont_Release(font2);
|
||||
|
||||
IDWriteFontFamily_Release(family);
|
||||
|
||||
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_ITALIC);
|
||||
simulations = IDWriteFont_GetSimulations(font);
|
||||
ok(simulations == DWRITE_FONT_SIMULATIONS_OBLIQUE, "%d\n", simulations);
|
||||
IDWriteFont_Release(font);
|
||||
|
||||
IDWriteFontCollection_Release(collection);
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
||||
static void test_GetMatchingFonts(void)
|
||||
{
|
||||
IDWriteFontCollection *collection;
|
||||
IDWriteFontFamily *family;
|
||||
IDWriteFactory *factory;
|
||||
IDWriteFontList *fontlist, *fontlist2;
|
||||
IDWriteFontList1 *fontlist1;
|
||||
HRESULT hr;
|
||||
|
||||
factory = create_factory();
|
||||
|
||||
hr = IDWriteFactory_GetSystemFontCollection(factory, &collection, FALSE);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontCollection_GetFontFamily(collection, 0, &family);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
hr = IDWriteFontFamily_GetMatchingFonts(family, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL, &fontlist2);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(fontlist != fontlist2, "got %p, %p\n", fontlist, fontlist2);
|
||||
IDWriteFontList_Release(fontlist2);
|
||||
|
||||
hr = IDWriteFontList_QueryInterface(fontlist, &IID_IDWriteFontList1, (void**)&fontlist1);
|
||||
if (hr == S_OK) {
|
||||
IDWriteFont3 *font;
|
||||
|
||||
font = (void*)0xdeadbeef;
|
||||
hr = IDWriteFontList1_GetFont(fontlist1, ~0u, &font);
|
||||
todo_wine {
|
||||
ok(hr == E_FAIL, "got 0x%08x\n", hr);
|
||||
ok(font == NULL, "got %p\n", font);
|
||||
}
|
||||
IDWriteFontList1_Release(fontlist1);
|
||||
}
|
||||
else
|
||||
win_skip("IDWriteFontList1 is not supported.\n");
|
||||
|
||||
IDWriteFontList_Release(fontlist);
|
||||
IDWriteFontFamily_Release(family);
|
||||
|
||||
IDWriteFontCollection_Release(collection);
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
||||
|
@ -5378,6 +5452,7 @@ START_TEST(font)
|
|||
test_GetUnicodeRanges();
|
||||
test_GetFontFromFontFace();
|
||||
test_GetFirstMatchingFont();
|
||||
test_GetMatchingFonts();
|
||||
test_GetInformationalStrings();
|
||||
test_GetGdiInterop();
|
||||
test_CreateFontFaceFromHdc();
|
||||
|
|
Loading…
Reference in New Issue