Implement initial support for RTL languages (#3958)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
fix https://github.com/Chatterino/chatterino2/issues/720
This commit is contained in:
mohad12211
2022-11-10 23:36:19 +03:00
committed by GitHub
parent fbfa5e0f41
commit 3fcb7e1702
8 changed files with 217 additions and 13 deletions
+14 -2
View File
@@ -12,6 +12,12 @@
#include <QPainter>
#include <QPainterPath>
namespace {
const QChar RTL_MARK(0x200F);
} // namespace
namespace chatterino {
const QRect &MessageLayoutElement::getRect() const
@@ -286,14 +292,20 @@ int TextLayoutElement::getSelectionIndexCount() const
void TextLayoutElement::paint(QPainter &painter)
{
auto app = getApp();
QString text = this->getText();
if (text.isRightToLeft() || this->reversedNeutral)
{
text.prepend(RTL_MARK);
text.append(RTL_MARK);
}
painter.setPen(this->color_);
painter.setFont(app->fonts->getFont(this->style_, this->scale_));
painter.drawText(
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000),
this->getText(), QTextOption(Qt::AlignLeft | Qt::AlignTop));
QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), text,
QTextOption(Qt::AlignLeft | Qt::AlignTop));
}
void TextLayoutElement::paintAnimated(QPainter &, int)