Fix label word and letter spacing cannot be decimals

This commit is contained in:
Nyall Dawson 2016-07-08 18:52:37 +10:00
parent 5384e203fb
commit 48f090ca79
3 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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 )
{
@ -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

View File

@ -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