Skip to content

Commit

Permalink
Revert "Fix label map unit scale range for font size and buffer"
Browse files Browse the repository at this point in the history
This reverts commit 72714e6.
  • Loading branch information
nyalldawson committed Apr 25, 2016
1 parent 181c0c4 commit 4c02997
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
21 changes: 8 additions & 13 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,6 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
}

int fontPixelSize = sizeToPixel( fontSize, context, fontunits, true, fontSizeMapUnitScale );
double fontSizeScaleFactor = fontSize / ( fontPixelSize - 0.5 );
// don't try to show font sizes less than 1 pixel (Qt complains)
if ( fontPixelSize < 1 )
{
Expand Down Expand Up @@ -2284,7 +2283,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont

// calculate rest of font attributes and store any data defined values
// this is done here for later use in making label backgrounds part of collision management (when implemented)
parseTextStyle( labelFont, context, fontSizeScaleFactor );
parseTextStyle( labelFont, fontunits, context );
parseTextFormatting( context );
parseTextBuffer( context );
parseShapeBackground( context );
Expand Down Expand Up @@ -3189,7 +3188,8 @@ bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
}

void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
QgsRenderContext &context, double fontSizeScaleFactor )
QgsPalLayerSettings::SizeUnit fontunits,
QgsRenderContext &context )
{
// NOTE: labelFont already has pixelSize set, so pointSize or pointSizeF might return -1

Expand Down Expand Up @@ -3319,7 +3319,7 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
wordspace = wspacing;
}
}
labelFont.setWordSpacing( wordspace * fontSizeScaleFactor + 0.5 );
labelFont.setWordSpacing( sizeToPixel( wordspace, context, fontunits, false, fontSizeMapUnitScale ) );

// data defined letter spacing?
double letterspace = labelFont.letterSpacing();
Expand All @@ -3333,7 +3333,7 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
letterspace = lspacing;
}
}
labelFont.setLetterSpacing( QFont::AbsoluteSpacing, letterspace * fontSizeScaleFactor + 0.5 );
labelFont.setLetterSpacing( QFont::AbsoluteSpacing, sizeToPixel( letterspace, context, fontunits, false, fontSizeMapUnitScale ) );

// data defined font capitalization?
QFont::Capitalization fontcaps = labelFont.capitalization();
Expand Down Expand Up @@ -3846,19 +3846,14 @@ double QgsPalLayerSettings::scaleToPixelContext( double size, const QgsRenderCon

if ( unit == MapUnits && mapUnitsPerPixel > 0.0 )
{
size = size / mapUnitsPerPixel;
//check max/min size
if ( mapUnitScale.minSizeMMEnabled )
size = qMax( size, mapUnitScale.minSizeMM * c.scaleFactor() );
if ( mapUnitScale.maxSizeMMEnabled )
size = qMin( size, mapUnitScale.maxSizeMM * c.scaleFactor() );
size = size / mapUnitsPerPixel * ( rasterfactor ? c.rasterScaleFactor() : 1 );
}
else // e.g. in points or mm
{
double ptsTomm = ( unit == Points ? 0.352778 : 1 );
size *= ptsTomm * c.scaleFactor();
size *= ptsTomm * c.scaleFactor() * ( rasterfactor ? c.rasterScaleFactor() : 1 );
}
return size * ( rasterfactor ? c.rasterScaleFactor() : 1 );
return size;
}

// -------------
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgspallabeling.h
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ class CORE_EXPORT QgsPalLayerSettings
QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );

void parseTextStyle( QFont& labelFont,
QgsRenderContext& context,
double fontSizeScaleFactor = 1.0 );
QgsPalLayerSettings::SizeUnit fontunits,
QgsRenderContext& context );

void parseTextBuffer( QgsRenderContext& context );

Expand Down

0 comments on commit 4c02997

Please sign in to comment.