dwrite: Added GetTrimming()/SetTrimming() for text format.

This commit is contained in:
Nikolay Sivov 2014-04-08 07:42:06 +04:00 committed by Alexandre Julliard
parent 0c97026ade
commit 6b560c92fc
2 changed files with 43 additions and 4 deletions

View File

@ -53,6 +53,9 @@ struct dwrite_textformat_data {
FLOAT baseline;
FLOAT size;
DWRITE_TRIMMING trimming;
IDWriteInlineObject *trimmingsign;
IDWriteFontCollection *collection;
};
@ -76,6 +79,7 @@ static const IDWriteTextFormatVtbl dwritetextformatvtbl;
static void release_format_data(struct dwrite_textformat_data *data)
{
if (data->collection) IDWriteFontCollection_Release(data->collection);
if (data->trimmingsign) IDWriteInlineObject_Release(data->trimmingsign);
heap_free(data->family_name);
heap_free(data->locale);
}
@ -699,6 +703,8 @@ static void layout_format_from_textformat(struct dwrite_textlayout *layout, IDWr
layout->format = f->format;
layout->format.locale = heap_strdupW(f->format.locale);
layout->format.family_name = heap_strdupW(f->format.family_name);
if (layout->format.trimmingsign)
IDWriteInlineObject_AddRef(layout->format.trimmingsign);
}
else
{
@ -718,6 +724,7 @@ static void layout_format_from_textformat(struct dwrite_textlayout *layout, IDWr
&layout->format.spacing,
&layout->format.baseline
);
IDWriteTextFormat_GetTrimming(format, &layout->format.trimming, &layout->format.trimmingsign);
/* locale name and length */
locale_len = IDWriteTextFormat_GetLocaleNameLength(format);
@ -849,8 +856,15 @@ static HRESULT WINAPI dwritetextformat_SetTrimming(IDWriteTextFormat *iface, DWR
IDWriteInlineObject *trimming_sign)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
FIXME("(%p)->(%p %p): stub\n", This, trimming, trimming_sign);
return E_NOTIMPL;
TRACE("(%p)->(%p %p)\n", This, trimming, trimming_sign);
This->format.trimming = *trimming;
if (This->format.trimmingsign)
IDWriteInlineObject_Release(This->format.trimmingsign);
This->format.trimmingsign = trimming_sign;
if (This->format.trimmingsign)
IDWriteInlineObject_AddRef(This->format.trimmingsign);
return S_OK;
}
static HRESULT WINAPI dwritetextformat_SetLineSpacing(IDWriteTextFormat *iface, DWRITE_LINE_SPACING_METHOD method,
@ -910,8 +924,13 @@ static HRESULT WINAPI dwritetextformat_GetTrimming(IDWriteTextFormat *iface, DWR
IDWriteInlineObject **trimming_sign)
{
struct dwrite_textformat *This = impl_from_IDWriteTextFormat(iface);
FIXME("(%p)->(%p %p): stub\n", This, options, trimming_sign);
return E_NOTIMPL;
TRACE("(%p)->(%p %p)\n", This, options, trimming_sign);
*options = This->format.trimming;
if ((*trimming_sign = This->format.trimmingsign))
IDWriteInlineObject_AddRef(*trimming_sign);
return S_OK;
}
static HRESULT WINAPI dwritetextformat_GetLineSpacing(IDWriteTextFormat *iface, DWRITE_LINE_SPACING_METHOD *method,
@ -1061,6 +1080,10 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This->format.spacingmethod = DWRITE_LINE_SPACING_METHOD_DEFAULT;
This->format.spacing = 0.0;
This->format.baseline = 0.0;
This->format.trimming.granularity = DWRITE_TRIMMING_GRANULARITY_NONE;
This->format.trimming.delimiter = 0;
This->format.trimming.delimiterCount = 0;
This->format.trimmingsign = NULL;
if (collection)
{

View File

@ -116,8 +116,10 @@ static void test_CreateTextFormat(void)
DWRITE_TEXT_ALIGNMENT align;
DWRITE_FLOW_DIRECTION flow;
DWRITE_LINE_SPACING_METHOD method;
DWRITE_TRIMMING trimming;
IDWriteTextFormat *format;
FLOAT spacing, baseline;
IDWriteInlineObject *trimmingsign;
HRESULT hr;
hr = IDWriteFactory_CreateTextFormat(factory, tahomaW, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
@ -160,6 +162,17 @@ if (0) /* crashes on native */
ok(baseline == 0.0, "got %f\n", baseline);
ok(method == DWRITE_LINE_SPACING_METHOD_DEFAULT, "got %d\n", method);
trimming.granularity = DWRITE_TRIMMING_GRANULARITY_WORD;
trimming.delimiter = 10;
trimming.delimiterCount = 10;
trimmingsign = (void*)0xdeadbeef;
hr = IDWriteTextFormat_GetTrimming(format, &trimming, &trimmingsign);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(trimming.granularity == DWRITE_TRIMMING_GRANULARITY_NONE, "got %d\n", trimming.granularity);
ok(trimming.delimiter == 0, "got %d\n", trimming.delimiter);
ok(trimming.delimiterCount == 0, "got %d\n", trimming.delimiterCount);
ok(trimmingsign == NULL, "got %p\n", trimmingsign);
/* setters */
hr = IDWriteTextFormat_SetTextAlignment(format, DWRITE_TEXT_ALIGNMENT_LEADING);
ok(hr == S_OK, "got 0x%08x\n", hr);
@ -179,6 +192,9 @@ if (0) /* crashes on native */
hr = IDWriteTextFormat_SetLineSpacing(format, DWRITE_LINE_SPACING_METHOD_DEFAULT, 0.0, 0.0);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDWriteTextFormat_SetTrimming(format, &trimming, NULL);
ok(hr == S_OK, "got 0x%08x\n", hr);
IDWriteTextFormat_Release(format);
}