Commit d800cd74 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Extend matching font creation helper.

parent fcbb0f6c
......@@ -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;
......
......@@ -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;
......
......@@ -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))
......
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