Skip to content

Commit

Permalink
[labeling] Fix incorrect handling of word spacing for curved labels
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson authored and jef-n committed Jul 24, 2015
1 parent 1583924 commit e0b2445
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/core/qgspalgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,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;
}

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

/**Stores attribute values for diagram rendering*/
/** Stores attribute values for diagram rendering*/
QgsAttributes mDiagramAttributes;

QString mDxfLayer;
Expand Down

0 comments on commit e0b2445

Please sign in to comment.