Nikolay Sivov : dwrite: Derive some format data for text layout from specified text format.

Alexandre Julliard julliard at winehq.org
Wed Oct 24 13:39:41 CDT 2012


Module: wine
Branch: master
Commit: 2250f0e5336382bb4f344d54fe189a9c7234c878
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2250f0e5336382bb4f344d54fe189a9c7234c878

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Oct 23 08:48:17 2012 -0400

dwrite: Derive some format data for text layout from specified text format.

---

 dlls/dwrite/dwrite_private.h |    2 +-
 dlls/dwrite/layout.c         |   12 +++++++++++-
 dlls/dwrite/main.c           |    6 +++---
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index 7216393..ef50b54 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 e793e49..8567c6a 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 09ed3f2..7514492 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,




More information about the wine-cvs mailing list