QPainter.drawText ugly font rendering

qfont = QtGui.QFont('Ubuntu', 9)
#qfont.setHintingPreference(QtGui.QFont.PreferDefaultHinting)
#qfont.setStyleStrategy(QtGui.QFont.PreferAntialias)
qfont.setStyle(QtGui.QFont.StyleNormal)
qfont.setWeight(QtGui.QFont.Normal)
qpaint.setFont(qfont)
qpaint.drawText(qpix.rect() , QtCore.Qt.AlignBottom + QtCore.Qt.AlignCenter, Invent.get_item(i)['type'])

Font rendering (anti-aliasing) is different from that used by other applications.

http://rghost.net/53129449/image.png

How to make it look like?

+4
source share
1 answer

I'm not sure if this applies directly to pyQt, but on the C ++ side, the rendering sides should be set at any time when the picture scales or looks bad. This is how I set my flags:

m_paintFlags = QPainter::RenderHint(QPainter::Antialiasing | 
    QPainter::SmoothPixmapTransform | 
    QPainter::HighQualityAntialiasing);

Then in the drawing event before drawing anything:

painter.setRenderHints(m_paintFlags);
+1
source

Source: https://habr.com/ru/post/1532149/


All Articles