Commit 6ba2c25d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Store optical alignment property.

parent 3905ed8c
......@@ -50,6 +50,7 @@ struct dwrite_textformat_data {
DWRITE_FLOW_DIRECTION flow;
DWRITE_LINE_SPACING_METHOD spacingmethod;
DWRITE_VERTICAL_GLYPH_ORIENTATION vertical_orientation;
DWRITE_OPTICAL_ALIGNMENT optical_alignment;
FLOAT spacing;
FLOAT baseline;
......@@ -408,6 +409,15 @@ static HRESULT set_fontfallback_for_format(struct dwrite_textformat_data *format
return S_OK;
}
static HRESULT format_set_optical_alignment(struct dwrite_textformat_data *format,
DWRITE_OPTICAL_ALIGNMENT alignment)
{
if ((UINT32)alignment > DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS)
return E_INVALIDARG;
format->optical_alignment = alignment;
return S_OK;
}
static struct layout_run *alloc_layout_run(enum layout_run_kind kind)
{
struct layout_run *ret;
......@@ -3217,15 +3227,15 @@ static BOOL WINAPI dwritetextlayout2_GetLastLineWrapping(IDWriteTextLayout2 *ifa
static HRESULT WINAPI dwritetextlayout2_SetOpticalAlignment(IDWriteTextLayout2 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p)->(%d): stub\n", This, alignment);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, alignment);
return IDWriteTextFormat1_SetOpticalAlignment(&This->IDWriteTextFormat1_iface, alignment);
}
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextlayout2_GetOpticalAlignment(IDWriteTextLayout2 *iface)
{
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout2(iface);
FIXME("(%p): stub\n", This);
return DWRITE_OPTICAL_ALIGNMENT_NONE;
TRACE("(%p)\n", This);
return IDWriteTextFormat1_GetOpticalAlignment(&This->IDWriteTextFormat1_iface);
}
static HRESULT WINAPI dwritetextlayout2_SetFontFallback(IDWriteTextLayout2 *iface, IDWriteFontFallback *fallback)
......@@ -3627,15 +3637,15 @@ static BOOL WINAPI dwritetextformat1_layout_GetLastLineWrapping(IDWriteTextForma
static HRESULT WINAPI dwritetextformat1_layout_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
FIXME("(%p)->(%d): stub\n", This, alignment);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, alignment);
return format_set_optical_alignment(&This->format, alignment);
}
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_layout_GetOpticalAlignment(IDWriteTextFormat1 *iface)
{
struct dwrite_textlayout *This = impl_layout_form_IDWriteTextFormat1(iface);
FIXME("(%p): stub\n", This);
return DWRITE_OPTICAL_ALIGNMENT_NONE;
TRACE("(%p)\n", This);
return This->format.optical_alignment;
}
static HRESULT WINAPI dwritetextformat1_layout_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
......@@ -3969,11 +3979,14 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
hr = IDWriteTextFormat_QueryInterface(format, &IID_IDWriteTextFormat1, (void**)&format1);
if (hr == S_OK) {
layout->format.vertical_orientation = IDWriteTextFormat1_GetVerticalGlyphOrientation(format1);
layout->format.optical_alignment = IDWriteTextFormat1_GetOpticalAlignment(format1);
IDWriteTextFormat1_GetFontFallback(format1, &layout->format.fallback);
IDWriteTextFormat1_Release(format1);
}
else
else {
layout->format.vertical_orientation = DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT;
layout->format.optical_alignment = DWRITE_OPTICAL_ALIGNMENT_NONE;
}
return IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
}
......@@ -4563,15 +4576,15 @@ static BOOL WINAPI dwritetextformat1_GetLastLineWrapping(IDWriteTextFormat1 *ifa
static HRESULT WINAPI dwritetextformat1_SetOpticalAlignment(IDWriteTextFormat1 *iface, DWRITE_OPTICAL_ALIGNMENT alignment)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
FIXME("(%p)->(%d): stub\n", This, alignment);
return E_NOTIMPL;
TRACE("(%p)->(%d)\n", This, alignment);
return format_set_optical_alignment(&This->format, alignment);
}
static DWRITE_OPTICAL_ALIGNMENT WINAPI dwritetextformat1_GetOpticalAlignment(IDWriteTextFormat1 *iface)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat1(iface);
FIXME("(%p): stub\n", This);
return DWRITE_OPTICAL_ALIGNMENT_NONE;
TRACE("(%p)\n", This);
return This->format.optical_alignment;
}
static HRESULT WINAPI dwritetextformat1_SetFontFallback(IDWriteTextFormat1 *iface, IDWriteFontFallback *fallback)
......@@ -4654,6 +4667,7 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This->format.fontsize = size;
This->format.stretch = stretch;
This->format.textalignment = DWRITE_TEXT_ALIGNMENT_LEADING;
This->format.optical_alignment = DWRITE_OPTICAL_ALIGNMENT_NONE;
This->format.paralign = DWRITE_PARAGRAPH_ALIGNMENT_NEAR;
This->format.wrapping = DWRITE_WORD_WRAPPING_WRAP;
This->format.last_line_wrapping = TRUE;
......
......@@ -4177,6 +4177,74 @@ static void test_SetLastLineWrapping(void)
IDWriteFactory_Release(factory);
}
static void test_SetOpticalAlignment(void)
{
static const WCHAR strW[] = {'a',0};
DWRITE_OPTICAL_ALIGNMENT alignment;
IDWriteTextLayout2 *layout2;
IDWriteTextFormat1 *format1;
IDWriteTextLayout *layout;
IDWriteTextFormat *format;
IDWriteFactory *factory;
HRESULT hr;
factory = create_factory();
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 = IDWriteTextFormat_QueryInterface(format, &IID_IDWriteTextFormat1, (void**)&format1);
IDWriteTextFormat_Release(format);
if (hr != S_OK) {
win_skip("SetOpticalAlignment() is not supported\n");
IDWriteFactory_Release(factory);
return;
}
alignment = IDWriteTextFormat1_GetOpticalAlignment(format1);
ok(alignment == DWRITE_OPTICAL_ALIGNMENT_NONE, "got %d\n", alignment);
hr = IDWriteFactory_CreateTextLayout(factory, strW, 1, (IDWriteTextFormat*)format1, 1000.0, 1000.0, &layout);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextLayout_QueryInterface(layout, &IID_IDWriteTextLayout2, (void**)&layout2);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteTextLayout_Release(layout);
IDWriteTextFormat1_Release(format1);
alignment = IDWriteTextLayout2_GetOpticalAlignment(layout2);
ok(alignment == DWRITE_OPTICAL_ALIGNMENT_NONE, "got %d\n", alignment);
hr = IDWriteTextLayout2_QueryInterface(layout2, &IID_IDWriteTextFormat1, (void**)&format1);
ok(hr == S_OK, "got 0x%08x\n", hr);
alignment = IDWriteTextFormat1_GetOpticalAlignment(format1);
ok(alignment == DWRITE_OPTICAL_ALIGNMENT_NONE, "got %d\n", alignment);
hr = IDWriteTextLayout2_SetOpticalAlignment(layout2, DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextLayout2_SetOpticalAlignment(layout2, DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS+1);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
alignment = IDWriteTextFormat1_GetOpticalAlignment(format1);
ok(alignment == DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS, "got %d\n", alignment);
hr = IDWriteTextFormat1_SetOpticalAlignment(format1, DWRITE_OPTICAL_ALIGNMENT_NONE);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat1_SetOpticalAlignment(format1, DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS+1);
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
alignment = IDWriteTextLayout2_GetOpticalAlignment(layout2);
ok(alignment == DWRITE_OPTICAL_ALIGNMENT_NONE, "got %d\n", alignment);
IDWriteTextLayout2_Release(layout2);
IDWriteTextFormat1_Release(format1);
IDWriteFactory_Release(factory);
}
START_TEST(layout)
{
static const WCHAR ctrlstrW[] = {0x202a,0};
......@@ -4226,6 +4294,7 @@ START_TEST(layout)
test_FontFallbackBuilder();
test_SetTypography();
test_SetLastLineWrapping();
test_SetOpticalAlignment();
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