tdf#163105 Require kashida after Seen, even before a final Yeh
Small tweak to the kashida insertion rules to restore some previous behavior. Kashida should not be inserted after a final Yeh, but should be inserted after an initial or medial Seen, even if it is followed by a final Yeh. Change-Id: I1fef2d32961c6f55006b2df456827588f62af40b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173889 Reviewed-by: Jonathan Clark <jonathan@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
@@ -37,7 +37,7 @@ void KashidaTest::testCharacteristic()
|
||||
// Characteristic tests for kashida candidate selection.
|
||||
// Uses words from sample documents.
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), GetWordKashidaPosition(u"متن"_ustr).value().nIndex);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"فارسی"_ustr).value().nIndex);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), GetWordKashidaPosition(u"فارسی"_ustr).value().nIndex);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"با"_ustr).value().nIndex);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(3), GetWordKashidaPosition(u"نویسه"_ustr).value().nIndex);
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), GetWordKashidaPosition(u"کشیده"_ustr).value().nIndex);
|
||||
@@ -58,7 +58,9 @@ void KashidaTest::testCharacteristic()
|
||||
void KashidaTest::testFinalYeh()
|
||||
{
|
||||
CPPUNIT_ASSERT(!GetWordKashidaPosition(u"نیمِي"_ustr).has_value());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetWordKashidaPosition(u"كرسي"_ustr).value().nIndex);
|
||||
|
||||
// Should always insert kashida after Seen, even before a final Yeh
|
||||
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), GetWordKashidaPosition(u"كرسي"_ustr).value().nIndex);
|
||||
}
|
||||
|
||||
// #i98410#: Do not insert kashida under a ZWNJ
|
||||
|
@@ -44,7 +44,8 @@ namespace
|
||||
/*
|
||||
The LibreOffice implementation modifies the above rules, as follows:
|
||||
|
||||
- tdf#65344: Kashida must not be inserted before the final form of Yeh.
|
||||
- tdf#65344: Kashida must not be inserted before the final form of Yeh, unless
|
||||
preceded by an initial or medial Seen.
|
||||
*/
|
||||
|
||||
#define IS_JOINING_GROUP(c, g) (u_getIntPropertyValue((c), UCHAR_JOINING_GROUP) == U_JG_##g)
|
||||
@@ -152,7 +153,7 @@ std::optional<i18nutil::KashidaPosition> i18nutil::GetWordKashidaPosition(const
|
||||
}
|
||||
|
||||
auto fnTryInsertBefore = [&rWord, &nIdx, &nPrevIdx, &nKashidaPos, &nPriorityLevel,
|
||||
&nWordLen](sal_Int32 nNewPriority) {
|
||||
&nWordLen](sal_Int32 nNewPriority, bool bIgnoreFinalYeh = false) {
|
||||
// Exclusions:
|
||||
|
||||
// #i98410#: prevent ZWNJ expansion
|
||||
@@ -162,7 +163,7 @@ std::optional<i18nutil::KashidaPosition> i18nutil::GetWordKashidaPosition(const
|
||||
}
|
||||
|
||||
// tdf#65344: Do not insert kashida before a final Yeh
|
||||
if (nIdx == (nWordLen - 1) && isYehChar(rWord[nIdx]))
|
||||
if (!bIgnoreFinalYeh && nIdx == (nWordLen - 1) && isYehChar(rWord[nIdx]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -190,7 +191,7 @@ std::optional<i18nutil::KashidaPosition> i18nutil::GetWordKashidaPosition(const
|
||||
{
|
||||
if (isSeenOrSadChar(cPrevCh))
|
||||
{
|
||||
fnTryInsertBefore(1);
|
||||
fnTryInsertBefore(1, /*bIgnoreFinalYeh*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user