dwrite: Set cluster length together with other metrics.
This commit is contained in:
parent
45677e173d
commit
f68f63152f
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue