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.
portage-wilder
Oliver Sander 7 years ago committed by Albert Astals Cid
parent 9b34bfb45e
commit a0bd9c4d1c
  1. 9
      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,

Loading…
Cancel
Save