Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix label word and letter spacing cannot be decimals
  • Loading branch information
nyalldawson committed Jul 20, 2016
1 parent 5384e20 commit 48f090c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/core/qgspallabeling.sip
Expand Up @@ -639,7 +639,7 @@ class QgsPalLayerSettings
* @param mapUnitScale a mapUnitScale clamper
* @return font pixel size
*/
int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
double sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;

/** Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
* @param size size to convert
Expand Down
6 changes: 3 additions & 3 deletions src/core/qgspallabeling.cpp
Expand Up @@ -2223,7 +2223,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
return;
}

int fontPixelSize = sizeToPixel( fontSize, context, fontunits, true, fontSizeMapUnitScale );
int fontPixelSize = qRound( sizeToPixel( fontSize, context, fontunits, true, fontSizeMapUnitScale ) );
// don't try to show font sizes less than 1 pixel (Qt complains)
if ( fontPixelSize < 1 )
{
Expand Down Expand Up @@ -3874,9 +3874,9 @@ void QgsPalLayerSettings::parseDropShadow( QgsRenderContext &context )
dataDefinedValEval( DDBlendMode, QgsPalLayerSettings::ShadowBlendMode, exprVal, context.expressionContext() );
}

int QgsPalLayerSettings::sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor, const QgsMapUnitScale& mapUnitScale ) const
double QgsPalLayerSettings::sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor, const QgsMapUnitScale& mapUnitScale ) const
{
return static_cast< int >( scaleToPixelContext( size, c, unit, rasterfactor, mapUnitScale ) + 0.5 );
return scaleToPixelContext( size, c, unit, rasterfactor, mapUnitScale ) + 0.5;
}

double QgsPalLayerSettings::scaleToPixelContext( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor, const QgsMapUnitScale& mapUnitScale ) const
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgspallabeling.h
Expand Up @@ -625,7 +625,7 @@ class CORE_EXPORT QgsPalLayerSettings
* @param mapUnitScale a mapUnitScale clamper
* @return font pixel size
*/
int sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;
double sizeToPixel( double size, const QgsRenderContext& c, SizeUnit unit, bool rasterfactor = false, const QgsMapUnitScale& mapUnitScale = QgsMapUnitScale() ) const;

/** Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)
* @param size size to convert
Expand Down

1 comment on commit 48f090c

@nirvn
Copy link
Contributor

@nirvn nirvn commented on 48f090c Jul 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson this might have created a regression, whereas using the same font size, a feature label isn't rendered the same way a composer label item is, creating problematic layout inconsistency.

QGIS 2.16 (top, consistent rendering) vs. QGIS master (bottom, inconsistent rendering):
untitled

Please sign in to comment.