Skip to content

Commit a09d3d6

Browse files
author
Sandro Santilli
committed
Do not assume map is not rotated when computing label sizes
1 parent 4dead72 commit a09d3d6

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/core/qgspalgeometry.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ class QgsPalGeometry : public PalGeometry
6767
maxoutangle = -95.0;
6868

6969
// create label info!
70-
QgsPoint ptZero = xform->toMapCoordinates( 0, 0 );
71-
QgsPoint ptSize = xform->toMapCoordinatesF( 0.0, -fm->height() / fontScale );
70+
double mapScale = xform->mapUnitsPerPixel();
71+
double labelHeight = mapScale * fm->height() / fontScale;
7272

7373
// mLetterSpacing/mWordSpacing = 0.0 is default for non-curved labels
7474
// (non-curved spacings handled by Qt in QgsPalLayerSettings/QgsPalLabeling)
7575
qreal charWidth;
7676
qreal wordSpaceFix;
77-
mInfo = new pal::LabelInfo( mText.count(), ptSize.y() - ptZero.y(), maxinangle, maxoutangle );
77+
mInfo = new pal::LabelInfo( mText.count(), labelHeight, maxinangle, maxoutangle );
7878
for ( int i = 0; i < mText.count(); i++ )
7979
{
8080
mInfo->char_info[i].chr = mText[i].unicode();
@@ -99,8 +99,8 @@ class QgsPalGeometry : public PalGeometry
9999
charWidth = fm->width( QString( mText[i] ) ) + wordSpaceFix;
100100
}
101101

102-
ptSize = xform->toMapCoordinatesF((( double ) charWidth ) / fontScale, 0.0 );
103-
mInfo->char_info[i].width = ptSize.x() - ptZero.x();
102+
double labelWidth = mapScale * charWidth / fontScale;
103+
mInfo->char_info[i].width = labelWidth;
104104
}
105105
return mInfo;
106106
}

0 commit comments

Comments
 (0)