Commit fa1fe44c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Implement SetFontFallback().

parent c2c30013
......@@ -235,6 +235,16 @@ static HRESULT get_fontfallback_from_format(const struct dwrite_textformat_data
return S_OK;
}
static HRESULT set_fontfallback_for_format(struct dwrite_textformat_data *format, IDWriteFontFallback *fallback)
{
if (format->fallback)
IDWriteFontFallback_Release(format->fallback);
format->fallback = fallback;
if (fallback)
IDWriteFontFallback_AddRef(fallback);
return S_OK;
}
static struct layout_run *alloc_layout_run(void)
{
struct layout_run *ret;
......@@ -1867,8 +1877,8 @@ static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextlayout2_GetOpticalAlignment(IDW
static HRESULT WINAPI dwritetextlayout2_SetFontFallback(IDWriteTextLayout2 *iface, IDWriteFontFallback *fallback)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p)->(%p): stub\n", This, fallback);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, fallback);
return set_fontfallback_for_format(&This->format, fallback);
}
static HRESULT WINAPI dwritetextlayout2_GetFontFallback(IDWriteTextLayout2 *iface, IDWriteFontFallback **fallback)
......@@ -2228,15 +2238,15 @@ static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_layout_GetOpticalAlignm
static HRESULT WINAPI dwritetextformat1_layout_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
FIXME("(%p)->(%p): stub\n", This, fallback);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, fallback);
return IDWriteTextLayout2_SetFontFallback(&This->IDWriteTextLayout2_iface, fallback);
}
static HRESULT WINAPI dwritetextformat1_layout_GetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback **fallback)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
TRACE("(%p)->(%p): stub\n", This, fallback);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, fallback);
return IDWriteTextLayout2_GetFontFallback(&This->IDWriteTextLayout2_iface, fallback);
}
static const IDWriteTextFormat1Vtbl dwritetextformat1_layout_vtbl = {
......@@ -3055,8 +3065,8 @@ static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_GetOpticalAlignment(IDW
static HRESULT WINAPI dwritetextformat1_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
FIXME("(%p)->(%p): stub\n", This, fallback);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, fallback);
return set_fontfallback_for_format(&This->format, fallback);
}
static HRESULT WINAPI dwritetextformat1_GetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback **fallback)
......
......@@ -1204,10 +1204,12 @@ static void test_SetVerticalGlyphOrientation(void)
static void test_fallback(void)
{
static const WCHAR strW[] = {'a','b','c','d',0};
IDWriteFontFallback *fallback;
IDWriteFontFallback *fallback, *fallback2;
IDWriteTextLayout2 *layout2;
IDWriteTextFormat1 *format1;
IDWriteTextFormat *format;
IDWriteTextLayout *layout;
IDWriteFactory2 *factory2;
IDWriteFactory *factory;
HRESULT hr;
......@@ -1238,6 +1240,43 @@ if (0) /* crashes on native */
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(fallback == NULL, "got %p\n", fallback);
hr = IDWriteTextLayout2_QueryInterface(layout2, &IID_IDWriteTextFormat1, (void**)&format1);
ok(hr == S_OK, "got 0x%08x\n", hr);
fallback = (void*)0xdeadbeef;
hr = IDWriteTextFormat1_GetFontFallback(format1, &fallback);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(fallback == NULL, "got %p\n", fallback);
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory2, (void**)&factory2);
ok(hr == S_OK, "got 0x%08x\n", hr);
fallback = NULL;
hr = IDWriteFactory2_GetSystemFontFallback(factory2, &fallback);
todo_wine
ok(hr == S_OK, "got 0x%08x\n", hr);
if (hr == S_OK) {
ok(fallback != NULL, "got %p\n", fallback);
hr = IDWriteTextFormat1_SetFontFallback(format1, fallback);
ok(hr == S_OK, "got 0x%08x\n", hr);
fallback2 = (void*)0xdeadbeef;
hr = IDWriteTextLayout2_GetFontFallback(layout2, &fallback2);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(fallback2 == fallback, "got %p\n", fallback2);
hr = IDWriteTextLayout2_SetFontFallback(layout2, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
fallback2 = (void*)0xdeadbeef;
hr = IDWriteTextFormat1_GetFontFallback(format1, &fallback2);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(fallback2 == NULL, "got %p\n", fallback2);
IDWriteFontFallback_Release(fallback);
}
IDWriteTextFormat1_Release(format1);
IDWriteTextLayout2_Release(layout2);
IDWriteFactory_Release(factory);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment