PhilippM
21st March 2011, 16:06
Hi folks,
I'm using a QPainter to draw text with QFont on a QImage. This image as later used as a texture in an opengl scene.
Since drawing the complex texture with QPainter is rather slow, I decided to do all the painting in a different thread painting on a different QImage surface, and swap the images whenever the scene has finished painting (swapping and painting is of course guarded by a mutex).
This works really great with all contents of the scene that are lines, chords, ellipses etc. But it doesn't work with the text.
Instead of the letters, solid squares are displayed.
Is there something special I have to do with the QFont object so that it can be used in a thread other than the GUI thread?
Of course, the font object is allocated in the thread where it is used, and is not used from other threads.
I'm using Qt 4.7.1 on a 64bit Linux, compiling with gcc 4.5.0.
Regards,
Philipp
EDIT: According to this posting http://labs.qt.nokia.com/2007/09/27/multi-threaded-text-layout-and-printing/
it is supposed to work if QFontDatabase::supportsThreadedFontRendering () return true, which it does. So are there additional considerations i missed?
Added after 1 1:
Sorry, I was wrong in the edit.
QFontDatabase::supportsThreadedFontRendering () returns false.
This explains why the output is garbled.
According to the comment in the linked blogpost, this means that QT_X11_NO_FONTCONFIG is defined on my system.
However, env doesn't return an environment variable of that name.
So why does Qt assume that FONTCONFIG is not available?
Do I have to specify some options when compiling Qt?
Philipp
EDIT: can i ask my qmake binary whether it was compiled with -fontconfig ?
I'm using a QPainter to draw text with QFont on a QImage. This image as later used as a texture in an opengl scene.
Since drawing the complex texture with QPainter is rather slow, I decided to do all the painting in a different thread painting on a different QImage surface, and swap the images whenever the scene has finished painting (swapping and painting is of course guarded by a mutex).
This works really great with all contents of the scene that are lines, chords, ellipses etc. But it doesn't work with the text.
Instead of the letters, solid squares are displayed.
Is there something special I have to do with the QFont object so that it can be used in a thread other than the GUI thread?
Of course, the font object is allocated in the thread where it is used, and is not used from other threads.
I'm using Qt 4.7.1 on a 64bit Linux, compiling with gcc 4.5.0.
Regards,
Philipp
EDIT: According to this posting http://labs.qt.nokia.com/2007/09/27/multi-threaded-text-layout-and-printing/
it is supposed to work if QFontDatabase::supportsThreadedFontRendering () return true, which it does. So are there additional considerations i missed?
Added after 1 1:
Sorry, I was wrong in the edit.
QFontDatabase::supportsThreadedFontRendering () returns false.
This explains why the output is garbled.
According to the comment in the linked blogpost, this means that QT_X11_NO_FONTCONFIG is defined on my system.
However, env doesn't return an environment variable of that name.
So why does Qt assume that FONTCONFIG is not available?
Do I have to specify some options when compiling Qt?
Philipp
EDIT: can i ask my qmake binary whether it was compiled with -fontconfig ?