Commit dcf0e782 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Properly parse "characters" formed by two QChars

This fixes the crash at 287138, it does still not really fix the flaw in the algorithm in TextPagePrivate::breakWordIntoCharacters
when there are two strings with the same text and the same bounding rectangle in the same page, but i still don't know how to fix that problem properly,
so i've fixed a bug that was generating the situation for files that actually do not have it
BUGS: 287138
parent 56e1002a
......@@ -1147,22 +1147,42 @@ Okular::TextPage * PDFGenerator::abstractTextPage(const QList<Poppler::TextBox*>
#ifdef PDFGENERATOR_DEBUG
kDebug(PDFDebug) << "getting text page in generator pdf - rotation:" << rot;
#endif
int charCount=0;
int j;
QString s;
bool addChar;
foreach (Poppler::TextBox *word, text)
{
charCount=word->text().length();
const int qstringCharCount = word->text().length();
next=word->nextWord();
for (j = 0; j < charCount; j++)
int textBoxChar = 0;
for (int j = 0; j < qstringCharCount; j++)
{
s = word->text().at(j);
QRectF charBBox = word->charBoundingBox(j);
append(ktp, (j==charCount-1 && !next ) ? (s + '\n') : s,
charBBox.left()/width,
charBBox.bottom()/height,
charBBox.right()/width,
charBBox.top()/height);
const QChar c = word->text().at(j);
if (c.isHighSurrogate())
{
s = c;
addChar = false;
}
else if (c.isLowSurrogate())
{
s += c;
addChar = true;
}
else
{
s = c;
addChar = true;
}
if (addChar)
{
QRectF charBBox = word->charBoundingBox(textBoxChar);
append(ktp, (j==qstringCharCount-1 && !next) ? (s + "\n") : s,
charBBox.left()/width,
charBBox.bottom()/height,
charBBox.right()/width,
charBBox.top()/height);
textBoxChar++;
}
}
if ( word->hasSpaceAfter() && next )
......
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