Module: wine Branch: master Commit: f68f63152f94f6c8429901866df0bccf355d50b9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f68f63152f94f6c8429901866d...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Jun 17 21:51:01 2015 +0300
dwrite: Set cluster length together with other metrics.
---
dlls/dwrite/layout.c | 17 ++++++++--------- dlls/dwrite/tests/layout.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index 72f0885..e001e49 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -469,21 +469,20 @@ static inline DWRITE_LINE_BREAKPOINT get_effective_breakpoint(const struct dwrit }
static inline void init_cluster_metrics(const struct dwrite_textlayout *layout, const struct regular_layout_run *run, - UINT16 start_glyph, UINT16 stop_glyph, UINT32 stop_position, DWRITE_CLUSTER_METRICS *metrics) + UINT16 start_glyph, UINT16 stop_glyph, UINT32 stop_position, UINT16 length, DWRITE_CLUSTER_METRICS *metrics) { UINT8 breakcondition; UINT32 position; UINT16 j;
- metrics->width = 0.0; - - /* For clusters on control chars we report zero glyphs, and we need zero cluster + /* For clusters made of control chars we report zero glyphs, and we need zero cluster width as well; advances are already computed at this point and are not necessary zero. */ + metrics->width = 0.0; if (run->run.glyphCount) { for (j = start_glyph; j < stop_glyph; j++) metrics->width += run->run.glyphAdvances[j]; } - metrics->length = 0; + metrics->length = length;
position = stop_position; if (stop_glyph == run->glyphcount) @@ -531,8 +530,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s BOOL end = i == run->descr.stringLength - 1;
if (run->descr.clusterMap[start] != run->descr.clusterMap[i]) { - init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i, metrics); - metrics->length = i - start; + init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i, + i - start, metrics); c->position = start; c->run = r;
@@ -543,8 +542,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s }
if (end) { - init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i, metrics); - metrics->length = i - start + 1; + init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i, + i - start + 1, metrics); c->position = start; c->run = r;
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 3e654ae..5d655b6 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -1486,6 +1486,7 @@ 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}; + static const WCHAR str4W[] = {'a',' ',0}; DWRITE_INLINE_OBJECT_METRICS inline_metrics; DWRITE_CLUSTER_METRICS metrics[4]; IDWriteTextLayout1 *layout1; @@ -1705,6 +1706,20 @@ todo_wine ok(count == 0, "got %u\n", count); IDWriteTextLayout_Release(layout);
+ /* whitespace */ + hr = IDWriteFactory_CreateTextLayout(factory, str4W, 2, format, 1000.0, 1000.0, &layout); + ok(hr == S_OK, "got 0x%08x\n", hr); + + count = 0; + memset(metrics, 0, sizeof(metrics)); + hr = IDWriteTextLayout_GetClusterMetrics(layout, metrics, 2, &count); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(count == 2, "got %u\n", count); + ok(metrics[0].isWhitespace == 0, "got %d\n", metrics[0].isWhitespace); +todo_wine + ok(metrics[1].isWhitespace == 1, "got %d\n", metrics[1].isWhitespace); + IDWriteTextLayout_Release(layout); + IDWriteInlineObject_Release(trimm); IDWriteTextFormat_Release(format); IDWriteFactory_Release(factory);