[labeling] Fix incorrect handling of word spacing for curved labels

This commit is contained in:
Nyall Dawson 2015-07-22 16:15:57 +10:00
parent a1a8d1b7a3
commit c8dcf97e97

View File

@ -110,11 +110,15 @@ class QgsPalGeometry : public PalGeometry
int nxt = i + 1;
wordSpaceFix = ( nxt < mClusters.count() && mClusters[nxt] != QString( " " ) ) ? mWordSpacing : qreal( 0.0 );
}
if ( fm->width( QString( mClusters[i] ) ) - fm->width( mClusters[i] ) - mLetterSpacing != qreal( 0.0 ) )
// this workaround only works for clusters with a single character. Not sure how it should be handled
// with multi-character clusters.
if ( mClusters[i].length() == 1 &&
!qgsDoubleNear( fm->width( QString( mClusters[i].at( 0 ) ) ), fm->width( mClusters[i].at( 0 ) ) + mLetterSpacing ) )
{
// word spacing applied when it shouldn't be
wordSpaceFix -= mWordSpacing;
}
charWidth = fm->width( QString( mClusters[i] ) ) + wordSpaceFix;
}