From b9cfb927ec1333b20dc8af620a656530efae7a80 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Wed, 3 Sep 2014 07:26:52 -0500 Subject: [PATCH] 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 e78210419e6..00353b71ea0 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; } -- 2.11.4.GIT