Skip to content

Commit

Permalink
[composer] Fix incorrect calculation of frame thickness for labels
Browse files Browse the repository at this point in the history
Previously entire frame width was considered when calculating
the margin for the label item. Only half the frame width should be
used, since half is drawn outside the item rect.
  • Loading branch information
nyalldawson committed Oct 14, 2014
1 parent b94b44a commit f284f6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposerlabel.cpp
Expand Up @@ -92,7 +92,7 @@ void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem*
//antialiasing on
painter->setRenderHint( QPainter::Antialiasing, true );

double penWidth = hasFrame() ? pen().widthF() : 0;
double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, rect().width() - 2 * penWidth - 2 * mMargin, rect().height() - 2 * penWidth - 2 * mMargin );

QString textToDraw = displayText();
Expand Down Expand Up @@ -286,7 +286,7 @@ void QgsComposerLabel::adjustSizeToText()
double textWidth = QgsComposerUtils::textWidthMM( mFont, displayText() );
double fontHeight = QgsComposerUtils::fontHeightMM( mFont );

double penWidth = hasFrame() ? pen().widthF() : 0;
double penWidth = hasFrame() ? ( pen().widthF() / 2.0 ) : 0;

double width = textWidth + 2 * mMargin + 2 * penWidth + 1;
double height = fontHeight + 2 * mMargin + 2 * penWidth;
Expand Down

0 comments on commit f284f6e

Please sign in to comment.