Commit 26e717c5 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Remove old system fallback logic.

parent d37eb0f1
......@@ -323,6 +323,7 @@ extern HRESULT create_colorglyphenum(D2D1_POINT_2F origin, const DWRITE_GLYPH_RU
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 void release_system_fallback_data(void) DECLSPEC_HIDDEN;
extern HRESULT create_fontfallback_builder(IDWriteFactory7 *factory, IDWriteFontFallbackBuilder **builder) 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;
......
......@@ -643,7 +643,7 @@ static HRESULT layout_itemize(struct dwrite_textlayout *layout)
static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
{
IDWriteFontCollection *sys_collection;
IDWriteFontCollection *sys_collection, *collection;
IDWriteFontFallback *fallback = NULL;
struct layout_range *range;
struct layout_run *r;
......@@ -675,12 +675,10 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
continue;
range = get_layout_range_by_pos(layout, run->descr.textPosition);
collection = range->collection ? range->collection : sys_collection;
if (run->sa.shapes == DWRITE_SCRIPT_SHAPES_NO_VISUAL) {
IDWriteFontCollection *collection;
collection = range->collection ? range->collection : sys_collection;
if (run->sa.shapes == DWRITE_SCRIPT_SHAPES_NO_VISUAL)
{
if (FAILED(hr = create_matching_font(collection, range->fontfamily, range->weight, range->style,
range->stretch, &IID_IDWriteFont, (void **)&font)))
{
......@@ -702,8 +700,9 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
length = run->descr.stringLength;
while (length) {
UINT32 mapped_length;
while (length)
{
UINT32 mapped_length = 0;
FLOAT scale;
run = &r->u.regular;
......@@ -726,6 +725,21 @@ static HRESULT layout_resolve_fonts(struct dwrite_textlayout *layout)
goto fatal;
}
if (!mapped_length)
{
if (FAILED(create_matching_font(range->collection, range->fontfamily, range->weight, range->style,
range->stretch, &IID_IDWriteFont3, (void **)&font)))
{
if (FAILED(hr = create_matching_font(sys_collection, L"Tahoma", range->weight, range->style,
range->stretch, &IID_IDWriteFont3, (void **)&font)))
{
WARN("Failed to create last resort font, hr %#lx.\n", hr);
goto fatal;
}
}
mapped_length = run->descr.stringLength;
}
hr = IDWriteFont_CreateFontFace(font, &run->run.fontFace);
IDWriteFont_Release(font);
if (FAILED(hr)) {
......
......@@ -55,6 +55,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
case DLL_PROCESS_DETACH:
if (reserved) break;
release_shared_factory(shared_factory);
release_system_fallback_data();
if (unixlib_handle) UNIX_CALL(process_detach, NULL);
}
return TRUE;
......
......@@ -2672,9 +2672,9 @@ if (0) { /* crashes on native */
count = 0;
hr = IDWriteTextLayout1_GetClusterMetrics(layout1, clusters, 4, &count);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(count == 3, "Unexpected cluster count %u.\n", count);
todo_wine ok(count == 3, "Unexpected cluster count %u.\n", count);
ok(clusters[0].length == 1, "got %u\n", clusters[0].length);
ok(clusters[1].length == 2, "got %u\n", clusters[1].length);
todo_wine ok(clusters[1].length == 2, "got %u\n", clusters[1].length);
ok(clusters[2].length == 1, "got %u\n", clusters[2].length);
/* pair kerning flag participates in itemization - combining characters
......@@ -4639,10 +4639,9 @@ static void test_MapCharacters(void)
font = NULL;
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 1, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(mappedlength == 1, "got %u\n", mappedlength);
}
ok(scale == 1.0f, "got %f\n", scale);
todo_wine
ok(font != NULL, "got %p\n", font);
......@@ -4656,10 +4655,10 @@ if (font) {
font = NULL;
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(mappedlength == 3, "got %u\n", mappedlength);
}
ok(scale == 1.0f, "got %f\n", scale);
todo_wine
ok(font != NULL, "got %p\n", font);
......@@ -4673,10 +4672,9 @@ if (font) {
font = NULL;
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 3, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(mappedlength == 1, "got %u\n", mappedlength);
}
ok(scale == 1.0f, "got %f\n", scale);
todo_wine
ok(font != NULL, "got %p\n", font);
......@@ -4689,10 +4687,9 @@ if (font) {
font = NULL;
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 1, 2, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &mappedlength, &font, &scale);
todo_wine {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(mappedlength == 1, "got %u\n", mappedlength);
}
ok(scale == 1.0f, "got %f\n", scale);
todo_wine
ok(font != NULL, "got %p\n", font);
......@@ -4731,17 +4728,21 @@ if (font) {
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(mappedlength == 1, "got %u\n", mappedlength);
ok(scale == 1.0f, "got %f\n", scale);
todo_wine
ok(font != NULL, "got %p\n", font);
exists = FALSE;
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
ok(hr == S_OK && exists, "Unexpected hr %#lx, exists %d.\n", hr, exists);
hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW));
IDWriteLocalizedStrings_Release(strings);
IDWriteFont_Release(font);
if (font)
{
exists = FALSE;
hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &strings, &exists);
ok(hr == S_OK && exists, "Unexpected hr %#lx, exists %d.\n", hr, exists);
hr = IDWriteLocalizedStrings_GetString(strings, 0, buffW, ARRAY_SIZE(buffW));
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
todo_wine
ok(lstrcmpW(buffW, L"Tahoma"), "Unexpected string %s.\n", wine_dbgstr_w(buffW));
IDWriteLocalizedStrings_Release(strings);
IDWriteFont_Release(font);
}
IDWriteFontFallback_Release(fallback);
IDWriteFactory2_Release(factory2);
......@@ -4802,14 +4803,17 @@ static void test_system_fallback(void)
for (i = 0; i < ARRAY_SIZE(tests); ++i)
{
font = NULL;
g_source = tests[i].text;
hr = IDWriteFontFallback_MapCharacters(fallback, &analysissource, 0, 1, NULL, NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, &length, &font, &scale);
todo_wine
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
if (hr != S_OK) continue;
todo_wine
ok(length == 1, "Unexpected length %u\n", length);
ok(scale == 1.0f, "got %f\n", scale);
if (!font) continue;
get_font_name(font, name, ARRAY_SIZE(name));
todo_wine
......@@ -5054,21 +5058,17 @@ static void test_fallback(void)
count = 0;
hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, 4, &count);
todo_wine {
ok(hr == S_OK, "Failed to get cluster metrics, hr %#lx.\n", hr);
ok(count == 4, "Unexpected count %u.\n", count);
}
for (i = 0, width = 0.0; i < count; i++)
width += clusters[i].width;
memset(&metrics, 0xcc, sizeof(metrics));
hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
ok(hr == S_OK, "Failed to get layout metrics, hr %#lx.\n", hr);
todo_wine {
ok(metrics.width > 0.0 && metrics.width == width, "Unexpected width %.2f, expected %.2f.\n", metrics.width, width);
ok(metrics.height > 0.0, "Unexpected height %.2f.\n", metrics.height);
ok(metrics.lineCount == 1, "Unexpected line count %u.\n", metrics.lineCount);
}
IDWriteTextLayout_Release(layout);
IDWriteTextFormat_Release(format);
......@@ -5367,6 +5367,7 @@ static void test_SetUnderline(void)
count = 0;
hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, ARRAY_SIZE(clusters), &count);
ok(hr == S_OK, "Failed to get cluster metrics, hr %#lx.\n", hr);
todo_wine
ok(count == 3, "Unexpected cluster count %u.\n", count);
range.startPosition = 0;
......@@ -5377,6 +5378,7 @@ static void test_SetUnderline(void)
count = 0;
hr = IDWriteTextLayout_GetClusterMetrics(layout, clusters, ARRAY_SIZE(clusters), &count);
ok(hr == S_OK, "Failed to get cluster metrics, hr %#lx.\n", hr);
todo_wine
ok(count == 3, "Unexpected cluster count %u.\n", count);
flush_sequence(sequences, RENDERER_ID);
......
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