dwrite: Always use system font collection to create fallback fonts.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1a92176b67
commit
5ec7a860bf
|
@ -199,6 +199,7 @@ static const struct fallback_mapping fontfallback_neutral_data[] = {
|
||||||
struct dwrite_fontfallback {
|
struct dwrite_fontfallback {
|
||||||
IDWriteFontFallback IDWriteFontFallback_iface;
|
IDWriteFontFallback IDWriteFontFallback_iface;
|
||||||
IDWriteFactory2 *factory;
|
IDWriteFactory2 *factory;
|
||||||
|
IDWriteFontCollection *systemcollection;
|
||||||
const struct fallback_mapping *mappings;
|
const struct fallback_mapping *mappings;
|
||||||
UINT32 count;
|
UINT32 count;
|
||||||
};
|
};
|
||||||
|
@ -1810,8 +1811,7 @@ static HRESULT fallback_map_characters(IDWriteFont *font, const WCHAR *text, UIN
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback, const WCHAR *text, UINT32 length,
|
static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback, const WCHAR *text, UINT32 length,
|
||||||
IDWriteFontCollection *collection, DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch,
|
DWRITE_FONT_WEIGHT weight, DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, UINT32 *mapped_length, IDWriteFont **mapped_font)
|
||||||
UINT32 *mapped_length, IDWriteFont **mapped_font)
|
|
||||||
{
|
{
|
||||||
const struct fallback_mapping *mapping;
|
const struct fallback_mapping *mapping;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -1823,7 +1823,7 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now let's see what fallback can handle */
|
/* now let's see what fallback can handle */
|
||||||
hr = create_matching_font(collection, mapping->family, weight, style, stretch, mapped_font);
|
hr = create_matching_font(fallback->systemcollection, mapping->family, weight, style, stretch, mapped_font);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
WARN("failed to create fallback font %s for range [0x%x,0x%x], 0x%08x\n", debugstr_w(mapping->family),
|
WARN("failed to create fallback font %s for range [0x%x,0x%x], 0x%08x\n", debugstr_w(mapping->family),
|
||||||
mapping->range.first, mapping->range.last, hr);
|
mapping->range.first, mapping->range.last, hr);
|
||||||
|
@ -1865,21 +1865,14 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback *iface, IDW
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
if (!basecollection) {
|
if (!basecollection)
|
||||||
hr = IDWriteFactory2_GetSystemFontCollection(fallback->factory, &basecollection, FALSE);
|
basecollection = fallback->systemcollection;
|
||||||
if (FAILED(hr))
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
IDWriteFontCollection_AddRef(basecollection);
|
|
||||||
|
|
||||||
hr = get_text_source_ptr(source, position, length, &text, &buff);
|
hr = get_text_source_ptr(source, position, length, &text, &buff);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
if (basefamily && *basefamily) {
|
if (basefamily && *basefamily) {
|
||||||
IDWriteFont *mapped_font;
|
|
||||||
|
|
||||||
hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font);
|
hr = create_matching_font(basecollection, basefamily, weight, style, stretch, ret_font);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -1887,25 +1880,27 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback *iface, IDW
|
||||||
hr = fallback_map_characters(*ret_font, text, length, mapped_length);
|
hr = fallback_map_characters(*ret_font, text, length, mapped_length);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!*mapped_length) {
|
if (!*mapped_length) {
|
||||||
hr = fallback_get_fallback_font(fallback, text, length, basecollection, weight, style, stretch, mapped_length, &mapped_font);
|
IDWriteFont *mapped_font;
|
||||||
if (FAILED(hr)) {
|
|
||||||
|
hr = fallback_get_fallback_font(fallback, text, length, weight, style, stretch, mapped_length, &mapped_font);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
/* fallback wasn't found, keep base font if any, so we can get at least some visual output */
|
||||||
|
if (*ret_font) {
|
||||||
*mapped_length = length;
|
*mapped_length = length;
|
||||||
hr = S_OK;
|
hr = S_OK;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
IDWriteFont_Release(*ret_font);
|
|
||||||
*ret_font = mapped_font;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (*ret_font)
|
||||||
|
IDWriteFont_Release(*ret_font);
|
||||||
|
*ret_font = mapped_font;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
hr = fallback_get_fallback_font(fallback, text, length, basecollection, weight, style, stretch, mapped_length, ret_font);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
IDWriteFontCollection_Release(basecollection);
|
|
||||||
heap_free(buff);
|
heap_free(buff);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -1931,6 +1926,7 @@ HRESULT create_system_fontfallback(IDWriteFactory2 *factory, IDWriteFontFallback
|
||||||
fallback->factory = factory;
|
fallback->factory = factory;
|
||||||
fallback->mappings = fontfallback_neutral_data;
|
fallback->mappings = fontfallback_neutral_data;
|
||||||
fallback->count = sizeof(fontfallback_neutral_data)/sizeof(fontfallback_neutral_data[0]);
|
fallback->count = sizeof(fontfallback_neutral_data)/sizeof(fontfallback_neutral_data[0]);
|
||||||
|
IDWriteFactory2_GetSystemFontCollection(fallback->factory, &fallback->systemcollection, FALSE);
|
||||||
|
|
||||||
*ret = &fallback->IDWriteFontFallback_iface;
|
*ret = &fallback->IDWriteFontFallback_iface;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1939,5 +1935,6 @@ HRESULT create_system_fontfallback(IDWriteFactory2 *factory, IDWriteFontFallback
|
||||||
void release_system_fontfallback(IDWriteFontFallback *iface)
|
void release_system_fontfallback(IDWriteFontFallback *iface)
|
||||||
{
|
{
|
||||||
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface);
|
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface);
|
||||||
|
IDWriteFontCollection_Release(fallback->systemcollection);
|
||||||
heap_free(fallback);
|
heap_free(fallback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4200,7 +4200,6 @@ static HRESULT WINAPI fontcollection_FindFamilyName(IDWriteFontCollection *iface
|
||||||
*exists = TRUE;
|
*exists = TRUE;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
todo_wine
|
|
||||||
ok(0, "unexpected call, name %s\n", wine_dbgstr_w(name));
|
ok(0, "unexpected call, name %s\n", wine_dbgstr_w(name));
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue