Commit 63e1b3f5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Don't create enumerator with invalid palette.

parent ec3c7d9d
...@@ -4643,7 +4643,7 @@ HRESULT create_colorglyphenum(FLOAT originX, FLOAT originY, const DWRITE_GLYPH_R ...@@ -4643,7 +4643,7 @@ HRESULT create_colorglyphenum(FLOAT originX, FLOAT originY, const DWRITE_GLYPH_R
return hr; return hr;
} }
colorfont = IDWriteFontFace2_IsColorFont(fontface2); colorfont = IDWriteFontFace2_IsColorFont(fontface2) && IDWriteFontFace2_GetColorPaletteCount(fontface2) > palette;
IDWriteFontFace2_Release(fontface2); IDWriteFontFace2_Release(fontface2);
if (!colorfont) if (!colorfont)
return DWRITE_E_NOCOLOR; return DWRITE_E_NOCOLOR;
......
...@@ -5137,6 +5137,7 @@ static void test_TranslateColorGlyphRun(void) ...@@ -5137,6 +5137,7 @@ static void test_TranslateColorGlyphRun(void)
{ {
IDWriteColorGlyphRunEnumerator *layers; IDWriteColorGlyphRunEnumerator *layers;
const DWRITE_COLOR_GLYPH_RUN *colorrun; const DWRITE_COLOR_GLYPH_RUN *colorrun;
IDWriteFontFace2 *fontface2;
IDWriteFontFace *fontface; IDWriteFontFace *fontface;
IDWriteFactory2 *factory2; IDWriteFactory2 *factory2;
IDWriteFactory *factory; IDWriteFactory *factory;
...@@ -5200,9 +5201,12 @@ static void test_TranslateColorGlyphRun(void) ...@@ -5200,9 +5201,12 @@ static void test_TranslateColorGlyphRun(void)
layers = NULL; layers = NULL;
hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL,
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(layers != NULL, "got %p\n", layers); ok(layers != NULL, "got %p\n", layers);
}
if (layers) {
while (1) { while (1) {
hasrun = FALSE; hasrun = FALSE;
hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &hasrun); hr = IDWriteColorGlyphRunEnumerator_MoveNext(layers, &hasrun);
...@@ -5219,6 +5223,26 @@ todo_wine ...@@ -5219,6 +5223,26 @@ todo_wine
ok(hr == E_NOT_VALID_STATE, "got 0x%08x\n", hr); ok(hr == E_NOT_VALID_STATE, "got 0x%08x\n", hr);
IDWriteColorGlyphRunEnumerator_Release(layers); 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 */ /* color font, glyph without color info */
codepoints[0] = 'A'; codepoints[0] = 'A';
...@@ -5228,10 +5252,9 @@ todo_wine ...@@ -5228,10 +5252,9 @@ todo_wine
layers = (void*)0xdeadbeef; layers = (void*)0xdeadbeef;
hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL,
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
todo_wine {
ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr); ok(hr == DWRITE_E_NOCOLOR, "got 0x%08x\n", hr);
ok(layers == NULL, "got %p\n", layers); ok(layers == NULL, "got %p\n", layers);
}
/* one glyph with, one without */ /* one glyph with, one without */
codepoints[0] = 'A'; codepoints[0] = 'A';
codepoints[1] = 0x26c4; codepoints[1] = 0x26c4;
...@@ -5244,10 +5267,14 @@ todo_wine { ...@@ -5244,10 +5267,14 @@ todo_wine {
layers = NULL; layers = NULL;
hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL, hr = IDWriteFactory2_TranslateColorGlyphRun(factory2, 0.0, 0.0, &run, NULL,
DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers); DWRITE_MEASURING_MODE_NATURAL, NULL, 0, &layers);
todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(layers != NULL, "got %p\n", layers); ok(layers != NULL, "got %p\n", layers);
}
if (layers)
IDWriteColorGlyphRunEnumerator_Release(layers); IDWriteColorGlyphRunEnumerator_Release(layers);
IDWriteFontFace2_Release(fontface2);
IDWriteFontFace_Release(fontface); IDWriteFontFace_Release(fontface);
IDWriteFactory2_Release(factory2); IDWriteFactory2_Release(factory2);
} }
......
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