summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit
diff options
context:
space:
mode:
authorJonathan Clark <jonathan@libreoffice.org>2024-10-18 06:12:39 -0600
committerJonathan Clark <jonathan@libreoffice.org>2024-10-18 21:49:03 +0200
commit224fae69b224d28a1664c48117e77265ed67a136 (patch)
tree57e66f932aac2cadcf95804f0d293e38c6597f9d /vcl/qa/cppunit
parent3cc367f426506e3165dda06feeb20e0a9b4c6194 (diff)
tdf#163215: Enable kashida justification for AAT fonts
Currently, we use HarfBuzz-provided kashida insertion position information to decide on positions to insert kashida. This data is used both while ranking kashida insertion positions, and to avoid inserting kashida in positions that would break shaping on a per-font basis. Unfortunately, HarfBuzz cannot validate kashida insertion positions for AAT fonts. As a result, kashida were previously not inserted for text using AAT fonts. This change updates kashida justification to skip validation against HarfBuzz when AAT fonts are used. Change-Id: If0d31512b1db0f1f8155963f9b1031eb01bacc45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175165 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'vcl/qa/cppunit')
-rw-r--r--vcl/qa/cppunit/complextext.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 62b8ac2777dc..a3d033e7adba 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -697,4 +697,55 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testPartialArabicComposition)
CPPUNIT_ASSERT_DOUBLES_EQUAL(nCompleteWidth, nPartialWidth, /*delta*/ 0.01);
}
+CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf163215)
+{
+ OUString aStr = u"ببببب"_ustr;
+ vcl::Font aFont(u"DejaVu Sans"_ustr, u"Book"_ustr, Size(0, 2048));
+
+ ScopedVclPtrInstance<VirtualDevice> pOutDev;
+ pOutDev->SetFont(aFont);
+
+ // Characteristic case with kashida position validation
+ auto pLayout1 = pOutDev->ImplLayout(aStr, 0, aStr.getLength(), Point(), 0, {}, {},
+ SalLayoutFlags::GlyphItemsOnly);
+ CPPUNIT_ASSERT(pLayout1->HasFontKashidaPositions());
+
+ SalLayoutGlyphs aGlyphs1 = pLayout1->GetGlyphs();
+
+ std::vector<bool> aFoundPositions1;
+ for (const auto& stGlyph : *aGlyphs1.Impl(0))
+ {
+ aFoundPositions1.push_back(stGlyph.IsSafeToInsertKashida());
+ }
+
+ CPPUNIT_ASSERT_EQUAL(size_t(5), aFoundPositions1.size());
+ CPPUNIT_ASSERT(aFoundPositions1.at(0));
+ CPPUNIT_ASSERT(aFoundPositions1.at(1));
+ CPPUNIT_ASSERT(aFoundPositions1.at(2));
+ CPPUNIT_ASSERT(aFoundPositions1.at(3));
+ CPPUNIT_ASSERT(!aFoundPositions1.at(4));
+
+ // Case with kashida position validation disabled
+ auto pLayout2 = pOutDev->ImplLayout(aStr, 0, aStr.getLength(), Point(), 0, {}, {},
+ SalLayoutFlags::GlyphItemsOnly
+ | SalLayoutFlags::DisableKashidaValidation);
+ CPPUNIT_ASSERT(!pLayout2->HasFontKashidaPositions());
+
+ SalLayoutGlyphs aGlyphs2 = pLayout2->GetGlyphs();
+
+ std::vector<bool> aFoundPositions2;
+ for (const auto& stGlyph : *aGlyphs2.Impl(0))
+ {
+ aFoundPositions2.push_back(stGlyph.IsSafeToInsertKashida());
+ }
+
+ // With position validation disabled, all positions must be marked as valid
+ CPPUNIT_ASSERT_EQUAL(size_t(5), aFoundPositions2.size());
+ CPPUNIT_ASSERT(aFoundPositions2.at(0));
+ CPPUNIT_ASSERT(aFoundPositions2.at(1));
+ CPPUNIT_ASSERT(aFoundPositions2.at(2));
+ CPPUNIT_ASSERT(aFoundPositions2.at(3));
+ CPPUNIT_ASSERT(aFoundPositions2.at(4));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */