dwrite: Exit earlier when setting property for zero length range.

This commit is contained in:
Nikolay Sivov 2015-06-08 21:12:54 +03:00 committed by Alexandre Julliard
parent ffeba2348a
commit 1a2d520ee1
2 changed files with 28 additions and 0 deletions

View File

@ -1431,6 +1431,10 @@ static HRESULT set_layout_range_attr(struct dwrite_textlayout *layout, enum layo
struct list *ranges;
DWRITE_TEXT_RANGE r;
/* ignore zero length ranges */
if (value->range.length == 0)
return S_OK;
/* select from ranges lists */
switch (attr)
{

View File

@ -1879,6 +1879,12 @@ static void test_SetFontSize(void)
hr = IDWriteTextLayout_SetFontSize(layout, 15.0, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* zero length range */
r.startPosition = 1;
r.length = 0;
hr = IDWriteTextLayout_SetFontSize(layout, 123.0, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
size = 0.0;
hr = IDWriteTextLayout_GetFontSize(layout, 1, &size, &r);
ok(hr == S_OK, "got 0x%08x\n", hr);
@ -1963,6 +1969,12 @@ static void test_SetFontFamilyName(void)
hr = IDWriteTextLayout_SetFontFamilyName(layout, taHomaW, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* zero length range */
r.startPosition = 1;
r.length = 0;
hr = IDWriteTextLayout_SetFontFamilyName(layout, arialW, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
r.startPosition = 0;
r.length = 0;
nameW[0] = 0;
@ -2034,6 +2046,12 @@ static void test_SetFontStyle(void)
hr = IDWriteTextLayout_SetFontStyle(layout, DWRITE_FONT_STYLE_ITALIC, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* zero length range */
r.startPosition = 1;
r.length = 0;
hr = IDWriteTextLayout_SetFontStyle(layout, DWRITE_FONT_STYLE_NORMAL, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
style = DWRITE_FONT_STYLE_NORMAL;
hr = IDWriteTextLayout_GetFontStyle(layout, 1, &style, &r);
ok(hr == S_OK, "got 0x%08x\n", hr);
@ -2116,6 +2134,12 @@ static void test_SetFontStretch(void)
hr = IDWriteTextLayout_SetFontStretch(layout, DWRITE_FONT_STRETCH_CONDENSED, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
/* zero length range */
r.startPosition = 1;
r.length = 0;
hr = IDWriteTextLayout_SetFontStretch(layout, DWRITE_FONT_STRETCH_NORMAL, r);
ok(hr == S_OK, "got 0x%08x\n", hr);
stretch = DWRITE_FONT_STRETCH_UNDEFINED;
hr = IDWriteTextLayout_GetFontStretch(layout, 1, &stretch, &r);
ok(hr == S_OK, "got 0x%08x\n", hr);