Qt应用程序中的模糊文本?

时间:2015-04-12 10:07:46

标签: qt user-interface fonts

我写了一个绘制文本的Qt应用程序,当使用小点大小的某种字体(Inconsolata)时,它看起来很模糊:

enter image description here

但是当使用其他字体(Courier New等等)时,它很好:

enter image description here

这里有什么奇怪的是,使用该字体的其他应用程序看起来很正常,这是对比(左边是vim,右边是我的应用程序):

Contrast of same font, different application

这里会出现什么问题?

环境:

Window 7 Ultimate 64位

PySide 1.2.2& Qt 4.8

Inconsolata.otf(http://www.levien.com/type/myfonts/inconsolata.html

代码示例(在黑暗方案中问题更严重):

from PySide.QtGui import *

app = QApplication([])
label = QLabel('hello\nworld')
label.setStyleSheet('QLabel {background: #000; color: #fff;}')
label.setFont(QFont('Inconsolata', 11))
label.show()
app.exec_()

1 个答案:

答案 0 :(得分:1)

您可以尝试更改QFont的Qt font style strategy,看看哪种效果最佳。

例如,要对应用程序的默认字体启用抗锯齿,您可以执行以下操作:

QFont font = QApplication::font();
font.setStyleStrategy(QFont::PreferAntialias);
QApplication::setFont(font);