Skip to content
Permalink
Browse files

fix #39160 : fixed layout map grid annotations box calculation

  • Loading branch information
olivierdalang authored and nyalldawson committed Oct 7, 2020
1 parent daa4e84 commit 96e0e9b9e26771b2beb3458c68ad0f26149ff5d1
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/core/layout/qgslayoutitemmapgrid.cpp
@@ -1212,10 +1212,14 @@ void QgsLayoutItemMapGrid::drawCoordinateAnnotation( QgsRenderContext &context,
return;

QgsLayoutItemMapGrid::BorderSide frameBorder = annot.border;
double textWidth = QgsLayoutUtils::textWidthMM( mAnnotationFormat.font(), annotationString );
double textWidth = QgsTextRenderer::textWidth( context, mAnnotationFormat, QStringList() << annotationString ) / context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
if ( extension )
textWidth *= 1.1; // little bit of extra padding when we are calculating the bounding rect, to account for antialiasing

//relevant for annotations is the height of digits
double textHeight = extension ? QgsLayoutUtils::fontAscentMM( mAnnotationFormat.font() )
: QgsLayoutUtils::fontHeightCharacterMM( mAnnotationFormat.font(), QChar( '0' ) );
double textHeight = ( extension ? ( QgsTextRenderer::textHeight( context, mAnnotationFormat, QChar(), true ) )
: ( QgsTextRenderer::textHeight( context, mAnnotationFormat, '0', false ) ) ) / context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );

double xpos = annot.position.x();
double ypos = annot.position.y();
QPointF anchor = QPointF();

0 comments on commit 96e0e9b

Please sign in to comment.
You can’t perform that action at this time.