From a0bd9c4d1c42f47162922098e971bfc15f5c1faf Mon Sep 17 00:00:00 2001 From: Oliver Sander Date: Tue, 9 Jul 2019 21:57:05 +0200 Subject: [PATCH] Make the page outline one physical pixel wide Pages get a black rectangle around them as 'outline' after being rendered. This rendering was not pixel-perfect at fractional scalings: apparently, fractional line widths and positions get rounded differently. The result was that sometimes there was a small gap between outline and page. This pages fixes the problem by making the pen for the outline 'cosmetic', i.e., one physical pixel wide. With that, its position can be such that it encloses the page without any gap. --- ui/pageview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/pageview.cpp b/ui/pageview.cpp index 741ac2ef5..45437b0ac 100644 --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -3569,8 +3569,13 @@ void PageView::drawDocumentOnPainter( const QRect & contentsRect, QPainter * p ) int itemWidth = itemGeometry.width(); int itemHeight = itemGeometry.height(); // draw simple outline - p->setPen( Qt::black ); - p->drawRect( -1, -1, itemWidth + 1, itemHeight + 1 ); + QPen pen( Qt::black ); + pen.setWidth(0); + p->setPen( pen ); + + QRectF outline( -1.0/dpr, -1.0/dpr, itemWidth + 1.0/dpr, itemHeight + 1.0/dpr ); + p->drawRect( outline ); + // draw bottom/right gradient static const int levels = 2; int r = backColor.red() / (levels + 2) + 6,