diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index 7216393fe9b..ef50b547855 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -70,7 +70,7 @@ static inline LPWSTR heap_strdupnW(const WCHAR *str, UINT32 len) extern HRESULT create_font_from_logfont(const LOGFONTW*, IDWriteFont**) DECLSPEC_HIDDEN; extern HRESULT create_textformat(const WCHAR*,IDWriteFontCollection*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH, FLOAT,const WCHAR*,IDWriteTextFormat**) DECLSPEC_HIDDEN; -extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextLayout**) DECLSPEC_HIDDEN; +extern HRESULT create_textlayout(const WCHAR*,UINT32,IDWriteTextFormat*,IDWriteTextLayout**) DECLSPEC_HIDDEN; extern HRESULT create_gdiinterop(IDWriteGdiInterop**) DECLSPEC_HIDDEN; extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDEN; extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN; diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index e793e49fe83..8567c6ae4b1 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -664,7 +664,7 @@ static const IDWriteTextLayoutVtbl dwritetextlayoutvtbl = { dwritetextlayout_HitTestTextRange }; -HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextLayout **layout) +HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextFormat *format, IDWriteTextLayout **layout) { struct dwrite_textlayout *This; @@ -678,6 +678,16 @@ HRESULT create_textlayout(const WCHAR *str, UINT32 len, IDWriteTextLayout **layo This->str = heap_strdupnW(str, len); memset(&This->format, 0, sizeof(This->format)); + /* reference is not kept here, instead copy all underlying data */ + if (format) + { + IDWriteTextFormat_GetFontCollection(format, &This->format.collection); + This->format.weight = IDWriteTextFormat_GetFontWeight(format); + This->format.style = IDWriteTextFormat_GetFontStyle(format); + This->format.stretch = IDWriteTextFormat_GetFontStretch(format); + This->format.size = IDWriteTextFormat_GetFontSize(format); + } + *layout = &This->IDWriteTextLayout_iface; return S_OK; diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c index 09ed3f25e4f..7514492e964 100644 --- a/dlls/dwrite/main.c +++ b/dlls/dwrite/main.c @@ -506,10 +506,10 @@ static HRESULT WINAPI dwritefactory_GetGdiInterop(IDWriteFactory *iface, IDWrite static HRESULT WINAPI dwritefactory_CreateTextLayout(IDWriteFactory *iface, WCHAR const* string, UINT32 len, IDWriteTextFormat *format, FLOAT max_width, FLOAT max_height, IDWriteTextLayout **layout) { - FIXME("(%s %u %p %f %f %p): stub\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; - return create_textlayout(string, len, layout); + return create_textlayout(string, len, format, layout); } static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory *iface, WCHAR const* string, @@ -520,7 +520,7 @@ static HRESULT WINAPI dwritefactory_CreateGdiCompatibleTextLayout(IDWriteFactory pixels_per_dip, transform, use_gdi_natural, layout); if (!format) return E_INVALIDARG; - return create_textlayout(string, len, layout); + return create_textlayout(string, len, format, layout); } static HRESULT WINAPI dwritefactory_CreateEllipsisTrimmingSign(IDWriteFactory *iface, IDWriteTextFormat *format,