Skip to content
Permalink
Browse files

Fix label word and letter spacing cannot be decimals

  • Loading branch information
nyalldawson committed Jul 20, 2016
1 parent 5384e20 commit 48f090ca79f0d2d9ae341ae3617f20b2fe3fe14f
Showing with 5 additions and 5 deletions.
  1. +1 −1 python/core/qgspallabeling.sip
  2. +3 −3 src/core/qgspallabeling.cpp
  3. +1 −1 src/core/qgspallabeling.h
@@ -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
@@ -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
@@ -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

1 comment on commit 48f090c

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn commented on 48f090c Jul 20, 2016

@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.
You can’t perform that action at this time.