Commit d1126826 authored by Albert Astals Cid's avatar Albert Astals Cid

Make search work on documents that describe Å as A + ◌̊

BUGS: 430243
parent 3e86c9a5
Pipeline #44934 passed with stage
in 32 minutes and 43 seconds
......@@ -44,6 +44,7 @@ private slots:
void test311232();
void test323262();
void test323263();
void test430243();
void testDottedI();
void testHyphenAtEndOfLineWithoutYOverlap();
void testHyphenWithYOverlap();
......@@ -222,6 +223,28 @@ void SearchTest::test323263()
delete page;
}
void SearchTest::test430243()
{
// 778 is COMBINING RING ABOVE
// 197 is LATIN CAPITAL LETTER A WITH RING ABOVE
QVector<QString> text;
text << QStringLiteral("A") << QString(QChar(778));
QVector<Okular::NormalizedRect> rect;
rect << Okular::NormalizedRect(0, 0, 1, 1) << Okular::NormalizedRect(1, 0, 2, 1);
CREATE_PAGE;
Okular::RegularAreaRect *result = tp->findText(0, QString(QChar(197)), Okular::FromTop, Qt::CaseSensitive, nullptr);
QVERIFY(result);
Okular::RegularAreaRect expected;
expected.append(rect[0] | rect[1]);
QCOMPARE(*result, expected);
delete result;
delete page;
}
void SearchTest::testDottedI()
{
// Earlier versions of okular had the bug that the letter "İ" (capital dotter i) did not match itself
......
......@@ -245,8 +245,23 @@ TextPage::~TextPage()
void TextPage::append(const QString &text, NormalizedRect *area)
{
if (!text.isEmpty())
if (!text.isEmpty()) {
if (!d->m_words.isEmpty()) {
TinyTextEntity *lastEntity = d->m_words.last();
const QString concatText = lastEntity->text() + text.normalized(QString::NormalizationForm_KC);
if (concatText != concatText.normalized(QString::NormalizationForm_KC)) {
// If this happens it means that the new text + old one have combined, for example A and ◌̊ form Å
NormalizedRect newArea = *area | lastEntity->area;
delete area;
delete lastEntity;
d->m_words.removeLast();
d->m_words.append(new TinyTextEntity(concatText.normalized(QString::NormalizationForm_KC), newArea));
return;
}
}
d->m_words.append(new TinyTextEntity(text.normalized(QString::NormalizationForm_KC), *area));
}
delete area;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment