Aric Stewart : dwrite: Break out basic IDWriteFont creation from requiring a logfont.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Sep 3 15:09:21 CDT 2014


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

Author: Aric Stewart <aric at codeweavers.com>
Date:   Wed Sep  3 07:26:52 2014 -0500

dwrite: Break out basic IDWriteFont creation from requiring a logfont.

---

 dlls/dwrite/font.c | 46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c
index e782104..00353b7 100644
--- a/dlls/dwrite/font.c
+++ b/dlls/dwrite/font.c
@@ -208,6 +208,7 @@ struct dwrite_fontfile {
 };
 
 static HRESULT create_fontfamily(const WCHAR *familyname, IDWriteFontFamily **family);
+static HRESULT create_font_base(IDWriteFont **font);
 
 static inline struct dwrite_fontface *impl_from_IDWriteFontFace(IDWriteFontFace *iface)
 {
@@ -1120,17 +1121,9 @@ static void get_font_properties(struct dwrite_font *font, HDC hdc)
     }
 }
 
-HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
+static HRESULT create_font_base(IDWriteFont **font)
 {
-    const WCHAR* facename, *familyname;
     struct dwrite_font *This;
-    IDWriteFontFamily *family;
-    OUTLINETEXTMETRICW *otm;
-    HRESULT hr;
-    HFONT hfont;
-    HDC hdc;
-    int ret;
-
     *font = NULL;
 
     This = heap_alloc(sizeof(struct dwrite_font));
@@ -1142,6 +1135,35 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
         return E_OUTOFMEMORY;
     }
 
+    This->IDWriteFont_iface.lpVtbl = &dwritefontvtbl;
+    This->ref = 1;
+    This->data->face_data = NULL;
+    This->face = NULL;
+    This->family = NULL;
+    This->is_system = FALSE;
+
+    *font = &This->IDWriteFont_iface;
+
+    return S_OK;
+}
+
+HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
+{
+    const WCHAR* facename, *familyname;
+    struct dwrite_font *This;
+    IDWriteFontFamily *family;
+    OUTLINETEXTMETRICW *otm;
+    HRESULT hr;
+    HFONT hfont;
+    HDC hdc;
+    int ret;
+
+    hr = create_font_base(font);
+    if (FAILED(hr))
+        return hr;
+
+    This = impl_from_IDWriteFont(*font);
+
     hfont = CreateFontIndirectW(logfont);
     if (!hfont)
     {
@@ -1184,17 +1206,11 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
         return hr;
     }
 
-    This->IDWriteFont_iface.lpVtbl = &dwritefontvtbl;
-    This->ref = 1;
-    This->face = NULL;
     This->is_system = TRUE;
     This->family = family;
     This->data->simulations = DWRITE_FONT_SIMULATIONS_NONE;
     This->data->style = logfont->lfItalic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;
     This->data->facename = heap_strdupW(logfont->lfFaceName);
-    This->data->face_data = NULL;
-
-    *font = &This->IDWriteFont_iface;
 
     return S_OK;
 }




More information about the wine-cvs mailing list