QPainter drawFont() draws corrupt glyphs.
-
I'm trying to overlay some 2d text over an OpenGL context using QPainter.
Here's the code I'm using to set up the font:
@
m_font = QFont ("Times", 15, QFont::Light, true);
@Here's the code I'm using for drawing:
@
if (!m_paintDevice){
m_paintDevice = new QOpenGLPaintDevice;
}glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_paintDevice->setSize(size());
QPainter painter(m_paintDevice);
painter.setRenderHint(QPainter::Antialiasing);
painter.beginNativePainting();// OpenGL draw calls go here.
painter.endNativePainting();
m_defaultPen.setColor(Qt::white);
painter.setPen(m_defaultPen);
painter.setFont(m_font);
painter.drawText(m_defaultRect, Qt::AlignCenter, "This is a test.");
@This is the result I'm getting:
!http://i.imgur.com/mGVoBeT.png?1!I've tried multiple font families, yet this problem persisted. The only thing that can slightly mitigate it, is the increase in QFont size (60+ has little to none of these distortions).
I'm using Qt 5.2, on Windows 7, MinGW 32 bit, and would appreciate any help you can give.