vcl/qa/unx/generic/generic.cxx |   32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

New commits:
commit bc88302e1bdb9cfc103e72f93f4aaa98512ea141
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Jul 28 16:17:04 2024 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Jan 7 15:22:29 2025 +0100

    Related: tdf#162072 compare fallback to what "serif" resolves to
    
    instead of assuming that the resolved serif font will have
    serif in its name.
    
    Change-Id: I3f85e2a8abd1dbf851debec9196e55d5c2da4e66
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171144
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    (cherry picked from commit d01dcab81a6a66fd5b4448ccff348f69c82c538d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179887
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/vcl/qa/unx/generic/generic.cxx b/vcl/qa/unx/generic/generic.cxx
index 8b79d99e510a..22176c28633c 100644
--- a/vcl/qa/unx/generic/generic.cxx
+++ b/vcl/qa/unx/generic/generic.cxx
@@ -30,32 +30,40 @@ public:
         : UnoApiTest(u"/vcl/qa/unx/generic/data/"_ustr)
     {
     }
+    static OUString GetFallbackFont(const vcl::Font& rFont)
+    {
+        Size aSize(0, 3840);
+        float fExactHeight = 3840;
+        bool bNonAntialias = false;
+        vcl::font::FontSelectPattern aPattern(rFont, rFont.GetFamilyName(), 
aSize, fExactHeight,
+                                              bNonAntialias);
+        aPattern.maTargetName = rFont.GetFamilyName();
+        psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+        OUString aMissingCodes;
+
+        rMgr.Substitute(aPattern, aMissingCodes);
+
+        return aPattern.maSearchName;
+    }
 };
 
 CPPUNIT_TEST_FIXTURE(Test, testFontFallbackSerif)
 {
+    OUString sResolvedSerif = GetFallbackFont(vcl::Font("serif", Size(12, 
12)));
+
     // Given a font select pattern with a font name we don't bundle and with a 
serif family:
     vcl::Font aFont;
     aFont.SetFamilyName("IBM Plex Serif");
     aFont.SetFamily(FAMILY_ROMAN);
-    Size aSize(0, 3840);
-    float fExactHeight = 3840;
-    bool bNonAntialias = false;
-    vcl::font::FontSelectPattern aPattern(aFont, aFont.GetFamilyName(), aSize, 
fExactHeight,
-                                          bNonAntialias);
-    aPattern.maTargetName = aFont.GetFamilyName();
-    psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
-    OUString aMissingCodes;
-
-    // When substituting that font:
-    rMgr.Substitute(aPattern, aMissingCodes);
+
+    OUString sPlexFallback = GetFallbackFont(aFont);
 
     // Then make sure we get a serif fallback:
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: Noto Serif (or DejaVu Serif)
     // - Actual  : Noto Kufi Arabic
     // i.e. we got a sans fallback for a serif pattern, which is clearly poor.
-    CPPUNIT_ASSERT(aPattern.maSearchName.endsWith(u"Serif"));
+    CPPUNIT_ASSERT_EQUAL(sResolvedSerif, sPlexFallback);
 }
 
 CPPUNIT_TEST_FIXTURE(Test, testFontFallbackCaching)

Reply via email to