From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/dwrite/dwrite_private.h | 1 + dlls/dwrite/font.c | 14 ++++++++++++++ dlls/dwrite/gdiinterop.c | 20 ++++++++------------ dlls/dwrite/tests/font.c | 2 -- 4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h index b200ce58eb6..7fd0cdbe13f 100644 --- a/dlls/dwrite/dwrite_private.h +++ b/dlls/dwrite/dwrite_private.h @@ -365,6 +365,7 @@ extern void factory_detach_fontcollection(IDWriteFactory7 *factory, IDWriteFontC extern void factory_detach_gdiinterop(IDWriteFactory7 *factory, IDWriteGdiInterop1 *interop); extern struct fontfacecached *factory_cache_fontface(IDWriteFactory7 *factory, struct list *fontfaces, IDWriteFontFace5 *fontface); +extern IDWriteFontFile *get_fontfile_from_font(IDWriteFont *font); extern void get_logfont_from_font(IDWriteFont*,LOGFONTW*); extern void get_logfont_from_fontface(IDWriteFontFace*,LOGFONTW*); extern HRESULT get_fontsig_from_font(IDWriteFont*,FONTSIGNATURE*); diff --git a/dlls/dwrite/font.c b/dlls/dwrite/font.c index 65bf7021938..316d3eea1c7 100644 --- a/dlls/dwrite/font.c +++ b/dlls/dwrite/font.c @@ -2599,6 +2599,20 @@ static HRESULT create_font(struct dwrite_fontfamily *family, UINT32 index, IDWri return S_OK; }
+IDWriteFontFile *get_fontfile_from_font(IDWriteFont *font_iface) +{ + struct dwrite_font *font = unsafe_impl_from_IDWriteFont(font_iface); + IDWriteFontFile *file = NULL; + + if (font) + { + file = font->data->file; + IDWriteFontFile_AddRef(file); + } + + return file; +} + /* IDWriteFontList2 */ static HRESULT WINAPI dwritefontlist_QueryInterface(IDWriteFontList2 *iface, REFIID riid, void **obj) { diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 3e456a04a41..7f4b7f7689b 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -693,8 +693,8 @@ static HRESULT WINAPI gdiinterop_CreateFontFromLOGFONT(IDWriteGdiInterop1 *iface static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop1 *iface, IDWriteFont *font, LOGFONTW *logfont, BOOL *is_systemfont) { - IDWriteFontCollection *collection; - IDWriteFontFamily *family; + IDWriteFontFileLoader *loader; + IDWriteFontFile *file; HRESULT hr;
TRACE("%p, %p, %p, %p.\n", iface, font, logfont, is_systemfont); @@ -703,20 +703,16 @@ static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop1 *iface,
memset(logfont, 0, sizeof(*logfont));
- if (!font) - return E_INVALIDARG; + file = get_fontfile_from_font(font);
- hr = IDWriteFont_GetFontFamily(font, &family); - if (FAILED(hr)) - return hr; + if (!font || !file) + return E_INVALIDARG;
- hr = IDWriteFontFamily_GetFontCollection(family, &collection); - IDWriteFontFamily_Release(family); - if (FAILED(hr)) + if (FAILED(hr = IDWriteFontFile_GetLoader(file, &loader))) return hr;
- *is_systemfont = is_system_collection(collection); - IDWriteFontCollection_Release(collection); + *is_systemfont = loader == get_local_fontfile_loader(); + IDWriteFontFileLoader_Release(loader);
get_logfont_from_font(font, logfont); logfont->lfCharSet = DEFAULT_CHARSET; diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 08846e4b5a7..9d31407cf94 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -4936,7 +4936,6 @@ if (0) { /* crashes on native */ memset(&logfont, 0, sizeof(logfont)); hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, &logfont, &system); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(system, "Unexpected flag %d.\n", system);
IDWriteFont_Release(font); @@ -4971,7 +4970,6 @@ if (0) { /* crashes on native */ memset(&logfont, 0, sizeof(logfont)); hr = IDWriteGdiInterop_ConvertFontToLOGFONT(interop, font, &logfont, &system); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); - todo_wine ok(system, "Unexpected flag %d.\n", system);
IDWriteFont_Release(font);