Skip to content

Commit

Permalink
Do not assume map is not rotated when computing label sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli committed Jan 9, 2015
1 parent 4dead72 commit a09d3d6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/qgspalgeometry.h
Expand Up @@ -67,14 +67,14 @@ class QgsPalGeometry : public PalGeometry
maxoutangle = -95.0;

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

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

ptSize = xform->toMapCoordinatesF((( double ) charWidth ) / fontScale, 0.0 );
mInfo->char_info[i].width = ptSize.x() - ptZero.x();
double labelWidth = mapScale * charWidth / fontScale;
mInfo->char_info[i].width = labelWidth;
}
return mInfo;
}
Expand Down

0 comments on commit a09d3d6

Please sign in to comment.