Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.15.2, 6.0.4
-
None
Description
QPainter::drawText() on QWidget produces correctly ClearType subpixel anti-aliased result.
However, QPainter::drawText() on QPixmap produces gray-scale subpixel anti-aliased image which results into blurry image.
Same result for both of Qt 5.15.2 and Qt 6.0.4.
Here's sample code to reproduce the problem:
#include <QtWidgets/QWidget> #include <QtWidgets/QApplication> #include <QtGui/QPainter> namespace { class DirectWidget : public QWidget { public: DirectWidget() noexcept { setFixedSize(150, 20); } private: auto paintEvent(QPaintEvent *) -> void final { QPainter painter{this}; painter.setRenderHint(QPainter::TextAntialiasing); painter.drawText(rect(), Qt::AlignCenter, "Direct Rendering"); } }; class PixmapWidget : public QWidget { public: PixmapWidget() noexcept { setFixedSize(150, 20); } private: auto paintEvent(QPaintEvent *) -> void final { QPixmap pixmap{size()}; pixmap.fill(Qt::transparent); QPainter painter{&pixmap}; painter.setRenderHint(QPainter::TextAntialiasing); painter.drawText(pixmap.rect(), Qt::AlignCenter, "Pixmap Rendering"); painter.end(); painter.begin(this); painter.drawPixmap(0, 0, pixmap); } }; } auto main(int argc, char **argv) -> int { QApplication app{argc, argv}; app.setFont(QFont{"Consolas"}); DirectWidget dw; dw.show(); PixmapWidget pw; pw.show(); return app.exec(); }
You can see the problem in attachments, especially in enlarged screenshot.