From b948bf49f63d5eada5653024b462a32d19e1442a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 4 Jul 2020 22:10:32 +0530 Subject: [PATCH] Cover browser: improve rendering of text with heavily hinted fonts. Fixes #1886239 [Cover Browser: Font clipping with Microsoft ClearType Fonts](https://bugs.launchpad.net/calibre/+bug/1886239) Turn off hinting since we render to an offscreen buffer that is copied to screen later anyway and hinting results in very poor rendering. Hinting should not be needed at the larger text sizes typically used in the cover browser anyway. --- src/calibre/gui2/pictureflow/pictureflow.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/calibre/gui2/pictureflow/pictureflow.cpp b/src/calibre/gui2/pictureflow/pictureflow.cpp index fa2e7a7586..4aa0c29a04 100644 --- a/src/calibre/gui2/pictureflow/pictureflow.cpp +++ b/src/calibre/gui2/pictureflow/pictureflow.cpp @@ -435,6 +435,7 @@ PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w, int queueLength_) target = 0; fade = 256; subtitleFont = QFont(); + subtitleFont.setHintingPreference(QFont::PreferNoHinting); triggerTimer.setSingleShot(true); triggerTimer.setInterval(0); @@ -767,6 +768,11 @@ void PictureFlowPrivate::render() r = renderSlide(centerSlide); int c1 = r.left(); int c2 = r.right(); + QFont font = QFont(); + font.setBold(true); + font.setPixelSize(fontSize); + font.setHintingPreference(QFont::PreferNoHinting); + if(step == 0) { @@ -788,10 +794,6 @@ void PictureFlowPrivate::render() QPainter painter; painter.begin(&buffer); - - QFont font = QFont(); - font.setBold(true); - font.setPixelSize(fontSize); painter.setFont(font); painter.setPen(Qt::white); //painter.setPen(QColor(255,255,255,127)); @@ -835,14 +837,8 @@ void PictureFlowPrivate::render() c2 = rs.right(); } - - QPainter painter; painter.begin(&buffer); - - QFont font = QFont(); - font.setBold(true); - font.setPixelSize(fontSize); painter.setFont(font); int leftTextIndex = (step>0) ? centerIndex : centerIndex-1; @@ -1253,6 +1249,7 @@ void PictureFlow::setPreserveAspectRatio(bool preserve) void PictureFlow::setSubtitleFont(QFont font) { d->subtitleFont = font; + d->subtitleFont.setHintingPreference(QFont::PreferNoHinting); } QFont PictureFlow::subtitleFont() const