Nikolay Sivov : dwrite: Extend matching font creation helper.
Alexandre Julliard
julliard at winehq.org
Fri Jul 22 15:38:23 CDT 2022
Module: wine
Branch: master
Commit: d800cd7437b770f04dd4a0366e1017283272fbb6
URL: https://gitlab.winehq.org/wine/wine/-/commit/d800cd7437b770f04dd4a0366e1017283272fbb6
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Jul 18 11:57:25 2022 +0300
dwrite: Extend matching font creation helper.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/dwrite/analyzer.c | 20 ++++++++++++++------
dlls/dwrite/dwrite_private.h | 4 ++--
dlls/dwrite/layout.c | 14 ++++++--------
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/dlls/dwrite/analyzer.c b/dlls/dwrite/analyzer.c
index 3d5aca98826..0769dada355 100644
--- a/dlls/dwrite/analyzer.c
+++ b/dlls/dwrite/analyzer.c
@@ -2129,15 +2129,16 @@ static const struct fallback_mapping *find_fallback_mapping(struct dwrite_fontfa
return NULL;
}
-HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *name,
- DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, IDWriteFont **font)
+HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *name, DWRITE_FONT_WEIGHT weight,
+ DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, REFIID riid, void **obj)
{
IDWriteFontFamily *family;
BOOL exists = FALSE;
+ IDWriteFont *font;
HRESULT hr;
UINT32 i;
- *font = NULL;
+ *obj = NULL;
hr = IDWriteFontCollection_FindFamilyName(collection, name, &i, &exists);
if (FAILED(hr))
@@ -2150,8 +2151,15 @@ HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *nam
if (FAILED(hr))
return hr;
- hr = IDWriteFontFamily_GetFirstMatchingFont(family, weight, stretch, style, font);
+ hr = IDWriteFontFamily_GetFirstMatchingFont(family, weight, stretch, style, &font);
IDWriteFontFamily_Release(family);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IDWriteFont_QueryInterface(font, riid, obj);
+ IDWriteFont_Release(font);
+ }
+
return hr;
}
@@ -2200,7 +2208,7 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
/* Now let's see what fallback can handle. Pick first font that could be created. */
for (i = 0; i < mapping->families_count; i++) {
hr = create_matching_font((IDWriteFontCollection *)fallback->systemcollection, mapping->families[i],
- weight, style, stretch, mapped_font);
+ weight, style, stretch, &IID_IDWriteFont, (void **)mapped_font);
if (hr == S_OK) {
TRACE("Created fallback font using family %s.\n", debugstr_w(mapping->families[i]));
break;
@@ -2255,7 +2263,7 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback1 *iface, ID
goto done;
if (basefamily && *basefamily) {
- hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font);
+ hr = create_matching_font(basecollection, basefamily, weight, style, stretch, &IID_IDWriteFont, (void **)ret_font);
if (FAILED(hr))
goto done;
diff --git a/dlls/dwrite/dwrite_private.h b/dlls/dwrite/dwrite_private.h
index edb005b8b58..a46d5fe7d96 100644
--- a/dlls/dwrite/dwrite_private.h
+++ b/dlls/dwrite/dwrite_private.h
@@ -324,8 +324,8 @@ extern BOOL lb_is_newline_char(WCHAR) DECLSPEC_HIDDEN;
extern HRESULT create_system_fontfallback(IDWriteFactory7 *factory, IDWriteFontFallback1 **fallback) DECLSPEC_HIDDEN;
extern void release_system_fontfallback(IDWriteFontFallback1 *fallback) DECLSPEC_HIDDEN;
extern HRESULT create_fontfallback_builder(IDWriteFactory7 *factory, IDWriteFontFallbackBuilder **builder) DECLSPEC_HIDDEN;
-extern HRESULT create_matching_font(IDWriteFontCollection*,const WCHAR*,DWRITE_FONT_WEIGHT,DWRITE_FONT_STYLE,DWRITE_FONT_STRETCH,
- IDWriteFont**) DECLSPEC_HIDDEN;
+extern HRESULT create_matching_font(IDWriteFontCollection *collection, const WCHAR *family, DWRITE_FONT_WEIGHT weight,
+ DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, REFIID riid, void **obj) DECLSPEC_HIDDEN;
extern HRESULT create_fontfacereference(IDWriteFactory7 *factory, IDWriteFontFile *file, UINT32 face_index,
DWRITE_FONT_SIMULATIONS simulations, DWRITE_FONT_AXIS_VALUE const *axis_values, UINT32 axis_values_count,
IDWriteFontFaceReference1 **reference) DECLSPEC_HIDDEN;
diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c
index ba80c3f70e8..60fcb8cc71a 100644
--- a/dlls/dwrite/layout.c
+++ b/dlls/dwrite/layout.c
@@ -682,7 +682,8 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
collection = range->collection ? range->collection : sys_collection;
if (FAILED(hr = create_matching_font(collection, range->fontfamily, range->weight, range->style,
- range->stretch, &font))) {
+ range->stretch, &IID_IDWriteFont, (void **)&font)))
+ {
WARN("%s: failed to create matching font for non visual run, family %s, collection %p\n",
debugstr_rundescr(&run->descr), debugstr_w(range->fontfamily), range->collection);
break;
@@ -1828,14 +1829,11 @@ static HRESULT layout_set_dummy_line_metrics(struct dwrite_textlayout *layout, U
HRESULT hr;
range = get_layout_range_by_pos(layout, pos);
- hr = create_matching_font(range->collection,
- range->fontfamily,
- range->weight,
- range->style,
- range->stretch,
- &font);
- if (FAILED(hr))
+ if (FAILED(hr = create_matching_font(range->collection, range->fontfamily, range->weight, range->style,
+ range->stretch, &IID_IDWriteFont, (void **)&font)))
+ {
return hr;
+ }
hr = IDWriteFont_CreateFontFace(font, &fontface);
IDWriteFont_Release(font);
if (FAILED(hr))
More information about the wine-cvs
mailing list