Commit b9cfb927 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

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

parent 2ec9fbb2
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment