Commit 672aae65 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Store pair kerning range attribute.

parent 777ae5b7
......@@ -67,6 +67,7 @@ enum layout_range_attr_kind {
LAYOUT_RANGE_ATTR_INLINE,
LAYOUT_RANGE_ATTR_UNDERLINE,
LAYOUT_RANGE_ATTR_STRIKETHROUGH,
LAYOUT_RANGE_ATTR_PAIR_KERNING,
LAYOUT_RANGE_ATTR_FONTCOLL,
LAYOUT_RANGE_ATTR_LOCALE,
LAYOUT_RANGE_ATTR_FONTFAMILY
......@@ -83,6 +84,7 @@ struct layout_range_attr_value {
IUnknown *effect;
BOOL underline;
BOOL strikethrough;
BOOL pair_kerning;
IDWriteFontCollection *collection;
const WCHAR *locale;
const WCHAR *fontfamily;
......@@ -100,6 +102,7 @@ struct layout_range {
IUnknown *effect;
BOOL underline;
BOOL strikethrough;
BOOL pair_kerning;
IDWriteFontCollection *collection;
WCHAR locale[LOCALE_NAME_MAX_LENGTH];
WCHAR *fontfamily;
......@@ -628,6 +631,8 @@ static BOOL is_same_layout_attrvalue(struct layout_range const *range, enum layo
return range->underline == value->u.underline;
case LAYOUT_RANGE_ATTR_STRIKETHROUGH:
return range->strikethrough == value->u.strikethrough;
case LAYOUT_RANGE_ATTR_PAIR_KERNING:
return range->pair_kerning == value->u.pair_kerning;
case LAYOUT_RANGE_ATTR_FONTCOLL:
return range->collection == value->u.collection;
case LAYOUT_RANGE_ATTR_LOCALE:
......@@ -651,6 +656,7 @@ static inline BOOL is_same_layout_attributes(struct layout_range const *left, st
left->effect == right->effect &&
left->underline == right->underline &&
left->strikethrough == right->strikethrough &&
left->pair_kerning == right->pair_kerning &&
left->collection == right->collection &&
!strcmpW(left->locale, right->locale) &&
!strcmpW(left->fontfamily, right->fontfamily);
......@@ -678,6 +684,7 @@ static struct layout_range *alloc_layout_range(struct dwrite_textlayout *layout,
range->effect = NULL;
range->underline = FALSE;
range->strikethrough = FALSE;
range->pair_kerning = FALSE;
range->fontfamily = heap_strdupW(layout->format.family_name);
if (!range->fontfamily) {
......@@ -823,6 +830,10 @@ static BOOL set_layout_range_attrval(struct layout_range *dest, enum layout_rang
changed = dest->strikethrough != value->u.strikethrough;
dest->strikethrough = value->u.strikethrough;
break;
case LAYOUT_RANGE_ATTR_PAIR_KERNING:
changed = dest->pair_kerning != value->u.pair_kerning;
dest->pair_kerning = value->u.pair_kerning;
break;
case LAYOUT_RANGE_ATTR_FONTCOLL:
changed = set_layout_range_iface_attr((IUnknown**)&dest->collection, (IUnknown*)value->u.collection);
break;
......@@ -1758,16 +1769,30 @@ static HRESULT WINAPI dwritetextlayout1_SetPairKerning(IDWriteTextLayout2 *iface
DWRITE_TEXT_RANGE range)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p)->(%d %s): stub\n", This, is_pairkerning_enabled, debugstr_range(&range));
return E_NOTIMPL;
struct layout_range_attr_value value;
TRACE("(%p)->(%d %s)\n", This, is_pairkerning_enabled, debugstr_range(&range));
value.range = range;
value.u.pair_kerning = !!is_pairkerning_enabled;
return set_layout_range_attr(This, LAYOUT_RANGE_ATTR_PAIR_KERNING, &value);
}
static HRESULT WINAPI dwritetextlayout1_GetPairKerning(IDWriteTextLayout2 *iface, UINT32 position, BOOL *is_pairkerning_enabled,
DWRITE_TEXT_RANGE *range)
DWRITE_TEXT_RANGE *r)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p)->(%p %p): stub\n", This, is_pairkerning_enabled, range);
return E_NOTIMPL;
struct layout_range *range;
TRACE("(%p)->(%u %p %p)\n", This, position, is_pairkerning_enabled, r);
if (position >= This->len)
return S_OK;
range = get_layout_range_by_pos(This, position);
*is_pairkerning_enabled = range->pair_kerning;
return return_range(range, r);
}
static HRESULT WINAPI dwritetextlayout1_SetCharacterSpacing(IDWriteTextLayout2 *iface, FLOAT leading_spacing, FLOAT trailing_spacing,
......
......@@ -1035,6 +1035,60 @@ if (0) /* crashes on native */
IDWriteTextFormat_Release(format);
}
static void test_SetPairKerning(void)
{
static const WCHAR strW[] = {'a','b','c','d',0};
IDWriteTextLayout1 *layout1;
IDWriteTextFormat *format;
IDWriteTextLayout *layout;
DWRITE_TEXT_RANGE range;
BOOL kerning;
HRESULT hr;
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, 10.0, enusW, &format);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteFactory_CreateTextLayout(factory, strW, 4, format, 1000.0, 1000.0, &layout);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteTextFormat_Release(format);
hr = IDWriteTextLayout_QueryInterface(layout, &IID_IDWriteTextLayout1, (void**)&layout1);
IDWriteTextLayout_Release(layout);
if (hr != S_OK) {
win_skip("SetPairKerning() is not supported.\n");
return;
}
if (0) { /* crashes on native */
hr = IDWriteTextLayout1_GetPairKerning(layout1, 0, NULL, NULL);
hr = IDWriteTextLayout1_GetPairKerning(layout1, 0, NULL, &range);
}
hr = IDWriteTextLayout1_GetPairKerning(layout1, 0, &kerning, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
range.startPosition = 0;
range.length = 0;
kerning = TRUE;
hr = IDWriteTextLayout1_GetPairKerning(layout1, 0, &kerning, &range);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(!kerning, "got %d\n", kerning);
range.startPosition = 0;
range.length = 1;
hr = IDWriteTextLayout1_SetPairKerning(layout1, 2, range);
ok(hr == S_OK, "got 0x%08x\n", hr);
kerning = FALSE;
hr = IDWriteTextLayout1_GetPairKerning(layout1, 0, &kerning, &range);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(kerning == TRUE, "got %d\n", kerning);
IDWriteTextLayout1_Release(layout1);
}
START_TEST(layout)
{
HRESULT hr;
......@@ -1061,6 +1115,7 @@ START_TEST(layout)
test_typography();
test_GetClusterMetrics();
test_SetLocaleName();
test_SetPairKerning();
IDWriteFactory_Release(factory);
}
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