dwrite: Filter invalid weight in SetFontWeight().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2016-07-19 23:03:01 +03:00 committed by Alexandre Julliard
parent 02773e1f15
commit 4f01bee4c8
2 changed files with 8 additions and 0 deletions

View File

@ -2889,6 +2889,9 @@ static HRESULT WINAPI dwritetextlayout_SetFontWeight(IDWriteTextLayout3 *iface,
TRACE("(%p)->(%d %s)\n", This, weight, debugstr_range(&range));
if ((UINT32)weight > DWRITE_FONT_WEIGHT_ULTRA_BLACK)
return E_INVALIDARG;
value.range = range;
value.u.weight = weight;
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_WEIGHT, &value);

View File

@ -1249,6 +1249,11 @@ static void test_fontweight(void)
ok(weight == DWRITE_FONT_WEIGHT_NORMAL, "got %d\n", weight);
ok(range.length == 6, "got %d\n", range.length);
range.startPosition = 0;
range.length = 6;
hr = IDWriteTextLayout_SetFontWeight(layout, 1000, range);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
size = IDWriteTextLayout_GetMaxWidth(layout);
ok(size == 100.0, "got %.2f\n", size);