summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-07-30 07:12:53 +0300
committerخالد حسني <khaled@libreoffice.org>2023-07-30 09:50:11 +0200
commitd4653fa961b1aa1cd4bf568e7d1fe50ae97df484 (patch)
treea18a52cd123a3782263d2630c50e79169fa07fbe /vcl/qa
parent49fc6598426fb4552904c66702cddc6534124227 (diff)
tdf#107612: Include NNBSP and Mongolian characters in the same fallback run
When a Mongolian character is preceded by a Narrow No Break Space (NNBSP), it is used to trigger special letter forms, but when we do font fallback NNBSP is always taken from the main font (HarfBuzz synthesises it when missing from the font, so we almost never use font fallback for it). We now check if the start of the fallback run is a Mongolian character and the previous is NNBSP and extend the fallback run to include it. Change-Id: I7607dba37ee51ff62bc9e86c3dbc555cd77e8d5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155060 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/complextext.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index bcb0c9622361..ec6ce0ccd0e2 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -540,4 +540,37 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718)
#endif
}
+CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107612)
+{
+#if HAVE_MORE_FONTS
+ vcl::Font aFont(u"DejaVu Sans", u"Book", Size(0, 72));
+
+ ScopedVclPtrInstance<VirtualDevice> pOutDev;
+ pOutDev->SetFont(aFont);
+
+ auto pLayout = pOutDev->ImplLayout(u"a\u202F\u1823", 0, -1, Point(0, 0), 0, {}, {});
+
+ // If font fallback happened, then the returned layout must be a
+ // MultiSalLayout instance.
+ auto pMultiLayout = dynamic_cast<MultiSalLayout*>(pLayout.get());
+ CPPUNIT_ASSERT(pMultiLayout);
+
+ auto pFallbackRuns = pMultiLayout->GetFallbackRuns();
+ CPPUNIT_ASSERT(!pFallbackRuns->IsEmpty());
+
+ bool bRTL;
+ int nCharPos = -1;
+ std::vector<sal_Int32> aFallbacks;
+ while (pFallbackRuns->GetNextPos(&nCharPos, &bRTL))
+ aFallbacks.push_back(nCharPos);
+
+ // Assert that U+202F is included in the fallback run.
+ // Without the fix this fails with:
+ // - Expected: { 2 }
+ // - Actual : { 1, 2 }
+ std::vector<sal_Int32> aExpctedFallbacks = { 1, 2 };
+ CPPUNIT_ASSERT_EQUAL(aFallbacks, aExpctedFallbacks);
+#endif
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */