Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.2.3
-
None
Description
Consider the following on X11:
The same QPainter code is used to draw a rectangle and some text in a QPixmap and a QBitmap. In the resulting images, the rectangle is the same, but the text is off by one pixel in the vertical direction in the QPixmap compared to the QBitmap. The text should be painted the same in both images.
Note that the off-by-one error only occurs if XRender is enabled. if XRender is disabled, the text is drawn exactly the same in the QPixmap as in the QBitmap.
The following example demonstrates the problem:
#include <QApplication> #include <QPainter> #include <QPixmap> #include <QBitmap> void draw_text(QPixmap* d) { QPainter p; p.begin(d); p.setRenderHint(QPainter::Antialiasing, false); p.setRenderHint(QPainter::TextAntialiasing, false); QFont fn = p.font(); fn.setStyleStrategy(QFont::NoAntialias); fn.setPointSize(18); p.setFont(fn); p.drawRect(d->rect().adjusted(0, 0, -1, -1)); p.drawText(20, 20, "test"); p.end(); } int main(int argc, char *argv[]) { QApplication a(argc, argv); QPixmap p(100, 100); QBitmap b(100, 100); p.fill(Qt::transparent); b.clear(); draw_text(&p); draw_text(&b); p.save("pixmap.png", "PNG"); b.save("bitmap.png", "PNG"); return 0; }