mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
dwrite-FontFallback: Drop some patches.
These are superseded and/or no longer useful upstream, per private correspondence with Nikolay.
This commit is contained in:
parent
6d46b1e13f
commit
2ee26de43f
@ -1,69 +0,0 @@
|
||||
From b1690a5bc6ea4cf670f3117f8caf9e229cd1f47d Mon Sep 17 00:00:00 2001
|
||||
From: Lucian Poston <lucianposton@pm.me>
|
||||
Date: Sun, 20 May 2018 21:40:39 -0700
|
||||
Subject: [PATCH] dwrite: Test IDWriteTextFormat with nonexistent font
|
||||
|
||||
Signed-off-by: Lucian Poston <lucianposton@pm.me>
|
||||
---
|
||||
dlls/dwrite/tests/layout.c | 45 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 45 insertions(+)
|
||||
|
||||
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
|
||||
index d19f91311db..d89ccc9d995 100644
|
||||
--- a/dlls/dwrite/tests/layout.c
|
||||
+++ b/dlls/dwrite/tests/layout.c
|
||||
@@ -3290,6 +3290,51 @@ todo_wine
|
||||
ok(metrics.lineCount == 1, "Unexpected line count %u.\n", metrics.lineCount);
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
+ IDWriteTextFormat_Release(format);
|
||||
+
|
||||
+ /* nonexistent font */
|
||||
+ hr = IDWriteFactory_CreateTextFormat(factory, L"Blah!", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
|
||||
+ DWRITE_FONT_STRETCH_NORMAL, 10.0, L"en-us", &format);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 500.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+
|
||||
+ count = 0;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+todo_wine
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+todo_wine
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ 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 == 500.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);
|
||||
+
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
IDWriteTextFormat_Release(format);
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
--
|
||||
2.17.1
|
||||
|
@ -1,332 +0,0 @@
|
||||
From 79b9dda91ac0e33add2252f9ad5c10ba752ddabb Mon Sep 17 00:00:00 2001
|
||||
From: Lucian Poston <lucianposton@pm.me>
|
||||
Date: Wed, 23 May 2018 00:01:42 -0700
|
||||
Subject: [PATCH] dwrite: Test GetMetrics with custom fontcollection
|
||||
|
||||
Signed-off-by: Lucian Poston <lucianposton@pm.me>
|
||||
---
|
||||
dlls/dwrite/tests/layout.c | 280 ++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 279 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
|
||||
index 9a450495146..9f1051b4905 100644
|
||||
--- a/dlls/dwrite/tests/layout.c
|
||||
+++ b/dlls/dwrite/tests/layout.c
|
||||
@@ -3363,7 +3363,7 @@ todo_wine
|
||||
DWRITE_FONT_STRETCH_NORMAL, 10.0, L"en-us", &format);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
- hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 500.0, 1000.0, &layout);
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, L"A", 4, format, 500.0, 1000.0, &layout);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
|
||||
count = 0;
|
||||
@@ -4546,6 +4546,7 @@ static void test_SetWordWrapping(void)
|
||||
/* Collection dedicated to fallback testing */
|
||||
|
||||
static const WCHAR g_blahfontW[] = {'B','l','a','h',0};
|
||||
+static const WCHAR g_fontNotInCollectionW[] = {'n','o','t','B','l','a','h',0};
|
||||
static HRESULT WINAPI fontcollection_QI(IDWriteFontCollection *iface, REFIID riid, void **obj)
|
||||
{
|
||||
if (IsEqualIID(riid, &IID_IDWriteFontCollection) || IsEqualIID(riid, &IID_IUnknown)) {
|
||||
@@ -4607,6 +4608,9 @@ static HRESULT WINAPI fontcollection_FindFamilyName(IDWriteFontCollection *iface
|
||||
*index = 123456;
|
||||
*exists = TRUE;
|
||||
return S_OK;
|
||||
+ } else if (!lstrcmpW(name, g_fontNotInCollectionW)) {
|
||||
+ *exists = FALSE;
|
||||
+ return S_OK;
|
||||
}
|
||||
ok(0, "unexpected call, name %s\n", wine_dbgstr_w(name));
|
||||
return E_NOTIMPL;
|
||||
@@ -6405,6 +6409,279 @@ static void test_layout_range_length(void)
|
||||
IDWriteFactory_Release(factory);
|
||||
}
|
||||
|
||||
+static void test_GetMetrics_with_custom_fontcollection(void)
|
||||
+{
|
||||
+ static const WCHAR emptystringW[] = {0};
|
||||
+ static const WCHAR mappedW[] = {'a','b','c','d',0};
|
||||
+ static const WCHAR notmappedW[] = {'a',0xffff,'b',0}; // u+ffff = not a unicode character
|
||||
+ DWRITE_CLUSTER_METRICS clusters[4];
|
||||
+ DWRITE_TEXT_METRICS metrics;
|
||||
+ IDWriteTextFormat *format;
|
||||
+ IDWriteTextLayout *layout;
|
||||
+ IDWriteFactory *factory;
|
||||
+ UINT32 count, i;
|
||||
+ FLOAT width;
|
||||
+ HRESULT hr;
|
||||
+
|
||||
+ factory = create_factory();
|
||||
+
|
||||
+ /* font is in font collection */
|
||||
+ hr = IDWriteFactory_CreateTextFormat(factory, g_blahfontW, &fallbackcollection,
|
||||
+ DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
|
||||
+ DWRITE_FONT_STRETCH_NORMAL, 10.0, L"en-us", &format);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+
|
||||
+ /* text is mapped by fontfallback */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, mappedW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ width += clusters[i].width;
|
||||
+ memset(&metrics, 0xcc, sizeof(metrics));
|
||||
+ hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
|
||||
+ ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
|
||||
+ ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width);
|
||||
+ ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n",
|
||||
+ metrics.widthIncludingTrailingWhitespace, width);
|
||||
+ ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
|
||||
+ ok(metrics.layoutWidth == 1000.0, "got %.2f\n", metrics.layoutWidth);
|
||||
+ ok(metrics.layoutHeight == 1000.0, "got %.2f\n", metrics.layoutHeight);
|
||||
+ ok(metrics.maxBidiReorderingDepth == 1, "got %u\n", metrics.maxBidiReorderingDepth);
|
||||
+ ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* text is not mapped by fontfallback */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, notmappedW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ width += clusters[i].width;
|
||||
+ memset(&metrics, 0xcc, sizeof(metrics));
|
||||
+ hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
|
||||
+ ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
|
||||
+ ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width);
|
||||
+ ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n",
|
||||
+ metrics.widthIncludingTrailingWhitespace, width);
|
||||
+ ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
|
||||
+ ok(metrics.layoutWidth == 1000.0, "got %.2f\n", metrics.layoutWidth);
|
||||
+ ok(metrics.layoutHeight == 1000.0, "got %.2f\n", metrics.layoutHeight);
|
||||
+ ok(metrics.maxBidiReorderingDepth == 1, "got %u\n", metrics.maxBidiReorderingDepth);
|
||||
+ ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* empty string */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, emptystringW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ width += clusters[i].width;
|
||||
+ memset(&metrics, 0xcc, sizeof(metrics));
|
||||
+ hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
|
||||
+ ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
|
||||
+ ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width);
|
||||
+ ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n",
|
||||
+ metrics.widthIncludingTrailingWhitespace, width);
|
||||
+ ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
|
||||
+ ok(metrics.layoutWidth == 1000.0, "got %.2f\n", metrics.layoutWidth);
|
||||
+ ok(metrics.layoutHeight == 1000.0, "got %.2f\n", metrics.layoutHeight);
|
||||
+ ok(metrics.maxBidiReorderingDepth == 1, "got %u\n", metrics.maxBidiReorderingDepth);
|
||||
+ ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* zero-length empty string */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, emptystringW, 0, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(count == 0, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ width += clusters[i].width;
|
||||
+ memset(&metrics, 0xcc, sizeof(metrics));
|
||||
+ hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
|
||||
+ ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
|
||||
+ ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width);
|
||||
+ ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n",
|
||||
+ metrics.widthIncludingTrailingWhitespace, width);
|
||||
+ ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
|
||||
+ ok(metrics.layoutWidth == 1000.0, "got %.2f\n", metrics.layoutWidth);
|
||||
+ ok(metrics.layoutHeight == 1000.0, "got %.2f\n", metrics.layoutHeight);
|
||||
+ ok(metrics.maxBidiReorderingDepth == 1, "got %u\n", metrics.maxBidiReorderingDepth);
|
||||
+ ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ IDWriteTextFormat_Release(format);
|
||||
+
|
||||
+ /* font not in font collection */
|
||||
+ hr = IDWriteFactory_CreateTextFormat(factory, g_fontNotInCollectionW, &fallbackcollection,
|
||||
+ DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
|
||||
+ DWRITE_FONT_STRETCH_NORMAL, 10.0, L"en-us", &format);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+
|
||||
+ /* text is mapped by fontfallback */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, mappedW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ todo_wine
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ todo_wine
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ 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);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* text is not mapped by fontfallback */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, notmappedW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ todo_wine
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ todo_wine
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ 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);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* empty string */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, emptystringW, 4, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ todo_wine
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ todo_wine
|
||||
+ ok(count == 4, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ 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);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ /* zero-length empty string */
|
||||
+ hr = IDWriteFactory_CreateTextLayout(factory, emptystringW, 0, format, 1000.0, 1000.0, &layout);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ count = 9999;
|
||||
+ hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
+ ok(count == 0, "got %u\n", count);
|
||||
+ for (i = 0, width = 0.0; i < count; i++)
|
||||
+ 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);
|
||||
+ IDWriteTextLayout_Release(layout);
|
||||
+
|
||||
+ IDWriteTextFormat_Release(format);
|
||||
+
|
||||
+ IDWriteFactory_Release(factory);
|
||||
+}
|
||||
+
|
||||
START_TEST(layout)
|
||||
{
|
||||
IDWriteFactory *factory;
|
||||
@@ -6438,6 +6715,7 @@ START_TEST(layout)
|
||||
test_SetFontStretch();
|
||||
test_SetStrikethrough();
|
||||
test_GetMetrics();
|
||||
+ test_GetMetrics_with_custom_fontcollection();
|
||||
test_SetFlowDirection();
|
||||
test_SetDrawingEffect();
|
||||
test_GetLineMetrics();
|
||||
--
|
||||
2.20.1
|
||||
|
@ -1,311 +0,0 @@
|
||||
From bf4cc6cfca946ff719763bb7be25fe268577f0d3 Mon Sep 17 00:00:00 2001
|
||||
From: Lucian Poston <lucianposton@pm.me>
|
||||
Date: Mon, 21 May 2018 18:13:00 -0700
|
||||
Subject: [PATCH] dwrite: Use font fallback when mapping characters
|
||||
|
||||
Signed-off-by: Lucian Poston <lucianposton@pm.me>
|
||||
---
|
||||
dlls/dwrite/analyzer.c | 77 +++++++++++++++++++++++++++++---------
|
||||
dlls/dwrite/layout.c | 6 +++
|
||||
dlls/dwrite/tests/layout.c | 54 ++++----------------------
|
||||
3 files changed, 73 insertions(+), 64 deletions(-)
|
||||
|
||||
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c
|
||||
index 7ffcfa8070c..aab309c2a8c 100644
|
||||
--- a/dlls/dwrite/analyzer.c
|
||||
+++ b/dlls/dwrite/analyzer.c
|
||||
@@ -2094,6 +2094,7 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
|
||||
IDWriteFont **mapped_font)
|
||||
{
|
||||
const struct fallback_mapping *mapping;
|
||||
+ IDWriteFontCollection *collection;
|
||||
HRESULT hr;
|
||||
UINT32 i;
|
||||
|
||||
@@ -2105,9 +2106,15 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
+ if (mapping->collection) {
|
||||
+ collection = mapping->collection;
|
||||
+ } else {
|
||||
+ collection = (IDWriteFontCollection *)fallback->systemcollection;
|
||||
+ }
|
||||
+
|
||||
/* Now let's see what fallback can handle. Pick first font that could be created. */
|
||||
for (i = 0; i < mapping->families_count; i++) {
|
||||
- hr = create_matching_font((IDWriteFontCollection *)fallback->systemcollection, mapping->families[i],
|
||||
+ hr = create_matching_font(collection, mapping->families[i],
|
||||
weight, style, stretch, mapped_font);
|
||||
if (hr == S_OK) {
|
||||
TRACE("Created fallback font using family %s.\n", debugstr_w(mapping->families[i]));
|
||||
@@ -2164,32 +2171,66 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback1 *iface, ID
|
||||
|
||||
if (basefamily && *basefamily) {
|
||||
hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font);
|
||||
- if (FAILED(hr))
|
||||
- goto done;
|
||||
-
|
||||
- hr = fallback_map_characters(*ret_font, text, length, mapped_length);
|
||||
- if (FAILED(hr))
|
||||
- goto done;
|
||||
+ if (SUCCEEDED(hr)) {
|
||||
+ hr = fallback_map_characters(*ret_font, text, length, mapped_length);
|
||||
+ if (FAILED(hr)) {
|
||||
+ IDWriteFont_Release(*ret_font);
|
||||
+ *ret_font = NULL;
|
||||
+ WARN("Mapping with requested family %s failed, hr %#x.\n", debugstr_w(basefamily), hr);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
if (!*mapped_length) {
|
||||
- IDWriteFont *mapped_font;
|
||||
+ if (*ret_font) {
|
||||
+ IDWriteFont_Release(*ret_font);
|
||||
+ *ret_font = NULL;
|
||||
+ }
|
||||
|
||||
- hr = fallback_get_fallback_font(fallback, text, length, weight, style, stretch, mapped_length, &mapped_font);
|
||||
+ hr = fallback_get_fallback_font(fallback, text, length, weight, style, stretch, mapped_length, ret_font);
|
||||
if (FAILED(hr)) {
|
||||
- /* fallback wasn't found, keep base font if any, so we can get at least some visual output */
|
||||
- if (*ret_font) {
|
||||
- *mapped_length = length;
|
||||
- hr = S_OK;
|
||||
- }
|
||||
+ WARN("Mapping with fallback families failed, hr %#x.\n", hr);
|
||||
}
|
||||
- else {
|
||||
- if (*ret_font)
|
||||
- IDWriteFont_Release(*ret_font);
|
||||
- *ret_font = mapped_font;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * This is a rough hack. We search the system font collection because
|
||||
+ * the system fontfallback, which would have been searched above, is not
|
||||
+ * fully implemented as it isn't populated with any system fonts. Once
|
||||
+ * implemented, the block below can be removed.
|
||||
+ * */
|
||||
+ if (!*mapped_length) {
|
||||
+ IDWriteFontFamily *family;
|
||||
+ IDWriteFont *font;
|
||||
+ UINT32 i, count = IDWriteFontCollection_GetFontFamilyCount((IDWriteFontCollection *)fallback->systemcollection);
|
||||
+ for (i = 0; i < count; i++) {
|
||||
+ hr = IDWriteFontCollection_GetFontFamily((IDWriteFontCollection *)fallback->systemcollection, i, &family);
|
||||
+ if (FAILED(hr)) {
|
||||
+ ERR("Failed to get font family.\n");
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ hr = IDWriteFontFamily_GetFirstMatchingFont(family, weight, stretch, style, &font);
|
||||
+ IDWriteFontFamily_Release(family);
|
||||
+ if (FAILED(hr)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ hr = fallback_map_characters(font, text, length, mapped_length);
|
||||
+ if (SUCCEEDED(hr) && mapped_length > 0) {
|
||||
+ *ret_font = font;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ IDWriteFont_Release(font);
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!*mapped_length) {
|
||||
+ *mapped_length = length == 0 ? 0 : 1;
|
||||
+ hr = S_OK;
|
||||
+ }
|
||||
+
|
||||
done:
|
||||
free(buff);
|
||||
return hr;
|
||||
diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c
|
||||
index ba80c3f70e8..c7845f9b675 100644
|
||||
--- a/dlls/dwrite/layout.c
|
||||
+++ b/dlls/dwrite/layout.c
|
||||
@@ -725,6 +725,12 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
|
||||
goto fatal;
|
||||
}
|
||||
|
||||
+ if (!font) {
|
||||
+ hr = E_FAIL;
|
||||
+ WARN("Failed to create font face, hr %#x.\n", hr);
|
||||
+ goto fatal;
|
||||
+ }
|
||||
+
|
||||
hr = IDWriteFont_CreateFontFace(font, &run->run.fontFace);
|
||||
IDWriteFont_Release(font);
|
||||
if (FAILED(hr)) {
|
||||
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
|
||||
index 3efedd3df95..07687c76c60 100644
|
||||
--- a/dlls/dwrite/tests/layout.c
|
||||
+++ b/dlls/dwrite/tests/layout.c
|
||||
@@ -3366,35 +3366,23 @@ static void test_GetMetrics(void)
|
||||
|
||||
count = 0;
|
||||
hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
-todo_wine
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
-todo_wine
|
||||
ok(count == 4, "got %u\n", count);
|
||||
for (i = 0, width = 0.0; i < count; i++)
|
||||
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 == 500.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);
|
||||
|
||||
IDWriteTextLayout_Release(layout);
|
||||
@@ -4688,16 +4676,12 @@ static void test_MapCharacters(void)
|
||||
font = NULL;
|
||||
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 1, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
|
||||
-todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
ok(mappedlength == 1, "got %u\n", mappedlength);
|
||||
-}
|
||||
ok(scale == 1.0f, "got %f\n", scale);
|
||||
- todo_wine
|
||||
ok(font != NULL, "got %p\n", font);
|
||||
-if (font) {
|
||||
IDWriteFont_Release(font);
|
||||
-}
|
||||
+
|
||||
/* same Latin text, full length */
|
||||
g_source = L"abc";
|
||||
mappedlength = 0;
|
||||
@@ -4705,16 +4689,12 @@ if (font) {
|
||||
font = NULL;
|
||||
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
|
||||
-todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
ok(mappedlength == 3, "got %u\n", mappedlength);
|
||||
-}
|
||||
ok(scale == 1.0f, "got %f\n", scale);
|
||||
- todo_wine
|
||||
ok(font != NULL, "got %p\n", font);
|
||||
-if (font) {
|
||||
IDWriteFont_Release(font);
|
||||
-}
|
||||
+
|
||||
/* string 'a\x3058b' */
|
||||
g_source = str2W;
|
||||
mappedlength = 0;
|
||||
@@ -4722,32 +4702,24 @@ if (font) {
|
||||
font = NULL;
|
||||
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
|
||||
-todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
ok(mappedlength == 1, "got %u\n", mappedlength);
|
||||
-}
|
||||
ok(scale == 1.0f, "got %f\n", scale);
|
||||
- todo_wine
|
||||
ok(font != NULL, "got %p\n", font);
|
||||
-if (font) {
|
||||
IDWriteFont_Release(font);
|
||||
-}
|
||||
+
|
||||
g_source = str2W;
|
||||
mappedlength = 0;
|
||||
scale = 0.0f;
|
||||
font = NULL;
|
||||
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 2, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
|
||||
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
|
||||
-todo_wine {
|
||||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
ok(mappedlength == 1, "got %u\n", mappedlength);
|
||||
-}
|
||||
ok(scale == 1.0f, "got %f\n", scale);
|
||||
- todo_wine
|
||||
ok(font != NULL, "got %p\n", font);
|
||||
-if (font) {
|
||||
IDWriteFont_Release(font);
|
||||
-}
|
||||
+
|
||||
/* Try with explicit collection, Tahoma will be forced. */
|
||||
/* 1. Latin part */
|
||||
g_source = str2W;
|
||||
@@ -4770,7 +4742,10 @@ if (font) {
|
||||
IDWriteLocalizedStrings_Release(strings);
|
||||
IDWriteFont_Release(font);
|
||||
|
||||
- /* 2. Hiragana character, force Tahoma font does not support Japanese */
|
||||
+ /**
|
||||
+ * 2. Hiragana character. Tahoma is requested, but it doesn't support
|
||||
+ * Japanese. A NULL font is returned if there is no fallback for Japanese.
|
||||
+ */
|
||||
g_source = str2W;
|
||||
mappedlength = 0;
|
||||
scale = 0.0f;
|
||||
@@ -4780,7 +4755,6 @@ if (font) {
|
||||
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
|
||||
ok(mappedlength == 1, "got %u\n", mappedlength);
|
||||
ok(scale == 1.0f, "got %f\n", scale);
|
||||
- ok(font != NULL, "got %p\n", font);
|
||||
|
||||
exists = FALSE;
|
||||
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
|
||||
@@ -6667,34 +6641,22 @@ static void test_GetMetrics_with_custom_fontcollection(void)
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
count = 9999;
|
||||
hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
|
||||
- todo_wine
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
- todo_wine
|
||||
ok(count == 4, "got %u\n", count);
|
||||
for (i = 0, width = 0.0; i < count; i++)
|
||||
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);
|
||||
IDWriteTextLayout_Release(layout);
|
||||
|
||||
--
|
||||
2.35.1
|
||||
|
Loading…
Reference in New Issue
Block a user