[PATCH 2/2] dwrite: Fix font fallback

Lucian Poston lucian.poston at gmail.com
Wed Nov 22 13:51:53 CST 2017


https://bugs.winehq.org/show_bug.cgi?id=44052

Signed-off-by: Lucian Poston <lucian.poston at gmail.com>
---
 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 bb08017611..4a6d40f1b6 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 eda90ec784..6de29129f0 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 744ae18445..9fb7f44c5e 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -2966,7 +2966,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);
-- 
2.13.6




More information about the wine-devel mailing list