Dmitry Timoshkov : dwrite/tests: Add some fallback tests for Segoe UI Symbol.

Alexandre Julliard julliard at winehq.org
Tue Apr 5 15:39:44 CDT 2022


Module: wine
Branch: master
Commit: a90d976bb45e26cc64bcb1a4304a6dc7a1ad0571
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a90d976bb45e26cc64bcb1a4304a6dc7a1ad0571

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Apr  5 08:38:22 2022 +0300

dwrite/tests: Add some fallback tests for Segoe UI Symbol.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dwrite/tests/layout.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c
index c77c6ff2034..43b6efa107b 100644
--- a/dlls/dwrite/tests/layout.c
+++ b/dlls/dwrite/tests/layout.c
@@ -4747,6 +4747,86 @@ if (font) {
     IDWriteFactory2_Release(factory2);
 }
 
+static void get_font_name(IDWriteFont *font, WCHAR *name, UINT32 size)
+{
+    IDWriteLocalizedStrings *names;
+    IDWriteFontFamily *family;
+    UINT32 index;
+    BOOL exists;
+    HRESULT hr;
+
+    hr = IDWriteFont_GetFontFamily(font, &family);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+    hr = IDWriteFontFamily_GetFamilyNames(family, &names);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+    hr = IDWriteLocalizedStrings_FindLocaleName(names, L"en-us", &index, &exists);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+    ok(index != UINT_MAX && exists, "Name was not found.\n");
+    hr = IDWriteLocalizedStrings_GetString(names, index, name, size);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+    IDWriteLocalizedStrings_Release(names);
+    IDWriteFontFamily_Release(family);
+}
+
+static void test_system_fallback(void)
+{
+    static const struct fallback_test
+    {
+        const WCHAR text[2];
+        const WCHAR *name;
+    }
+    tests[] =
+    {
+        { { 0x25d4, 0}, L"Segoe UI Symbol" },
+    };
+    IDWriteFontFallback *fallback;
+    IDWriteFactory2 *factory;
+    IDWriteFont *font;
+    UINT32 i, length;
+    WCHAR name[256];
+    BOOL exists;
+    float scale;
+    HRESULT hr;
+
+    if (!(factory = create_factory_iid(&IID_IDWriteFactory2)))
+    {
+        win_skip("System font fallback API is not supported.\n");
+        return;
+    }
+
+    hr = IDWriteFactory2_GetSystemFontFallback(factory, &fallback);
+    ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+
+    for (i = 0; i < ARRAY_SIZE(tests); ++i)
+    {
+        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;
+        ok(length == 1, "Unexpected length %u\n", length);
+        ok(scale == 1.0f, "got %f\n", scale);
+
+        get_font_name(font, name, ARRAY_SIZE(name));
+    todo_wine
+        ok(!wcscmp(name, tests[i].name), "%u: unexpected name %s.\n", i, wine_dbgstr_w(name));
+
+        hr = IDWriteFont_HasCharacter(font, g_source[0], &exists);
+        ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
+    todo_wine
+        ok(exists, "%s missing character %#x\n", wine_dbgstr_w(name), g_source[0]);
+
+        IDWriteFont_Release(font);
+    }
+
+    IDWriteFontFallback_Release(fallback);
+    IDWriteFactory2_Release(factory);
+}
+
 static void test_FontFallbackBuilder(void)
 {
     IDWriteFontFallback *fallback, *fallback2;
@@ -6529,6 +6609,7 @@ START_TEST(layout)
     test_pixelsnapping();
     test_SetWordWrapping();
     test_MapCharacters();
+    test_system_fallback();
     test_FontFallbackBuilder();
     test_SetTypography();
     test_SetLastLineWrapping();




More information about the wine-cvs mailing list