Commit f68f6315 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Set cluster length together with other metrics.

parent 45677e17
...@@ -469,21 +469,20 @@ static inline DWRITE_LINE_BREAKPOINT get_effective_breakpoint(const struct dwrit ...@@ -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, 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; UINT8 breakcondition;
UINT32 position; UINT32 position;
UINT16 j; UINT16 j;
metrics->width = 0.0; /* For clusters made of control chars we report zero glyphs, and we need zero cluster
/* For clusters on 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. */ width as well; advances are already computed at this point and are not necessary zero. */
metrics->width = 0.0;
if (run->run.glyphCount) { if (run->run.glyphCount) {
for (j = start_glyph; j < stop_glyph; j++) for (j = start_glyph; j < stop_glyph; j++)
metrics->width += run->run.glyphAdvances[j]; metrics->width += run->run.glyphAdvances[j];
} }
metrics->length = 0; metrics->length = length;
position = stop_position; position = stop_position;
if (stop_glyph == run->glyphcount) if (stop_glyph == run->glyphcount)
...@@ -531,8 +530,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s ...@@ -531,8 +530,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s
BOOL end = i == run->descr.stringLength - 1; BOOL end = i == run->descr.stringLength - 1;
if (run->descr.clusterMap[start] != run->descr.clusterMap[i]) { if (run->descr.clusterMap[start] != run->descr.clusterMap[i]) {
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i, metrics); init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->descr.clusterMap[i], i,
metrics->length = i - start; i - start, metrics);
c->position = start; c->position = start;
c->run = r; c->run = r;
...@@ -543,8 +542,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s ...@@ -543,8 +542,8 @@ static void layout_set_cluster_metrics(struct dwrite_textlayout *layout, const s
} }
if (end) { if (end) {
init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i, metrics); init_cluster_metrics(layout, run, run->descr.clusterMap[start], run->glyphcount, i,
metrics->length = i - start + 1; i - start + 1, metrics);
c->position = start; c->position = start;
c->run = r; c->run = r;
......
...@@ -1486,6 +1486,7 @@ static void test_GetClusterMetrics(void) ...@@ -1486,6 +1486,7 @@ static void test_GetClusterMetrics(void)
static const WCHAR str3W[] = {0x2066,')',')',0x661,'(',0x627,')',0}; static const WCHAR str3W[] = {0x2066,')',')',0x661,'(',0x627,')',0};
static const WCHAR str2W[] = {0x202a,0x202c,'a',0}; static const WCHAR str2W[] = {0x202a,0x202c,'a',0};
static const WCHAR strW[] = {'a','b','c','d',0}; static const WCHAR strW[] = {'a','b','c','d',0};
static const WCHAR str4W[] = {'a',' ',0};
DWRITE_INLINE_OBJECT_METRICS inline_metrics; DWRITE_INLINE_OBJECT_METRICS inline_metrics;
DWRITE_CLUSTER_METRICS metrics[4]; DWRITE_CLUSTER_METRICS metrics[4];
IDWriteTextLayout1 *layout1; IDWriteTextLayout1 *layout1;
...@@ -1705,6 +1706,20 @@ todo_wine ...@@ -1705,6 +1706,20 @@ todo_wine
ok(count == 0, "got %u\n", count); ok(count == 0, "got %u\n", count);
IDWriteTextLayout_Release(layout); 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); IDWriteInlineObject_Release(trimm);
IDWriteTextFormat_Release(format); IDWriteTextFormat_Release(format);
IDWriteFactory_Release(factory); IDWriteFactory_Release(factory);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment