mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
333 lines
14 KiB
Diff
333 lines
14 KiB
Diff
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
|
|
|