Details
-
Bug
-
Resolution: Done
-
P2: Important
-
4.7.0
-
None
-
354246566cf86f687ee897f95586ac17b5deb35c
Description
When text is painted with QPainter to an FBO on Linux (with Freetype font engine), then the characters are shifted one pixel to the left compared to when they are drawn using the raster engine.
Run the following example to see. The top "Q" is painted with the raster engine and the bottom "Q" is painted into an FBO with the OpenGL engine. The bottom "Q" is one pixel to the left of the top "Q".
#include <QtGui> #include <QtOpenGL> class MyGL : public QGLWidget { public: MyGL() : QGLWidget() { makeCurrent(); QGLFramebufferObjectFormat fboFormat; fbo = new QGLFramebufferObject(800, 800, fboFormat); } void paintEvent(QPaintEvent *) { { QPainter p(fbo); p.fillRect(0, 0, 50, 20, Qt::white); p.fillRect(10, 0, 10, 20, Qt::yellow); p.drawText(10, 10, "Q"); } QImage rasterEngineImage(50, 20, QImage::Format_ARGB32_Premultiplied); { QPainter p(&rasterEngineImage); p.fillRect(0, 0, 50, 20, Qt::white); p.fillRect(10, 0, 10, 20, Qt::yellow); p.drawText(10, 10, "Q"); p.end(); } QImage openglEngineImage = fbo->toImage(); { QPainter p(this); p.fillRect(rect(), Qt::white); p.drawImage(0, 0, rasterEngineImage); p.drawImage(0, rasterEngineImage.height(), openglEngineImage); } } private: QGLFramebufferObject *fbo; }; int main(int argc, char **argv) { QApplication a(argc, argv); MyGL m; m.show(); return a.exec(); }