https://bugs.kde.org/show_bug.cgi?id=353300
Saladin Shaban <salshaa...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |salshaa...@gmail.com --- Comment #4 from Saladin Shaban <salshaa...@gmail.com> --- I have been investigating this with ChatGPT's help: https://chat.openai.com/share/69484c6f-d974-4047-8d52-c92d6ea0ebf9 There seem to be two issues affecting Arabic and, apparently, other RTL languages as well. One of them is in TextDocumentUtils::calculateBoundingRect(), where the final if statement is incorrectly triggered for all Arabic text, causing all characters to be substituted with newlines. Trying to work around the issue with this patch, the TinyTextEntity's are created with the correct characters and the correct bounding rectangles, as far as I can see. But the search still seems to expect the TinyTextEntity's in left to right order. I can only find Arabic words if I type them backwards in the Find bar. diff --git a/core/textdocumentgenerator_p.h b/core/textdocumentgenerator_p.h index fb1a5e395..bf17e2e52 100644 --- a/core/textdocumentgenerator_p.h +++ b/core/textdocumentgenerator_p.h @@ -44,19 +44,23 @@ static void calculateBoundingRect(QTextDocument *document, int startPosition, in const QTextLine startLine = startLayout->lineForTextPosition(startPos); const QTextLine endLine = endLayout->lineForTextPosition(endPos); - const double x = startBoundingRect.x() + startLine.cursorToX(startPos); + double x = startBoundingRect.x() + startLine.cursorToX(startPos); const double y = startBoundingRect.y() + startLine.y(); - const double r = endBoundingRect.x() + endLine.cursorToX(endPos); + double r = endBoundingRect.x() + endLine.cursorToX(endPos); const double b = endBoundingRect.y() + endLine.y() + endLine.height(); const int offset = qRound(y) % qRound(pageSize.height()); - if (x > r) { // line break, so return a pseudo character on the start line + if (startLine.y() != endLine.y()) { // line break, so return a pseudo character on the start line rect = QRectF(x / pageSize.width(), offset / pageSize.height(), 3 / pageSize.width(), startLine.height() / pageSize.height()); page = -1; return; } + const auto direction = document->characterAt(startPosition).direction(); + if (direction == QChar::DirAL || direction == QChar::DirR) + std::swap(x, r); + page = qRound(y) / qRound(pageSize.height()); rect = QRectF(x / pageSize.width(), offset / pageSize.height(), (r - x) / pageSize.width(), (b - y) / pageSize.height()); } -- You are receiving this mail because: You are the assignee for the bug.