dwrite: Force advances to zero for isZeroWidthSpace glyphs.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-02-16 00:59:24 +03:00 committed by Alexandre Julliard
parent fd8ecd0cfa
commit 297b3d080a
2 changed files with 48 additions and 6 deletions

View File

@ -1089,13 +1089,16 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphPlacements(IDWriteTextAnalyzer2
IDWriteFontFace_GetMetrics(fontface, &metrics);
for (i = 0; i < glyph_count; i++) {
INT32 a;
if (glyph_props[i].isZeroWidthSpace)
advances[i] = 0.0f;
else {
INT32 a;
hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &glyphs[i], &a, is_sideways);
if (FAILED(hr))
a = 0;
advances[i] = get_scaled_advance_width(a, emSize, &metrics);
hr = IDWriteFontFace1_GetDesignGlyphAdvances(fontface1, 1, &glyphs[i], &a, is_sideways);
if (FAILED(hr))
a = 0;
advances[i] = get_scaled_advance_width(a, emSize, &metrics);
}
offsets[i].advanceOffset = 0.0f;
offsets[i].ascenderOffset = 0.0f;
}

View File

@ -1393,6 +1393,18 @@ if (0) {
ok(advances[0] == advances2[0], "got %.2f, expected %.2f\n", advances[0], advances2[0]);
ok(advances[1] == advances2[1], "got %.2f, expected %.2f\n", advances[1], advances2[1]);
/* DWRITE_SCRIPT_SHAPES_NO_VISUAL run */
maxglyphcount = 10;
actual_count = 0;
sa.script = 0;
sa.shapes = DWRITE_SCRIPT_SHAPES_NO_VISUAL;
hr = IDWriteTextAnalyzer_GetGlyphs(analyzer, test1W, lstrlenW(test1W), fontface, FALSE, FALSE, &sa, NULL,
NULL, NULL, NULL, 0, maxglyphcount, clustermap, props, glyphs1, shapingprops, &actual_count);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(actual_count == 4, "got %d\n", actual_count);
ok(sa.script == 0, "got %u\n", sa.script);
ok(!shapingprops[0].isZeroWidthSpace, "got %d\n", shapingprops[0].isZeroWidthSpace);
IDWriteTextAnalyzer_Release(analyzer);
IDWriteFontFace_Release(fontface);
}
@ -1582,6 +1594,33 @@ static void test_GetGlyphPlacements(void)
ok(offsets[0].advanceOffset == 0.0 && offsets[0].ascenderOffset == 0.0, "got %.2f,%.2f\n",
offsets[0].advanceOffset, offsets[0].ascenderOffset);
/* DWRITE_SCRIPT_SHAPES_NO_VISUAL has no effect on placement */
sa.shapes = DWRITE_SCRIPT_SHAPES_NO_VISUAL;
advances[0] = advances[1] = 1.0f;
memset(offsets, 0xcc, sizeof(offsets));
hr = IDWriteTextAnalyzer_GetGlyphPlacements(analyzer, aW, clustermap, textprops,
len, glyphs, glyphprops, len, fontface, 2048.0f, FALSE, FALSE, &sa, NULL, NULL,
NULL, 0, advances, offsets);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(advances[0] == 1000.0f, "got %.2f\n", advances[0]);
ok(advances[1] == 1000.0f, "got %.2f\n", advances[1]);
ok(offsets[0].advanceOffset == 0.0f && offsets[0].ascenderOffset == 0.0f, "got %.2f,%.2f\n",
offsets[0].advanceOffset, offsets[0].ascenderOffset);
/* isZeroWidthSpace */
sa.shapes = DWRITE_SCRIPT_SHAPES_DEFAULT;
advances[0] = advances[1] = 1.0f;
memset(offsets, 0xcc, sizeof(offsets));
glyphprops[0].isZeroWidthSpace = 1;
hr = IDWriteTextAnalyzer_GetGlyphPlacements(analyzer, aW, clustermap, textprops,
len, glyphs, glyphprops, len, fontface, 2048.0f, FALSE, FALSE, &sa, NULL, NULL,
NULL, 0, advances, offsets);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(advances[0] == 0.0f, "got %.2f\n", advances[0]);
ok(advances[1] == 1000.0f, "got %.2f\n", advances[1]);
ok(offsets[0].advanceOffset == 0.0f && offsets[0].ascenderOffset == 0.0f, "got %.2f,%.2f\n",
offsets[0].advanceOffset, offsets[0].ascenderOffset);
IDWriteTextAnalyzer_Release(analyzer);
IDWriteFontFace_Release(fontface);
DELETE_FONTFILE(path);