mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Fix label map unit scale range for font size and buffer
Refs #14698, but other label size parameters are still ignoring scale ranges
This commit is contained in:
parent
3322bcb2b3
commit
72714e6f5e
@ -2226,6 +2226,7 @@ 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 )
|
||||
{
|
||||
@ -2283,7 +2284,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, fontunits, context );
|
||||
parseTextStyle( labelFont, context, fontSizeScaleFactor );
|
||||
parseTextFormatting( context );
|
||||
parseTextBuffer( context );
|
||||
parseShapeBackground( context );
|
||||
@ -3188,8 +3189,7 @@ bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
|
||||
}
|
||||
|
||||
void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
|
||||
QgsPalLayerSettings::SizeUnit fontunits,
|
||||
QgsRenderContext &context )
|
||||
QgsRenderContext &context, double fontSizeScaleFactor )
|
||||
{
|
||||
// NOTE: labelFont already has pixelSize set, so pointSize or pointSizeF might return -1
|
||||
|
||||
@ -3319,7 +3319,7 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
|
||||
wordspace = wspacing;
|
||||
}
|
||||
}
|
||||
labelFont.setWordSpacing( sizeToPixel( wordspace, context, fontunits, false, fontSizeMapUnitScale ) );
|
||||
labelFont.setWordSpacing( wordspace * fontSizeScaleFactor + 0.5 );
|
||||
|
||||
// data defined letter spacing?
|
||||
double letterspace = labelFont.letterSpacing();
|
||||
@ -3333,7 +3333,7 @@ void QgsPalLayerSettings::parseTextStyle( QFont& labelFont,
|
||||
letterspace = lspacing;
|
||||
}
|
||||
}
|
||||
labelFont.setLetterSpacing( QFont::AbsoluteSpacing, sizeToPixel( letterspace, context, fontunits, false, fontSizeMapUnitScale ) );
|
||||
labelFont.setLetterSpacing( QFont::AbsoluteSpacing, letterspace * fontSizeScaleFactor + 0.5 );
|
||||
|
||||
// data defined font capitalization?
|
||||
QFont::Capitalization fontcaps = labelFont.capitalization();
|
||||
@ -3846,14 +3846,19 @@ double QgsPalLayerSettings::scaleToPixelContext( double size, const QgsRenderCon
|
||||
|
||||
if ( unit == MapUnits && mapUnitsPerPixel > 0.0 )
|
||||
{
|
||||
size = size / mapUnitsPerPixel * ( rasterfactor ? c.rasterScaleFactor() : 1 );
|
||||
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() );
|
||||
}
|
||||
else // e.g. in points or mm
|
||||
{
|
||||
double ptsTomm = ( unit == Points ? 0.352778 : 1 );
|
||||
size *= ptsTomm * c.scaleFactor() * ( rasterfactor ? c.rasterScaleFactor() : 1 );
|
||||
size *= ptsTomm * c.scaleFactor();
|
||||
}
|
||||
return size;
|
||||
return size * ( rasterfactor ? c.rasterScaleFactor() : 1 );
|
||||
}
|
||||
|
||||
// -------------
|
||||
|
@ -695,8 +695,8 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
QVariant& exprVal, QgsExpressionContext &context, const QVariant& originalValue = QVariant() );
|
||||
|
||||
void parseTextStyle( QFont& labelFont,
|
||||
QgsPalLayerSettings::SizeUnit fontunits,
|
||||
QgsRenderContext& context );
|
||||
QgsRenderContext& context,
|
||||
double fontSizeScaleFactor = 1.0 );
|
||||
|
||||
void parseTextBuffer( QgsRenderContext& context );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user