Workaround for Qt being unable to anti-alias rotated text on windows

This commit is contained in:
Kovid Goyal 2016-09-01 14:20:48 +05:30
parent c868fdd32e
commit 942b4e3a0e

View File

@ -5,9 +5,9 @@
from __future__ import (unicode_literals, division, absolute_import,
print_function)
from PyQt5.Qt import Qt, QSplashScreen, QIcon, QApplication, QTransform
from PyQt5.Qt import Qt, QSplashScreen, QIcon, QApplication, QTransform, QPainterPath, QBrush
from calibre.constants import __appname__
from calibre.constants import __appname__, iswindows
from calibre.utils.monotonic import monotonic
class SplashScreen(QSplashScreen):
@ -24,6 +24,7 @@ class SplashScreen(QSplashScreen):
painter.save()
painter.setPen(Qt.black)
painter.setRenderHint(painter.TextAntialiasing, True)
painter.setRenderHint(painter.Antialiasing, True)
f = painter.font()
f.setPixelSize(18)
painter.setFont(f)
@ -31,7 +32,13 @@ class SplashScreen(QSplashScreen):
t.translate(330, 450)
painter.setTransform(t)
painter.rotate(-98)
painter.drawText(0, 0, self.message())
if iswindows:
# On windows Qt cannot anti-alias rotated text
p = QPainterPath()
p.addText(0, 0, f, self.message())
painter.fillPath(p, QBrush(Qt.black))
else:
painter.drawText(0, 0, self.message())
painter.restore()
def show_message(self, msg):
@ -51,10 +58,13 @@ class SplashScreen(QSplashScreen):
ev.accept()
QApplication.instance().quit()
if __name__ == '__main__':
def main():
from calibre.gui2 import Application
app = Application([])
spl = SplashScreen(develop=True)
spl.show()
spl.show_message('Testing the splash screen message...')
app.exec_()
if __name__ == '__main__':
main()