[PATCH 6/6] dwrite: Use MapCharacters for dummy line metrics

Lucian Poston lucianposton at pm.me
Wed May 23 13:09:00 CDT 2018


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

Signed-off-by: Lucian Poston <lucianposton at pm.me>
---
 dlls/dwrite/layout.c       | 29 +++++++++++++++++++++++++++++
 dlls/dwrite/tests/layout.c |  8 --------
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c
index 5d06bf9348..2213717f92 100644
--- a/dlls/dwrite/layout.c
+++ b/dlls/dwrite/layout.c
@@ -1808,8 +1808,11 @@ static HRESULT layout_set_dummy_line_metrics(struct dwrite_textlayout *layout, U
     DWRITE_FONT_METRICS fontmetrics;
     struct layout_range *range;
     IDWriteFontFace *fontface;
+    IDWriteFontFallback *fallback;
     IDWriteFont *font;
     HRESULT hr;
+    UINT32 mapped_length;
+    FLOAT scale;
 
     range = get_layout_range_by_pos(layout, pos);
     hr = create_matching_font(range->collection,
@@ -1818,8 +1821,34 @@ static HRESULT layout_set_dummy_line_metrics(struct dwrite_textlayout *layout, U
         range->style,
         range->stretch,
         &font);
+
+    if (FAILED(hr)) {
+        if (layout->format.fallback) {
+            fallback = layout->format.fallback;
+            IDWriteFontFallback_AddRef(fallback);
+        } else if (FAILED(hr = IDWriteFactory5_GetSystemFontFallback(layout->factory, &fallback))) {
+            WARN("Failed to get system fallback, hr %#x.\n", hr);
+            return hr;
+        }
+
+        hr = IDWriteFontFallback_MapCharacters(fallback,
+                (IDWriteTextAnalysisSource *)&layout->IDWriteTextAnalysisSource1_iface,
+                pos,
+                layout->len,
+                range->collection,
+                range->fontfamily,
+                range->weight,
+                range->style,
+                range->stretch,
+                &mapped_length,
+                &font,
+                &scale);
+        IDWriteFontFallback_Release(fallback);
+    }
     if (FAILED(hr))
         return hr;
+    if (font == NULL)
+        return S_OK;
     hr = IDWriteFont_CreateFontFace(font, &fontface);
     IDWriteFont_Release(font);
     if (FAILED(hr))
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
index 975b6ac7b3..e0748302ad 100644
--- a/dlls/dwrite/tests/layout.c
+++ b/dlls/dwrite/tests/layout.c
@@ -5769,24 +5769,16 @@ static void test_GetMetrics_with_custom_fontcollection(void)
         width += clusters[i].width;
     memset(&metrics, 0xcc, sizeof(metrics));
     hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
-    todo_wine
     ok(hr == S_OK, "got 0x%08x\n", hr);
-    todo_wine
     ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
-    todo_wine
     ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
-    todo_wine
     ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width);
-    todo_wine
     ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n",
         metrics.widthIncludingTrailingWhitespace, width);
     todo_wine
     ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
-    todo_wine
     ok(metrics.layoutWidth == 1000.0, "got %.2f\n", metrics.layoutWidth);
-    todo_wine
     ok(metrics.layoutHeight == 1000.0, "got %.2f\n", metrics.layoutHeight);
-    todo_wine
     ok(metrics.maxBidiReorderingDepth == 1, "got %u\n", metrics.maxBidiReorderingDepth);
     todo_wine
     ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
-- 
2.16.1





More information about the wine-devel mailing list