From c7b329f9f17e18691cc62530820e1e9cfcda9123 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 4 May 2018 09:32:17 +1000 Subject: [PATCH] Added dwrite-FontFallback patch --- ...-test-font-collection-fallback-logic.patch | 79 +++++++++++++++++ .../0002-dwrite-Fix-font-fallback.patch | 88 +++++++++++++++++++ patches/dwrite-FontFallback/definition | 1 + patches/patchinstall.sh | 21 +++++ 4 files changed, 189 insertions(+) create mode 100644 patches/dwrite-FontFallback/0001-dwrite-test-font-collection-fallback-logic.patch create mode 100644 patches/dwrite-FontFallback/0002-dwrite-Fix-font-fallback.patch create mode 100644 patches/dwrite-FontFallback/definition diff --git a/patches/dwrite-FontFallback/0001-dwrite-test-font-collection-fallback-logic.patch b/patches/dwrite-FontFallback/0001-dwrite-test-font-collection-fallback-logic.patch new file mode 100644 index 00000000..a1af59ed --- /dev/null +++ b/patches/dwrite-FontFallback/0001-dwrite-test-font-collection-fallback-logic.patch @@ -0,0 +1,79 @@ +From cd1fcc1f8bc4b196304930254dc87ce34f6e9558 Mon Sep 17 00:00:00 2001 +From: Lucian Poston +Date: Mon, 20 Nov 2017 20:50:19 -0800 +Subject: [PATCH 1/2] dwrite: test font collection fallback logic + +https://bugs.winehq.org/show_bug.cgi?id=44052 + +Signed-off-by: Lucian Poston +--- + dlls/dwrite/tests/font.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c +index c226dba..ae386e6 100644 +--- a/dlls/dwrite/tests/font.c ++++ b/dlls/dwrite/tests/font.c +@@ -2926,6 +2926,51 @@ todo_wine + ok(ref == 0, "factory not released, %u\n", ref); + } + ++static void test_CustomFontCollection_fallback(void) ++{ ++ static const WCHAR strW[] = {'a','b','c','d',0}; ++ static const WCHAR enusW[] = {'e','n','-','u','s',0}; ++ IDWriteFontCollectionLoader *loader; ++ IDWriteTextFormat *format; ++ IDWriteTextLayout *layout; ++ IDWriteFactory *factory; ++ LONG font_coll_key = 1; ++ IDWriteFontCollection *font_collection; ++ DWRITE_TEXT_METRICS metrics; ++ HRESULT hr; ++ ++ factory = create_factory(); ++ loader = create_collection_loader(); ++ hr = IDWriteFactory_RegisterFontCollectionLoader(factory, loader); ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ hr = IDWriteFactory_CreateCustomFontCollection(factory, loader, ++ &font_coll_key, sizeof(font_coll_key), &font_collection); ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, font_collection, ++ DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, ++ DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, ++ 1000.0, 1000.0, &layout); ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ hr = IDWriteTextLayout_GetMetrics(layout, &metrics); ++ todo_wine ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader); ++ ok(hr == S_OK, "got 0x%08x\n", hr); ++ ++ IDWriteFontCollectionLoader_Release(loader); ++ IDWriteFontCollection_Release(font_collection); ++ IDWriteTextFormat_Release(format); ++ IDWriteTextLayout_Release(layout); ++ IDWriteFactory_Release(factory); ++} ++ + static HRESULT WINAPI fontfileloader_QueryInterface(IDWriteFontFileLoader *iface, REFIID riid, void **obj) + { + if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDWriteFontFileLoader)) +@@ -8459,6 +8504,7 @@ START_TEST(font) + test_system_fontcollection(); + test_ConvertFontFaceToLOGFONT(); + test_CustomFontCollection(); ++ test_CustomFontCollection_fallback(); + test_CreateCustomFontFileReference(); + test_CreateFontFileReference(); + test_shared_isolated(); +-- +1.9.1 + diff --git a/patches/dwrite-FontFallback/0002-dwrite-Fix-font-fallback.patch b/patches/dwrite-FontFallback/0002-dwrite-Fix-font-fallback.patch new file mode 100644 index 00000000..78b7e8d5 --- /dev/null +++ b/patches/dwrite-FontFallback/0002-dwrite-Fix-font-fallback.patch @@ -0,0 +1,88 @@ +From 3f165554d6ca5dc9a1606794d9b0824796714c03 Mon Sep 17 00:00:00 2001 +From: Lucian Poston +Date: Fri, 17 Nov 2017 17:28:34 -0800 +Subject: [PATCH 2/2] dwrite: Fix font fallback + +https://bugs.winehq.org/show_bug.cgi?id=44052 + +Signed-off-by: Lucian Poston +--- + dlls/dwrite/analyzer.c | 15 +++++++++++---- + dlls/dwrite/layout.c | 15 +++++++++++---- + dlls/dwrite/tests/font.c | 1 - + 3 files changed, 22 insertions(+), 9 deletions(-) + +diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c +index 8d553c6..1659b56 100644 +--- a/dlls/dwrite/analyzer.c ++++ b/dlls/dwrite/analyzer.c +@@ -2139,15 +2139,22 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback *iface, IDW + if (length == 0) + return S_OK; + +- if (!basecollection) +- basecollection = (IDWriteFontCollection*)fallback->systemcollection; +- + hr = get_text_source_ptr(source, position, length, &text, &buff); + if (FAILED(hr)) + goto done; + + if (basefamily && *basefamily) { +- hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font); ++ if (basecollection) ++ { ++ hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font); ++ } ++ ++ if (!basecollection || FAILED(hr)) ++ { ++ hr = create_matching_font((IDWriteFontCollection*)fallback->systemcollection, ++ basefamily, weight, style, stretch, ret_font); ++ } ++ + if (FAILED(hr)) + goto done; + +diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c +index 104b039..fefe14c 100644 +--- a/dlls/dwrite/layout.c ++++ b/dlls/dwrite/layout.c +@@ -830,12 +830,19 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout) + range = get_layout_range_by_pos(layout, run->descr.textPosition); + + if (run->sa.shapes == DWRITE_SCRIPT_SHAPES_NO_VISUAL) { +- IDWriteFontCollection *collection; ++ if (range->collection) { ++ hr = create_matching_font(range->collection, range->fontfamily, ++ range->weight, range->style, range->stretch, &font); ++ } + +- collection = range->collection ? range->collection : sys_collection; ++ if (range->collection == NULL || FAILED(hr)) ++ { ++ hr = create_matching_font(sys_collection, range->fontfamily, ++ range->weight, range->style, range->stretch, &font); ++ } + +- if (FAILED(hr = create_matching_font(collection, range->fontfamily, range->weight, range->style, +- range->stretch, &font))) { ++ if (FAILED(hr)) ++ { + WARN("%s: failed to create matching font for non visual run, family %s, collection %p\n", + debugstr_rundescr(&run->descr), debugstr_w(range->fontfamily), range->collection); + break; +diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c +index ae386e6..cf0856f 100644 +--- a/dlls/dwrite/tests/font.c ++++ b/dlls/dwrite/tests/font.c +@@ -2958,7 +2958,6 @@ static void test_CustomFontCollection_fallback(void) + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteTextLayout_GetMetrics(layout, &metrics); +- todo_wine + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteFactory_UnregisterFontCollectionLoader(factory, loader); +-- +1.9.1 + diff --git a/patches/dwrite-FontFallback/definition b/patches/dwrite-FontFallback/definition new file mode 100644 index 00000000..7d93ede0 --- /dev/null +++ b/patches/dwrite-FontFallback/definition @@ -0,0 +1 @@ +Fixes: [44052] - Support for font fallback. diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index f490451f..1b73c840 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -145,6 +145,7 @@ patch_enable_all () enable_dsound_EAX="$1" enable_dsound_Fast_Mixer="$1" enable_dsound_Revert_Cleanup="$1" + enable_dwrite_FontFallback="$1" enable_dxdiagn_Display_Information="$1" enable_dxdiagn_Enumerate_DirectSound="$1" enable_dxdiagn_GetChildContainer_Leaf_Nodes="$1" @@ -624,6 +625,9 @@ patch_enable () dsound-Revert_Cleanup) enable_dsound_Revert_Cleanup="$2" ;; + dwrite-FontFallback) + enable_dwrite_FontFallback="$2" + ;; dxdiagn-Display_Information) enable_dxdiagn_Display_Information="$2" ;; @@ -3823,6 +3827,23 @@ if test "$enable_dsound_EAX" -eq 1; then ) >> "$patchlist" fi +# Patchset dwrite-FontFallback +# | +# | This patchset fixes the following Wine bugs: +# | * [#44052] - Support for font fallback. +# | +# | Modified files: +# | * dlls/dwrite/analyzer.c, dlls/dwrite/layout.c, dlls/dwrite/tests/font.c +# | +if test "$enable_dwrite_FontFallback" -eq 1; then + patch_apply dwrite-FontFallback/0001-dwrite-test-font-collection-fallback-logic.patch + patch_apply dwrite-FontFallback/0002-dwrite-Fix-font-fallback.patch + ( + printf '%s\n' '+ { "Lucian Poston", "dwrite: Test font collection fallback logic.", 1 },'; + printf '%s\n' '+ { "Lucian Poston", "dwrite: Fix font fallback.", 1 },'; + ) >> "$patchlist" +fi + # Patchset dxdiagn-Display_Information # | # | This patchset fixes the following Wine bugs: