v3: Separate test for Segoe UI Symbol so that it doesn't depend on presence of the Segoe UI font. This also makes it more clear which of the tests get fixed by adding Segoe UI Symbol to the Wine tree.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/dwrite/tests/layout.c | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index c77c6ff2034..76f69892226 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -6487,6 +6487,94 @@ if (SUCCEEDED(hr)) IDWriteFactory_Release(factory); }
+#define get_font_name(a, b, c) get_font_name_(a, b, c, __LINE__) +static void get_font_name_(IDWriteFont *font, WCHAR *name, UINT32 size, int line) +{ + HRESULT hr; + IDWriteFontFamily *family; + IDWriteLocalizedStrings *names; + UINT32 index; + BOOL exists; + + hr = IDWriteFont_GetFontFamily(font, &family); + ok_(__FILE__, line)(hr == S_OK, "got %#x\n", hr); + + hr = IDWriteFontFamily_GetFamilyNames(family, &names); + ok_(__FILE__, line)(hr == S_OK, "got %#x\n", hr); + + hr = IDWriteLocalizedStrings_FindLocaleName(names, L"en-us", &index, &exists); + ok_(__FILE__, line)(hr == S_OK, "got %#x\n", hr); + ok_(__FILE__, line)(index != UINT_MAX && exists, "name was not found\n"); + hr = IDWriteLocalizedStrings_GetString(names, index, name, size); + ok_(__FILE__, line)(hr == S_OK, "got %#x\n", hr); + + IDWriteLocalizedStrings_Release(names); + IDWriteFontFamily_Release(family); +} + +static void test_SegoeUI(void) +{ + HRESULT hr; + IDWriteFactory2 *factory; + IDWriteFontCollection *collection; + IDWriteFontFamily *family; + IDWriteFont *font; + UINT32 index, count, i; + WCHAR name[256]; + BOOL exists, found; + + hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory2, (IUnknown **)&factory); + if (hr != S_OK) + { + win_skip("IDWriteFactory2 is not supported\n"); + return; + } + + hr = IDWriteFactory2_GetSystemFontCollection(factory, &collection, FALSE); + ok(hr == S_OK, "got %#x\n", hr); + + hr = IDWriteFontCollection_FindFamilyName(collection, L"Segoe UI", &index, &exists); + ok(hr == S_OK, "got %#x\n", hr); + if (!exists) + { + skip("Segoe UI is not installed\n"); + IDWriteFontCollection_Release(collection); + IDWriteFactory2_Release(factory); + return; + } + ok(index != UINT_MAX && exists, "Segoe UI was not found\n"); + + hr = IDWriteFontCollection_GetFontFamily(collection, index, &family); + ok(hr == S_OK, "got %#x\n", hr); + + count = IDWriteFontFamily_GetFontCount(family); + trace("family Segoe UI has %u fonts\n", count); + + found = FALSE; + + for (i = 0; i < count; i++) + { + hr = IDWriteFontFamily_GetFont(family, i, &font); + ok(hr == S_OK, "got %#x\n", hr); + + get_font_name(font, name, ARRAY_SIZE(name)); + if (!wcscmp(name, L"Segoe UI Symbol")) + found = TRUE; + + hr = IDWriteFont_HasCharacter(font, 0x25d4, &exists); + ok(hr == S_OK, "got %#x\n", hr); + ok(!exists, "%u: %s has character 0x25d4\n", i, wine_dbgstr_w(name)); + + IDWriteFont_Release(font); + } + + ok(!found, "Segoe UI Symbol should not be part of Segoe UI family\n"); + + IDWriteFontFamily_Release(family); + IDWriteFontCollection_Release(collection); + IDWriteFactory2_Release(factory); +} + START_TEST(layout) { IDWriteFactory *factory; @@ -6542,6 +6630,7 @@ START_TEST(layout) test_text_format_axes(); test_layout_range_length(); test_HitTestTextRange(); + test_SegoeUI();
IDWriteFactory_Release(factory); }