Skip to content

Commit

Permalink
Fix preview icon of text formats using balloon callouts with top/bottom
Browse files Browse the repository at this point in the history
margins
  • Loading branch information
nyalldawson committed Apr 19, 2021
1 parent 804914f commit cefd4ed
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/callouts/qgscallout.cpp
Expand Up @@ -1263,9 +1263,13 @@ QPolygonF QgsBalloonCallout::getPoints( QgsRenderContext &context, QgsPointXY or
const double marginTop = context.convertToPainterUnits( top, mMarginUnit );
const double marginBottom = context.convertToPainterUnits( bottom, mMarginUnit );

const QRectF expandedRect( rect.left() - marginLeft, rect.top() + marginBottom,
rect.width() + marginLeft + marginRight,
rect.height() - marginTop - marginBottom );
const QRectF expandedRect = rect.height() < 0 ?
QRectF( rect.left() - marginLeft, rect.top() + marginBottom,
rect.width() + marginLeft + marginRight,
rect.height() - marginTop - marginBottom ) :
QRectF( rect.left() - marginLeft, rect.top() - marginTop,
rect.width() + marginLeft + marginRight,
rect.height() + marginTop + marginBottom );

// IMPORTANT -- check for degenerate height is sometimes >=0, because QRectF are not normalized and we are using painter
// coordinates with descending vertical axis!
Expand Down

0 comments on commit cefd4ed

Please sign in to comment.