Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.0.2, 5.1.0
-
None
-
Ubuntu 12.04 32 Bit, GNOME Classic 3.4.1
Fedora 19, 32 Bit, GNOME 3.8
Description
If a QFont with stretch is used, QPainter::drawText() renders the Text realy strange. This behavior only occurs on Linux (tested with Ubuntu 12.04 and Fedora 19). There are an example of the distortion in the following image.
By way of comparison, the second image shows the same output on a Windows 7x64 System, which shows the Text as might be desired. The same font is used like on Linux.
I have tested this behavior with Qt 5.1 and 5.0.2. I also used other fonts. That makes no difference. I haven't tested on older versions of Qt.
Perhaps there is a deadlock in the drawText method. If the text is rendered Strange there is the following warning on stderr:
[warning] (thread/qmutex.cpp:194) – QMutex: destroying locked mutex
The following code generates the output shown in the images. It is also attached to this issue.
#include "MainWindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); QString GetFont(); protected: void paintEvent(QPaintEvent *ap_event); private: Ui::MainWindow *ui; QFont font; }; #endif // MAINWINDOW_H
#include "MainWindow.h" #include "ui_MainWindow.h" #include <QPainter> MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ), ui( new Ui::MainWindow ) { ui->setupUi( this ); } MainWindow::~MainWindow() { delete ui; } void MainWindow::paintEvent( QPaintEvent */*event*/ ) { QString str( "Hello World" ); QPoint pos( 10, 10 ); QFont font( "Ubuntu Mono" ); font.setPointSize( 40 ); font.setStretch( 200 ); font.setUnderline( true ); font.setOverline( true ); QFontMetrics fm( font ); QRect boundingRect( pos, fm.size( 0, str ) ); QPainter painter( this ); painter.setPen( Qt::black ); painter.fillRect( boundingRect, Qt::lightGray ); painter.setFont( font ); // probleme here // Warning: QMutex: destroying locked mutex painter.drawText( boundingRect, Qt::AlignCenter, str ); }