From de2ae5e1b8f65a855d0fd62a50346042aac9bd29 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 15 Jun 2015 00:36:43 +0300 Subject: [PATCH] dwrite: Fix splitted range length, initial test for GetMetrics(). --- dlls/dwrite/layout.c | 2 +- dlls/dwrite/tests/analyzer.c | 4 +- dlls/dwrite/tests/layout.c | 75 ++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 903e53d38ba..bdd8ad6d44a 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -3084,7 +3084,7 @@ static HRESULT WINAPI dwritetextlayout_sink_SetBidiLevel(IDWriteTextAnalysisSink /* reduce existing run */ cur->run.bidiLevel = resolvedLevel; - cur->descr.stringLength -= length; + cur->descr.stringLength = length; list_add_after(&cur_run->entry, &run->entry); break; diff --git a/dlls/dwrite/tests/analyzer.c b/dlls/dwrite/tests/analyzer.c index 4e2e7ca887d..c514beccb47 100644 --- a/dlls/dwrite/tests/analyzer.c +++ b/dlls/dwrite/tests/analyzer.c @@ -523,8 +523,8 @@ static struct sa_test sa_tests[] = { }, { /* Arabic */ - {0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,0}, 1, - { { 0, 7, DWRITE_SCRIPT_SHAPES_DEFAULT }} + {0x064a,0x064f,0x0633,0x0627,0x0648,0x0650,0x064a,0x0661,0}, 1, + { { 0, 8, DWRITE_SCRIPT_SHAPES_DEFAULT }} }, { /* Arabic */ diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 40936336e89..2b1996104bd 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -1380,6 +1380,7 @@ static void test_typography(void) static void test_GetClusterMetrics(void) { + static const WCHAR str3W[] = {0x2066,')',')',0x661,'(',0x627,')',0}; static const WCHAR str2W[] = {0x202a,0x202c,'a',0}; static const WCHAR strW[] = {'a','b','c','d',0}; DWRITE_INLINE_OBJECT_METRICS inline_metrics; @@ -1399,6 +1400,13 @@ static void test_GetClusterMetrics(void) DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format); ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IDWriteFactory_CreateTextLayout(factory, str3W, 7, format, 1000.0, 1000.0, &layout); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IDWriteTextLayout_GetClusterMetrics(layout, NULL, 0, &count); + ok(hr == E_NOT_SUFFICIENT_BUFFER, "got 0x%08x\n", hr); + ok(count == 7, "got %u\n", count); + IDWriteTextLayout_Release(layout); + hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 1000.0, 1000.0, &layout); ok(hr == S_OK, "got 0x%08x\n", hr); @@ -1873,6 +1881,7 @@ static void test_DetermineMinWidth(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } static void test_SetFontSize(void) @@ -1964,6 +1973,7 @@ static void test_SetFontSize(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } static void test_SetFontFamilyName(void) @@ -2044,6 +2054,7 @@ static void test_SetFontFamilyName(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } static void test_SetFontStyle(void) @@ -2131,6 +2142,7 @@ static void test_SetFontStyle(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } static void test_SetFontStretch(void) @@ -2225,6 +2237,7 @@ static void test_SetFontStretch(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } static void test_SetStrikethrough(void) @@ -2286,6 +2299,67 @@ static void test_SetStrikethrough(void) IDWriteTextLayout_Release(layout); IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); +} + +static void test_GetMetrics(void) +{ + static const WCHAR str2W[] = {0x2066,')',')',0x661,'(',0x627,')',0}; + static const WCHAR strW[] = {'a','b','c','d',0}; + DWRITE_TEXT_METRICS metrics; + IDWriteTextFormat *format; + IDWriteTextLayout *layout; + IDWriteFactory *factory; + HRESULT hr; + + factory = create_factory(); + + hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, + DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &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); + + 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 > 0.0, "got %.2f\n", metrics.width); + ok(metrics.widthIncludingTrailingWhitespace > 0.0, "got %.2f\n", metrics.widthIncludingTrailingWhitespace); + 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); + ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount); +} + IDWriteTextLayout_Release(layout); + + /* a string with more complex bidi sequence */ + hr = IDWriteFactory_CreateTextLayout(factory, str2W, 7, format, 500.0, 1000.0, &layout); + ok(hr == S_OK, "got 0x%08x\n", hr); + + memset(&metrics, 0xcc, sizeof(metrics)); + metrics.maxBidiReorderingDepth = 0; + 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 > 0.0, "got %.2f\n", metrics.width); + ok(metrics.widthIncludingTrailingWhitespace > 0.0, "got %.2f\n", metrics.widthIncludingTrailingWhitespace); + 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); + ok(metrics.lineCount == 1, "got %u\n", metrics.lineCount); +} + IDWriteTextLayout_Release(layout); + + IDWriteTextFormat_Release(format); + IDWriteFactory_Release(factory); } START_TEST(layout) @@ -2324,6 +2398,7 @@ START_TEST(layout) test_SetFontStyle(); test_SetFontStretch(); test_SetStrikethrough(); + test_GetMetrics(); IDWriteFactory_Release(factory); }