dwrite: Store maximum width/height for text layout.
This commit is contained in:
parent
d3a48ee342
commit
289043f4de
@ -81,7 +81,7 @@ extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC
|
|||||||
extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC_HIDDEN;
|
extern HRESULT convert_fontface_to_logfont(IDWriteFontFace*, LOGFONTW*) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
|
extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
|
||||||
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
|
FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,FLOAT,FLOAT,IDWriteTextLayout**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_trimmingsign(IDWriteInlineObject**) DECLSPEC_HIDDEN;
|
extern HRESULT create_trimmingsign(IDWriteInlineObject**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT get_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
|
extern HRESULT get_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
|
extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
|
||||||
|
@ -64,6 +64,8 @@ struct dwrite_textlayout {
|
|||||||
WCHAR *str;
|
WCHAR *str;
|
||||||
UINT32 len;
|
UINT32 len;
|
||||||
struct dwrite_textformat_data format;
|
struct dwrite_textformat_data format;
|
||||||
|
FLOAT maxwidth;
|
||||||
|
FLOAT maxheight;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dwrite_textformat {
|
struct dwrite_textformat {
|
||||||
@ -338,15 +340,17 @@ static HRESULT WINAPI dwritetextlayout_GetLocaleName(IDWriteTextLayout *iface, W
|
|||||||
static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout *iface, FLOAT maxWidth)
|
static HRESULT WINAPI dwritetextlayout_SetMaxWidth(IDWriteTextLayout *iface, FLOAT maxWidth)
|
||||||
{
|
{
|
||||||
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
||||||
FIXME("(%p)->(%f): stub\n", This, maxWidth);
|
TRACE("(%p)->(%.1f)\n", This, maxWidth);
|
||||||
return E_NOTIMPL;
|
This->maxwidth = maxWidth;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout *iface, FLOAT maxHeight)
|
static HRESULT WINAPI dwritetextlayout_SetMaxHeight(IDWriteTextLayout *iface, FLOAT maxHeight)
|
||||||
{
|
{
|
||||||
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
||||||
FIXME("(%p)->(%f): stub\n", This, maxHeight);
|
TRACE("(%p)->(%.1f)\n", This, maxHeight);
|
||||||
return E_NOTIMPL;
|
This->maxheight = maxHeight;
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range)
|
static HRESULT WINAPI dwritetextlayout_SetFontCollection(IDWriteTextLayout *iface, IDWriteFontCollection* collection, DWRITE_TEXT_RANGE range)
|
||||||
@ -436,15 +440,15 @@ static HRESULT WINAPI dwritetextlayout_SetLocaleName(IDWriteTextLayout *iface, W
|
|||||||
static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout *iface)
|
static FLOAT WINAPI dwritetextlayout_GetMaxWidth(IDWriteTextLayout *iface)
|
||||||
{
|
{
|
||||||
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
||||||
FIXME("(%p): stub\n", This);
|
TRACE("(%p)\n", This);
|
||||||
return 0.0;
|
return This->maxwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout *iface)
|
static FLOAT WINAPI dwritetextlayout_GetMaxHeight(IDWriteTextLayout *iface)
|
||||||
{
|
{
|
||||||
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
struct dwrite_textlayout *This = impl_from_IDWriteTextLayout(iface);
|
||||||
FIXME("(%p): stub\n", This);
|
TRACE("(%p)\n", This);
|
||||||
return 0.0;
|
return This->maxheight;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout *iface, UINT32 pos,
|
static HRESULT WINAPI dwritetextlayout_layout_GetFontCollection(IDWriteTextLayout *iface, UINT32 pos,
|
||||||
@ -750,7 +754,7 @@ static void layout_format_from_textformat(struct dwrite_textlayout *layout, IDWr
|
|||||||
IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
|
IDWriteTextFormat_GetFontCollection(format, &layout->format.collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, IDWriteTextLayout **layout)
|
HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, FLOAT maxwidth, FLOAT maxheight, IDWriteTextLayout **layout)
|
||||||
{
|
{
|
||||||
struct dwrite_textlayout *This;
|
struct dwrite_textlayout *This;
|
||||||
|
|
||||||
@ -763,6 +767,8 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *forma
|
|||||||
This->ref = 1;
|
This->ref = 1;
|
||||||
This->str = heap_strdupnW(str, len);
|
This->str = heap_strdupnW(str, len);
|
||||||
This->len = len;
|
This->len = len;
|
||||||
|
This->maxwidth = maxwidth;
|
||||||
|
This->maxheight = maxheight;
|
||||||
layout_format_from_textformat(This, format);
|
layout_format_from_textformat(This, format);
|
||||||
|
|
||||||
*layout = &This->IDWriteTextLayout_iface;
|
*layout = &This->IDWriteTextLayout_iface;
|
||||||
|
@ -510,7 +510,7 @@ static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHA
|
|||||||
TRACE("(%s %u %p %f %f %p)\n", debugstr_w(string), len, format, max_width, max_height, layout);
|
TRACE("(%s %u %p %f %f %p)\n", debugstr_w(string), len, format, max_width, max_height, layout);
|
||||||
|
|
||||||
if (!format) return E_INVALIDARG;
|
if (!format) return E_INVALIDARG;
|
||||||
return create_textlayout(string, len, format, layout);
|
return create_textlayout(string, len, format, max_width, max_height, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
|
static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string,
|
||||||
@ -521,7 +521,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory
|
|||||||
pixels_per_dip, transform, use_gdi_natural, layout);
|
pixels_per_dip, transform, use_gdi_natural, layout);
|
||||||
|
|
||||||
if (!format) return E_INVALIDARG;
|
if (!format) return E_INVALIDARG;
|
||||||
return create_textlayout(string, len, format, layout);
|
return create_textlayout(string, len, format, layout_width, layout_height, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
|
static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,
|
||||||
|
@ -65,6 +65,7 @@ static void test_CreateGdiCompatibleTextLayout(void)
|
|||||||
static const WCHAR strW[] = {'s','t','r','i','n','g',0};
|
static const WCHAR strW[] = {'s','t','r','i','n','g',0};
|
||||||
IDWriteTextLayout *layout;
|
IDWriteTextLayout *layout;
|
||||||
IDWriteTextFormat *format;
|
IDWriteTextFormat *format;
|
||||||
|
FLOAT dimension;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
|
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, NULL, 0, NULL, 0.0, 0.0, 0.0, NULL, FALSE, &layout);
|
||||||
@ -102,8 +103,14 @@ static void test_CreateGdiCompatibleTextLayout(void)
|
|||||||
/* zero length string is okay */
|
/* zero length string is okay */
|
||||||
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 0, format, 100.0, 100.0, 1.0, NULL, FALSE, &layout);
|
hr = IDWriteFactory_CreateGdiCompatibleTextLayout(factory, strW, 0, format, 100.0, 100.0, 1.0, NULL, FALSE, &layout);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
IDWriteTextLayout_Release(layout);
|
|
||||||
|
|
||||||
|
dimension = IDWriteTextLayout_GetMaxWidth(layout);
|
||||||
|
ok(dimension == 100.0, "got %f\n", dimension);
|
||||||
|
|
||||||
|
dimension = IDWriteTextLayout_GetMaxHeight(layout);
|
||||||
|
ok(dimension == 100.0, "got %f\n", dimension);
|
||||||
|
|
||||||
|
IDWriteTextLayout_Release(layout);
|
||||||
IDWriteTextFormat_Release(format);
|
IDWriteTextFormat_Release(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user