Module: wine Branch: master Commit: 63e1b3f5457b18505a89408155233de9073d6e71 URL: http://source.winehq.org/git/wine.git/?a=commit;h=63e1b3f5457b18505a89408155...
Author: Nikolay Sivov bunglehead@gmail.com Date: Mon Feb 8 12:31:17 2016 +0300
dwrite: Don't create enumerator with invalid palette.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/dwrite/font.c | 2 +- dlls/dwrite/tests/font.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index d466612..18e4e0e 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -4643,7 +4643,7 @@ HRESULT create_colorglyphenum(FLOAT originX, FLOAT originY, const DWRITE_GLYPH_R return hr; }
- colorfont = IDWriteFontFace2_IsColorFont(fontface2); + colorfont = IDWriteFontFace2_IsColorFont(fontface2) && IDWriteFontFace2_GetColorPaletteCount(fontface2) > palette; IDWriteFontFace2_Release(fontface2); if (!colorfont) return DWRITE_E_NOCOLOR; diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index b77d0cd..76d76f7 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -5137,6 +5137,7 @@ static void test_TranslateColorGlyphRun(void) { IDWriteColorGlyphRunEnumerator *layers; const DWRITE_COLOR_GLYPH_RUN *colorrun; + IDWriteFontFace2 *fontface2; IDWriteFontFace *fontface; IDWriteFactory2 *factory2; IDWriteFactory *factory; @@ -5200,9 +5201,12 @@ static void test_TranslateColorGlyphRun(void) layers = NULL; hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); +todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(layers != NULL, "got %p\n", layers); +}
+if (layers) { while (1) { hasrun = FALSE; hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &hasrun); @@ -5219,6 +5223,26 @@ todo_wine ok(hr == E_NOT_VALID_STATE, "got 0x%08x\n", hr);
IDWriteColorGlyphRunEnumerator_Release(layers); +} + hr = IDWriteFontFace_QueryInterface(fontface, &IID_IDWriteFontFace2, (void**)&fontface2); + ok(hr == S_OK, "got 0x%08x\n", hr); + + /* invalid palette index */ + layers = (void*)0xdeadbeef; + hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0f, 0.0f, &run, NULL, + DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2), + &layers); + ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr); + ok(layers == NULL, "got %p\n", layers); + + layers = NULL; + hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0f, 0.0f, &run, NULL, + DWRITE_MEASURING_MODE_NATURAL, NULL, IDWriteFontFace2_GetColorPaletteCount(fontface2) - 1, + &layers); +todo_wine + ok(hr == S_OK, "got 0x%08x\n", hr); +if (layers) + IDWriteColorGlyphRunEnumerator_Release(layers);
/* color font, glyph without color info */ codepoints[0] = 'A'; @@ -5228,10 +5252,9 @@ todo_wine layers = (void*)0xdeadbeef; hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); -todo_wine { ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr); ok(layers == NULL, "got %p\n", layers); -} + /* one glyph with, one without */ codepoints[0] = 'A'; codepoints[1] = 0x26c4; @@ -5244,10 +5267,14 @@ todo_wine { layers = NULL; hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); +todo_wine { ok(hr == S_OK, "got 0x%08x\n", hr); ok(layers != NULL, "got %p\n", layers); +} +if (layers) IDWriteColorGlyphRunEnumerator_Release(layers);
+ IDWriteFontFace2_Release(fontface2); IDWriteFontFace_Release(fontface); IDWriteFactory2_Release(factory2); }