Skip to content

Commit e0b2445

Browse files
nyalldawsonjef-n
authored andcommitted
[labeling] Fix incorrect handling of word spacing for curved labels
1 parent 1583924 commit e0b2445

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
@@ -117,11 +117,15 @@ class QgsPalGeometry : public PalGeometry
117117
int nxt = i + 1;
118118
wordSpaceFix = ( nxt < mClusters.count() && mClusters[nxt] != QString( " " ) ) ? mWordSpacing : qreal( 0.0 );
119119
}
120-
if ( fm->width( QString( mClusters[i] ) ) - fm->width( mClusters[i] ) - mLetterSpacing != qreal( 0.0 ) )
120+
// this workaround only works for clusters with a single character. Not sure how it should be handled
121+
// with multi-character clusters.
122+
if ( mClusters[i].length() == 1 &&
123+
!qgsDoubleNear( fm->width( QString( mClusters[i].at( 0 ) ) ), fm->width( mClusters[i].at( 0 ) ) + mLetterSpacing ) )
121124
{
122125
// word spacing applied when it shouldn't be
123126
wordSpaceFix -= mWordSpacing;
124127
}
128+
125129
charWidth = fm->width( QString( mClusters[i] ) ) + wordSpaceFix;
126130
}
127131

@@ -172,10 +176,10 @@ class QgsPalGeometry : public PalGeometry
172176
qreal mLetterSpacing; // for use with curved labels
173177
qreal mWordSpacing; // for use with curved labels
174178
bool mCurvedLabeling; // whether the geometry is to be used for curved labeling placement
175-
/**Stores attribute values for data defined properties*/
179+
/** Stores attribute values for data defined properties*/
176180
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues;
177181

178-
/**Stores attribute values for diagram rendering*/
182+
/** Stores attribute values for diagram rendering*/
179183
QgsAttributes mDiagramAttributes;
180184

181185
QString mDxfLayer;

0 commit comments

Comments
 (0)