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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user