From: Lucian Poston lucianposton@pm.me
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index cc4079faa14..35d54ae41f0 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -3356,6 +3356,43 @@ 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, L"A", 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); + 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); +todo_wine + ok(metrics.height > 0.0, "got %.2f\n", metrics.height); + ok(metrics.layoutWidth == 500.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); +todo_wine + ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount); + + IDWriteTextLayout_Release(layout); + IDWriteTextFormat_Release(format); IDWriteFactory_Release(factory); }
From: Lucian Poston lucianposton@pm.me
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 263 +++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 35d54ae41f0..df2cdb36f1c 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4538,6 +4538,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)) { @@ -4599,6 +4600,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; @@ -6424,6 +6428,264 @@ static void test_layout_range_length(void) IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format); + + 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); + width = 0.0; + if (hr == S_OK) + for (i = 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); + width = 0.0; + if (hr == S_OK) + for (i = 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); + width = 0.0; + if (hr == S_OK) + for (i = 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); + width = 0.0; + if (hr == S_OK) + for (i = 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); + ok(count == 4, "got %u\n", count); +} + width = 0.0; + if (hr == S_OK) + for (i = 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); +todo_wine + 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); +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); + ok(count == 4, "got %u\n", count); +} + width = 0.0; + if (hr == S_OK) + for (i = 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); +todo_wine + 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); +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); + ok(count == 4, "got %u\n", count); +} + width = 0.0; + if (hr == S_OK) + for (i = 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); +todo_wine + 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); +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); + width = 0.0; + if (hr == S_OK) + for (i = 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); + 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); + IDWriteFactory_Release(factory); }
@@ -6460,6 +6722,7 @@ START_TEST(layout) test_SetFontStretch(); test_SetStrikethrough(); test_GetMetrics(); + test_GetMetrics_with_custom_fontcollection(); test_SetFlowDirection(); test_SetDrawingEffect(); test_GetLineMetrics();
On 3/4/21 1:23 PM, Giovanni Mascellani wrote:
From: Lucian Poston lucianposton@pm.me
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
dlls/dwrite/tests/layout.c | 263 +++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 35d54ae41f0..df2cdb36f1c 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4538,6 +4538,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)) { @@ -4599,6 +4600,9 @@ static HRESULT WINAPI fontcollection_FindFamilyName(IDWriteFontCollection *iface *index = 123456; *exists = TRUE; return S_OK;
- } else if (!lstrcmpW(name, g_fontNotInCollectionW)) {
*exists = FALSE;
} ok(0, "unexpected call, name %s\n", wine_dbgstr_w(name)); return E_NOTIMPL;return S_OK;
@@ -6424,6 +6428,264 @@ static void test_layout_range_length(void) IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format);
- IDWriteFactory_Release(factory);
+}
+static void test_GetMetrics_with_custom_fontcollection(void)
That's not how existing functions are structured.
+{
- 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
I don't see what's special about 0xffff.
- 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);
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
- ok(count == 4, "got %u\n", count);
+}
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
+todo_wine
- 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);
+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);
- ok(count == 4, "got %u\n", count);
+}
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
+todo_wine
- 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);
+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);
- ok(count == 4, "got %u\n", count);
+}
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
+todo_wine
- 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);
+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);
- width = 0.0;
- if (hr == S_OK)
for (i = 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);
- 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);
- IDWriteFactory_Release(factory);
}
@@ -6460,6 +6722,7 @@ START_TEST(layout) test_SetFontStretch(); test_SetStrikethrough(); test_GetMetrics();
- test_GetMetrics_with_custom_fontcollection(); test_SetFlowDirection(); test_SetDrawingEffect(); test_GetLineMetrics();
All of that does not look closely related to fallback. We already use format collection if specified. And again, CreateTextLayout() arguments are occasionally incorrect.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index df2cdb36f1c..11fb6e1541d 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4761,6 +4761,7 @@ if (font) { ok(scale == 1.0f, "got %f\n", scale); ok(font != NULL, "got %p\n", font);
+if (font) { exists = FALSE; hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists); ok(hr == S_OK && exists, "got 0x%08x, exists %d\n", hr, exists); @@ -4769,6 +4770,7 @@ if (font) { ok(!lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW)); IDWriteLocalizedStrings_Release(strings); IDWriteFont_Release(font); +}
/* 2. Hiragana character, force Tahoma font does not support Japanese */ g_source = str2W; @@ -4782,6 +4784,7 @@ if (font) { ok(scale == 1.0f, "got %f\n", scale); ok(font != NULL, "got %p\n", font);
+if (font) { exists = FALSE; hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists); ok(hr == S_OK && exists, "got 0x%08x, exists %d\n", hr, exists); @@ -4791,6 +4794,7 @@ todo_wine ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW)); IDWriteLocalizedStrings_Release(strings); IDWriteFont_Release(font); +}
IDWriteFontFallback_Release(fallback); IDWriteFactory2_Release(factory2);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 11fb6e1541d..993a742a7e1 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4796,6 +4796,43 @@ todo_wine IDWriteFont_Release(font); }
+ /* Explicit collection, but forcing a font that does not exist in it. */ + /* 1. Latin part */ + g_source = str2W; + mappedlength = 0; + scale = 0.0f; + font = NULL; + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); +todo_wine { + ok(hr == S_OK, "got 0x%08x\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); +} + + /* 2. Hiragana character */ + g_source = str2W; + mappedlength = 0; + scale = 0.0f; + font = NULL; + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 1, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); +todo_wine { + ok(hr == S_OK, "got 0x%08x\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); +} + IDWriteFontFallback_Release(fallback); IDWriteFactory2_Release(factory2); }
While this test happens to always be true on Windows, this is just a property of the fallback fonts installed on the system, not a property of the code. Since we cannot control the fonts installed on users' computers, it makes no sense to do this test.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 993a742a7e1..134a7ec7e02 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4740,12 +4740,6 @@ todo_wine { todo_wine ok(font != NULL, "got %p\n", font); if (font) { - /* font returned for Hiragana character, check if it supports Latin too */ - exists = FALSE; - hr = IDWriteFont_HasCharacter(font, 'b', &exists); - ok(hr == S_OK, "got 0x%08x\n", hr); - ok(exists, "got %d\n", exists); - IDWriteFont_Release(font); } /* Try with explicit collection, Tahoma will be forced. */
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/tests/layout.c | 53 +++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 6 deletions(-)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 134a7ec7e02..51290d167d9 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4628,7 +4628,7 @@ static IDWriteFontCollection fallbackcollection = { &fallbackcollectionvtbl };
static void test_MapCharacters(void) { - static const WCHAR str2W[] = {'a',0x3058,'b',0}; + static const WCHAR str2W[] = {'a',0x3058,0x3059,'b',0}; IDWriteLocalizedStrings *strings; IDWriteFontFallback *fallback; IDWriteFactory2 *factory2; @@ -4709,12 +4709,12 @@ todo_wine if (font) { IDWriteFont_Release(font); } - /* string 'a\x3058b' */ + /* string 'a\x3058\x3059b' */ g_source = str2W; mappedlength = 0; scale = 0.0f; font = NULL; - hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL, + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 4, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); @@ -4734,7 +4734,7 @@ if (font) { DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); - ok(mappedlength == 1, "got %u\n", mappedlength); + ok(mappedlength == 2, "got %u\n", mappedlength); } ok(scale == 1.0f, "got %f\n", scale); todo_wine @@ -4748,7 +4748,7 @@ if (font) { mappedlength = 0; scale = 0.0f; font = NULL; - hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 4, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); ok(hr == S_OK, "got 0x%08x\n", hr); ok(mappedlength == 1, "got %u\n", mappedlength); @@ -4778,6 +4778,31 @@ if (font) { ok(scale == 1.0f, "got %f\n", scale); ok(font != NULL, "got %p\n", font);
+if (font) { + exists = FALSE; + hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists); + ok(hr == S_OK && exists, "got 0x%08x, exists %d\n", hr, exists); + hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW)); + ok(hr == S_OK, "got 0x%08x\n", hr); +todo_wine + ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW)); + IDWriteLocalizedStrings_Release(strings); + IDWriteFont_Release(font); +} + + /* 3. Hiragana character and Latin character, force Tahoma font does not support Japanese */ + g_source = str2W; + mappedlength = 0; + scale = 0.0f; + font = NULL; + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 3, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); + ok(hr == S_OK, "got 0x%08x\n", hr); +todo_wine + ok(mappedlength == 2, "got %u\n", mappedlength); + ok(scale == 1.0f, "got %f\n", scale); + ok(font != NULL, "got %p\n", font); + if (font) { exists = FALSE; hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists); @@ -4796,7 +4821,7 @@ todo_wine mappedlength = 0; scale = 0.0f; font = NULL; - hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 4, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); @@ -4827,6 +4852,22 @@ if (font) { IDWriteFont_Release(font); }
+ /* 3. Hiragana character and Latin character */ + g_source = str2W; + mappedlength = 0; + scale = 0.0f; + font = NULL; + hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 3, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, + DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); + ok(hr == S_OK, "got 0x%08x\n", hr); +todo_wine + ok(mappedlength == 2, "got %u\n", mappedlength); + ok(scale == 1.0f, "got %f\n", scale); + ok(font != NULL, "got %p\n", font); +if (font) { + IDWriteFont_Release(font); +} + IDWriteFontFallback_Release(fallback); IDWriteFactory2_Release(factory2); }
Add two fonts which are easily found on modern Linux installations. It might be wise to add others in the future, so that any random Linux installation has at least one of them.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/analyzer.c | 4 +++- dlls/dwrite/tests/layout.c | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index 6b74a23540a..e4bc8d42943 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -208,8 +208,10 @@ const char *debugstr_sa_script(UINT16 script)
/* system font falback configuration */ static const WCHAR meiryoW[] = {'M','e','i','r','y','o',0}; +static const WCHAR droidW[] = {'D','r','o','i','d',' ','S','a','n','s',' ','F','a','l','l','b','a','c','k',0}; +static const WCHAR notoW[] = {'N','o','t','o',' ','S','e','r','i','f',' ','C','J','K',' ','S','C',0};
-static const WCHAR *cjk_families[] = { meiryoW }; +static const WCHAR *cjk_families[] = { meiryoW, droidW, notoW };
static const DWRITE_UNICODE_RANGE cjk_ranges[] = { diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 51290d167d9..526ff4d7112 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4732,12 +4732,9 @@ if (font) { 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, "got 0x%08x\n", hr); ok(mappedlength == 2, "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); @@ -4784,7 +4781,6 @@ if (font) { ok(hr == S_OK && exists, "got 0x%08x, exists %d\n", hr, exists); hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW)); ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW)); IDWriteLocalizedStrings_Release(strings); IDWriteFont_Release(font); @@ -4798,7 +4794,6 @@ todo_wine hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 3, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine ok(mappedlength == 2, "got %u\n", mappedlength); ok(scale == 1.0f, "got %f\n", scale); ok(font != NULL, "got %p\n", font); @@ -4809,7 +4804,6 @@ if (font) { ok(hr == S_OK && exists, "got 0x%08x, exists %d\n", hr, exists); hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW)); ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW)); IDWriteLocalizedStrings_Release(strings); IDWriteFont_Release(font); @@ -4860,7 +4854,6 @@ if (font) { hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 3, &fallbackcollection, g_blahfontW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); ok(hr == S_OK, "got 0x%08x\n", hr); -todo_wine ok(mappedlength == 2, "got %u\n", mappedlength); ok(scale == 1.0f, "got %f\n", scale); ok(font != NULL, "got %p\n", font);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/analyzer.c | 16 ++++++++++++++++ dlls/dwrite/tests/layout.c | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index e4bc8d42943..daa553adbaf 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -220,6 +220,21 @@ static const DWRITE_UNICODE_RANGE cjk_ranges[] = { 0x4e00, 0x9fff }, /* CJK Unified Ideographs */ };
+static const WCHAR timesW[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0}; +static const WCHAR liberationW[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0}; +static const WCHAR dejavuW[] = {'D','e','j','a','V','u',' ','S','e','r','i','f',0}; + +static const WCHAR *latin_families[] = { timesW, liberationW, dejavuW }; + +static const DWRITE_UNICODE_RANGE latin_ranges[] = +{ + { 0x0000, 0x05ff }, + { 0x1d00, 0x2eff }, + { 0xa700, 0xa7ff }, + { 0xfb00, 0xfb4f }, + { 0xfe20, 0xfe23 }, +}; + struct fallback_mapping { DWRITE_UNICODE_RANGE *ranges; UINT32 ranges_count; @@ -236,6 +251,7 @@ static const struct fallback_mapping fontfallback_neutral_data[] = { (WCHAR **)families, ARRAY_SIZE(families) }
MAPPING_RANGE(cjk_ranges, cjk_families), + MAPPING_RANGE(latin_ranges, latin_families),
#undef MAPPING_RANGE }; diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 526ff4d7112..36372dd8c5a 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4682,12 +4682,9 @@ 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, "got 0x%08x\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); @@ -4699,12 +4696,9 @@ 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, "got 0x%08x\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); @@ -4716,12 +4710,9 @@ if (font) { font = NULL; hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 4, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); -todo_wine { ok(hr == S_OK, "got 0x%08x\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);
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- dlls/dwrite/analyzer.c | 51 ++++++++++++++++++++------------------ dlls/dwrite/tests/layout.c | 14 ----------- 2 files changed, 27 insertions(+), 38 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index daa553adbaf..c811caf0a66 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -2066,7 +2066,7 @@ static HRESULT fallback_map_characters(IDWriteFont *font, const WCHAR *text, UIN /* stop on first unsupported character */ exists = FALSE; hr = IDWriteFont_HasCharacter(font, text[i], &exists); - if (hr == S_OK && exists) + if (SUCCEEDED(hr) && exists) ++*mapped_length; else break; @@ -2084,11 +2084,12 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback, UINT32 i;
*mapped_font = NULL; + *mapped_length = 0;
mapping = find_fallback_mapping(fallback, text[0]); if (!mapping) { WARN("No mapping range for %#x.\n", text[0]); - return E_FAIL; + return S_OK; }
/* Now let's see what fallback can handle. Pick first font that could be created. */ @@ -2103,19 +2104,18 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
if (!*mapped_font) { WARN("Failed to create fallback font.\n"); - return E_FAIL; + return S_OK; }
hr = fallback_map_characters(*mapped_font, text, length, mapped_length); - if (FAILED(hr)) - WARN("Mapping with fallback family %s failed, hr %#x.\n", debugstr_w(mapping->families[i]), hr);
if (!*mapped_length) { + WARN("Mapping with fallback family %s failed.\n", debugstr_w(mapping->families[i])); IDWriteFont_Release(*mapped_font); *mapped_font = NULL; }
- return *mapped_length ? S_OK : E_FAIL; + return hr; }
static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback1 *iface, IDWriteTextAnalysisSource *source, @@ -2150,30 +2150,33 @@ 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); + /* It is not a fatal error for create_matching_font to + fail. We still have other fallbacks to try. */ + + if (SUCCEEDED(hr)) { + hr = fallback_map_characters(*ret_font, text, length, mapped_length); + if (FAILED(hr)) + goto done; + } + } + + if (!*mapped_length) { + if (*ret_font) { + IDWriteFont_Release(*ret_font); + *ret_font = NULL; + } + + hr = fallback_get_fallback_font(fallback, text, length, weight, style, stretch, mapped_length, ret_font); if (FAILED(hr)) goto done; }
if (!*mapped_length) { - IDWriteFont *mapped_font; - - hr = fallback_get_fallback_font(fallback, text, length, weight, style, stretch, mapped_length, &mapped_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; - } - } - else { - if (*ret_font) - IDWriteFont_Release(*ret_font); - *ret_font = mapped_font; - } + /* fallback wasn't found, ask the caller to skip one character + and try again; FIXME: skip the appropriate number of + characters instead of just one */ + *mapped_length = 1; }
done: diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 36372dd8c5a..7941fa180c1 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -4808,12 +4808,9 @@ if (font) { font = NULL; hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 4, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); -todo_wine { ok(hr == S_OK, "got 0x%08x\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); @@ -4826,12 +4823,9 @@ if (font) { font = NULL; hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 1, &fallbackcollection, g_fontNotInCollectionW, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale); -todo_wine { ok(hr == S_OK, "got 0x%08x\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); @@ -5090,21 +5084,17 @@ static void test_fallback(void)
count = 0; hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count); -todo_wine { ok(hr == S_OK, "Failed to get cluster metrics, hr %#x.\n", hr); ok(count == 4, "Unexpected count %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, "Failed to get layout metrics, hr %#x.\n", hr); -todo_wine { ok(metrics.width > 0.0 && metrics.width == width, "Unexpected width %.2f, expected %.2f.\n", metrics.width, width); ok(metrics.height > 0.0, "Unexpected height %.2f.\n", metrics.height); ok(metrics.lineCount == 1, "Unexpected line count %u.\n", metrics.lineCount); -} IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format);
@@ -6631,10 +6621,8 @@ 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); ok(count == 4, "got %u\n", count); -} width = 0.0; if (hr == S_OK) for (i = 0; i < count; i++) @@ -6647,12 +6635,10 @@ todo_wine { ok(metrics.width == width, "got %.2f, expected %.2f\n", metrics.width, width); ok(metrics.widthIncludingTrailingWhitespace == width, "got %.2f, expected %.2f\n", metrics.widthIncludingTrailingWhitespace, width); -todo_wine 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); -todo_wine ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount); IDWriteTextLayout_Release(layout);
On 3/4/21 1:23 PM, Giovanni Mascellani wrote:
- /* 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, L"A", 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;
Currently any layout method that triggers font creation will fail on missing font, so for the purposes of such test you can stop right at GetClusterMetrics() return value test.
Also note that specified string length exceeds string constant passed to CreateTextLayout(), remaining 3 clusters are probably not based on meaningful characters, or remaining 2 to be precise.
- 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);
+todo_wine
- ok(metrics.height > 0.0, "got %.2f\n", metrics.height);
- ok(metrics.layoutWidth == 500.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);
+todo_wine
- ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount);
- IDWriteTextLayout_Release(layout);
- IDWriteTextFormat_Release(format); IDWriteFactory_Release(factory);
I don't see any value in testing this.
Patch subject is inaccurate because you're testing layout behavior, format instance does not check or care if font exists, it only holds parameters.