Module: wine Branch: master Commit: d171185062e89ecfb9ffb01f545ae12a37694d53 URL: http://source.winehq.org/git/wine.git/?a=commit;h=d171185062e89ecfb9ffb01f54...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Tue Jan 26 15:44:46 2016 +0300
dwrite: Reuse linebreaking isSoftHyphen flag for cluster metrics.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dwrite/analyzer.c | 2 +- dlls/dwrite/layout.c | 5 +++-- dlls/dwrite/tests/analyzer.c | 18 ++++++++++++++++++ dlls/dwrite/tests/layout.c | 14 ++++++++------ 4 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c index 885cd76..2eb495e 100644 --- a/dlls/dwrite/analyzer.c +++ b/dlls/dwrite/analyzer.c @@ -348,7 +348,7 @@ static HRESULT analyze_linebreaks(const WCHAR *text, UINT32 count, DWRITE_LINE_B breakpoints[i].breakConditionBefore = DWRITE_BREAK_CONDITION_CAN_BREAK; breakpoints[i].breakConditionAfter = DWRITE_BREAK_CONDITION_CAN_BREAK; breakpoints[i].isWhitespace = !!isspaceW(text[i]); - breakpoints[i].isSoftHyphen = FALSE; + breakpoints[i].isSoftHyphen = text[i] == 0x00ad /* Unicode Soft Hyphen */; breakpoints[i].padding = 0;
/* LB1 - resolve some classes. TODO: use external algorithms for these classes. */ diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 241616b..27b02dc 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -612,9 +612,10 @@ static inline void init_cluster_metrics(const struct dwrite_textlayout *layout, metrics->canWrapLineAfter = breakcondition == DWRITE_BREAK_CONDITION_CAN_BREAK || breakcondition == DWRITE_BREAK_CONDITION_MUST_BREAK; if (metrics->length == 1) { - metrics->isWhitespace = get_effective_breakpoint(layout, position).isWhitespace; + DWRITE_LINE_BREAKPOINT bp = get_effective_breakpoint(layout, position); + metrics->isWhitespace = bp.isWhitespace; metrics->isNewline = FALSE /* FIXME */; - metrics->isSoftHyphen = layout->str[position] == 0x00ad /* Unicode Soft Hyphen */; + metrics->isSoftHyphen = bp.isSoftHyphen; } else { metrics->isWhitespace = FALSE; diff --git a/dlls/dwrite/tests/analyzer.c b/dlls/dwrite/tests/analyzer.c index 1519289..fa0d7eb 100644 --- a/dlls/dwrite/tests/analyzer.c +++ b/dlls/dwrite/tests/analyzer.c @@ -988,6 +988,24 @@ static struct linebreaks_test linebreaks_tests[] = { { DWRITE_BREAK_CONDITION_MUST_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, } }, + /* Soft hyphen, visible word dividers */ + { {'A',0xad,'B',0x5be,'C',0xf0b,'D',0x1361,'E',0x17d8,'F',0x17da,'G',0}, + { + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 1 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_MAY_NOT_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + { DWRITE_BREAK_CONDITION_CAN_BREAK, DWRITE_BREAK_CONDITION_CAN_BREAK, 0, 0 }, + } + }, { { 0 } } };
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index f036633..00da357 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -1666,13 +1666,13 @@ static void test_GetClusterMetrics(void) /* SP - SPACE */ 0x20 }; static const WCHAR str5W[] = {'a','\r','b','\n','c','\n','\r','d','\r','\n','e',0xb,'f',0xc, - 'g',0x0085,'h',0x2028,'i',0x2029,0}; + 'g',0x0085,'h',0x2028,'i',0x2029,0xad,0}; 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}; static const WCHAR str4W[] = {'a',' ',0}; DWRITE_INLINE_OBJECT_METRICS inline_metrics; - DWRITE_CLUSTER_METRICS metrics[20]; + DWRITE_CLUSTER_METRICS metrics[21]; IDWriteTextLayout1 *layout1; IDWriteInlineObject *trimm; IDWriteTextFormat *format; @@ -1955,14 +1955,14 @@ todo_wine IDWriteTextLayout_Release(layout);
/* isNewline tests */ - hr = IDWriteFactory_CreateTextLayout(factory, str5W, 20, format, 100.0, 200.0, &layout); + hr = IDWriteFactory_CreateTextLayout(factory, str5W, lstrlenW(str5W), format, 100.0f, 200.0f, &layout); ok(hr == S_OK, "got 0x%08x\n", hr);
count = 0; memset(metrics, 0, sizeof(metrics)); - hr = IDWriteTextLayout_GetClusterMetrics(layout, metrics, 20, &count); + hr = IDWriteTextLayout_GetClusterMetrics(layout, metrics, sizeof(metrics)/sizeof(metrics[0]), &count); ok(hr == S_OK, "got 0x%08x\n", hr); - ok(count == 20, "got %u\n", count); + ok(count == 21, "got %u\n", count);
todo_wine { ok(metrics[1].isNewline == 1, "got %d\n", metrics[1].isNewline); @@ -1987,8 +1987,10 @@ todo_wine { ok(metrics[16].isNewline == 0, "got %d\n", metrics[16].isNewline); ok(metrics[18].isNewline == 0, "got %d\n", metrics[18].isNewline);
- for (i = 0; i < count; i++) + for (i = 0; i < count; i++) { ok(metrics[i].length == 1, "%d: got %d\n", i, metrics[i].length); + ok(metrics[i].isSoftHyphen == (i == count - 1), "%d: got %d\n", i, metrics[i].isSoftHyphen); + }
IDWriteTextLayout_Release(layout);