Skip to content

Commit c8dcf97

Browse files
committedJul 22, 2015
[labeling] Fix incorrect handling of word spacing for curved labels
1 parent a1a8d1b commit c8dcf97

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎src/core/qgspalgeometry.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@ class QgsPalGeometry : public PalGeometry
110110
int nxt = i + 1;
111111
wordSpaceFix = ( nxt < mClusters.count() && mClusters[nxt] != QString( " " ) ) ? mWordSpacing : qreal( 0.0 );
112112
}
113-
if ( fm->width( QString( mClusters[i] ) ) - fm->width( mClusters[i] ) - mLetterSpacing != qreal( 0.0 ) )
113+
// this workaround only works for clusters with a single character. Not sure how it should be handled
114+
// with multi-character clusters.
115+
if ( mClusters[i].length() == 1 &&
116+
!qgsDoubleNear( fm->width( QString( mClusters[i].at( 0 ) ) ), fm->width( mClusters[i].at( 0 ) ) + mLetterSpacing ) )
114117
{
115118
// word spacing applied when it shouldn't be
116119
wordSpaceFix -= mWordSpacing;
117120
}
121+
118122
charWidth = fm->width( QString( mClusters[i] ) ) + wordSpaceFix;
119123
}
120124

@@ -165,10 +169,10 @@ class QgsPalGeometry : public PalGeometry
165169
qreal mLetterSpacing; // for use with curved labels
166170
qreal mWordSpacing; // for use with curved labels
167171
bool mCurvedLabeling; // whether the geometry is to be used for curved labeling placement
168-
/**Stores attribute values for data defined properties*/
172+
/** Stores attribute values for data defined properties*/
169173
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues;
170174

171-
/**Stores attribute values for diagram rendering*/
175+
/** Stores attribute values for diagram rendering*/
172176
QgsAttributes mDiagramAttributes;
173177

174178
QString mDxfLayer;

0 commit comments

Comments
 (0)
Please sign in to comment.