From 897c1d03fac13f6d0d7f32f85951d09d3bb3a42b Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 19 Apr 2016 09:39:27 +0300 Subject: [PATCH] dwrite: Fix IDWriteFactory3 methods order. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/main.c | 24 ++++++++++---------- dlls/dwrite/tests/font.c | 49 ++++++++++++++++++++++++++++++++++++++++ include/dwrite_3.idl | 12 ++++++---- 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index bf0c41dc2fb..de60147d683 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -1261,16 +1261,6 @@ static HRESULT WINAPI dwritefactory3_CreateCustomRenderingParams(IDWriteFactory3 gridfit_mode, params); } -static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory3 *iface, WCHAR const *path, FILETIME const *writetime, - UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference) -{ - struct dwritefactory *This = impl_from_IDWriteFactory3(iface); - - FIXME("(%p)->(%s %p %u %x, %p): stub\n", This, debugstr_w(path), writetime, index, simulations, reference); - - return E_NOTIMPL; -} - static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory3 *iface, IDWriteFontFile *file, UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference) { @@ -1281,6 +1271,16 @@ static HRESULT WINAPI dwritefactory3_CreateFontFaceReference_(IDWriteFactory3 *i return E_NOTIMPL; } +static HRESULT WINAPI dwritefactory3_CreateFontFaceReference(IDWriteFactory3 *iface, WCHAR const *path, FILETIME const *writetime, + UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference) +{ + struct dwritefactory *This = impl_from_IDWriteFactory3(iface); + + FIXME("(%p)->(%s %p %u %x, %p): stub\n", This, debugstr_w(path), writetime, index, simulations, reference); + + return E_NOTIMPL; +} + static HRESULT WINAPI dwritefactory3_GetSystemFontSet(IDWriteFactory3 *iface, IDWriteFontSet **fontset) { struct dwritefactory *This = impl_from_IDWriteFactory3(iface); @@ -1362,8 +1362,8 @@ static const struct IDWriteFactory3Vtbl dwritefactoryvtbl = { dwritefactory2_CreateGlyphRunAnalysis, dwritefactory3_CreateGlyphRunAnalysis, dwritefactory3_CreateCustomRenderingParams, - dwritefactory3_CreateFontFaceReference, dwritefactory3_CreateFontFaceReference_, + dwritefactory3_CreateFontFaceReference, dwritefactory3_GetSystemFontSet, dwritefactory3_CreateFontSetBuilder, dwritefactory3_CreateFontCollectionFromFontSet, @@ -1419,8 +1419,8 @@ static const struct IDWriteFactory3Vtbl shareddwritefactoryvtbl = { dwritefactory2_CreateGlyphRunAnalysis, dwritefactory3_CreateGlyphRunAnalysis, dwritefactory3_CreateCustomRenderingParams, - dwritefactory3_CreateFontFaceReference, dwritefactory3_CreateFontFaceReference_, + dwritefactory3_CreateFontFaceReference, dwritefactory3_GetSystemFontSet, dwritefactory3_CreateFontSetBuilder, dwritefactory3_CreateFontCollectionFromFontSet, diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 515ece45853..3c1f332d557 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -5792,6 +5792,54 @@ static void test_HasCharacter(void) IDWriteFactory_Release(factory); } +static void test_CreateFontFaceReference(void) +{ + static const WCHAR dummyW[] = {'d','u','m','m','y',0}; + IDWriteFontFaceReference *ref; + IDWriteFactory3 *factory3; + IDWriteFactory *factory; + UINT32 index; + WCHAR *path; + HRESULT hr; + + factory = create_factory(); + + hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3); + IDWriteFactory_Release(factory); + if (FAILED(hr)) { + win_skip("CreateFontFaceReference() is not supported.\n"); + return; + } + + path = create_testfontfile(test_fontfile); + + hr = IDWriteFactory3_CreateFontFaceReference(factory3, NULL, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref); +todo_wine + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + /* test file is not a collection, but reference could still be created */ + hr = IDWriteFactory3_CreateFontFaceReference(factory3, path, NULL, 1, DWRITE_FONT_SIMULATIONS_NONE, &ref); +todo_wine + ok(hr == S_OK, "got 0x%08x\n", hr); +if (hr == S_OK) { + index = IDWriteFontFaceReference_GetFontFaceIndex(ref); + ok(index == 1, "got %u\n", index); +} + /* path however has to be valid */ + hr = IDWriteFactory3_CreateFontFaceReference(factory3, dummyW, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref); +todo_wine + ok(hr == DWRITE_E_FILENOTFOUND, "got 0x%08x\n", hr); + + hr = IDWriteFactory3_CreateFontFaceReference(factory3, path, NULL, 0, DWRITE_FONT_SIMULATIONS_NONE, &ref); +todo_wine + ok(hr == S_OK, "got 0x%08x\n", hr); +if (hr == S_OK) + IDWriteFontFaceReference_Release(ref); + + IDWriteFactory3_Release(factory3); + DELETE_FONTFILE(path); +} + START_TEST(font) { IDWriteFactory *factory; @@ -5846,6 +5894,7 @@ START_TEST(font) test_GetPaletteEntries(); test_TranslateColorGlyphRun(); test_HasCharacter(); + test_CreateFontFaceReference(); IDWriteFactory_Release(factory); } diff --git a/include/dwrite_3.idl b/include/dwrite_3.idl index b69f29a162c..bf1680021c6 100644 --- a/include/dwrite_3.idl +++ b/include/dwrite_3.idl @@ -282,15 +282,17 @@ interface IDWriteFactory3 : IDWriteFactory2 DWRITE_GRID_FIT_MODE gridfit_mode, IDWriteRenderingParams3 **params); - HRESULT CreateFontFaceReference( - WCHAR const *path, - FILETIME const *writetime, + /* CreateFontFaceReference methods are listed in reversed order to make + resulting vtable order compatible. */ + HRESULT CreateFontFaceReference_( + IDWriteFontFile *file, UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference); - HRESULT CreateFontFaceReference_( - IDWriteFontFile *file, + HRESULT CreateFontFaceReference( + WCHAR const *path, + FILETIME const *writetime, UINT32 index, DWRITE_FONT_SIMULATIONS simulations, IDWriteFontFaceReference **reference);