Skip to content
Permalink
Browse files

Fix positioning of final scalebar label

  • Loading branch information
nyalldawson committed May 11, 2018
1 parent 9ce19af commit 0708d84139e3714111babcbaa6662171b314b563
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/core/scalebar/qgsscalebarrenderer.cpp
@@ -82,9 +82,13 @@ void QgsScaleBarRenderer::drawDefaultLabels( QgsRenderContext &context, const Qg
//also draw the last label
if ( !positions.isEmpty() )
{
// note: this label is NOT centered over the end of the bar - rather the numeric portion
// of it is, without considering the unit label suffix. That's drawn at the end after
// horizontally centering just the numeric portion.
currentNumericLabel = QString::number( currentLabelNumber / settings.mapUnitsPerScaleBarUnit() );
QgsTextRenderer::drawText( QPointF( context.convertToPainterUnits( positions.at( positions.size() - 1 ) + scaleContext.segmentWidth, QgsUnitTypes::RenderMillimeters ) + xOffset,
fontMetrics.ascent() + scaledBoxContentSpace ), 0, QgsTextRenderer::AlignCenter,
QgsTextRenderer::drawText( QPointF( context.convertToPainterUnits( positions.at( positions.size() - 1 ) + scaleContext.segmentWidth, QgsUnitTypes::RenderMillimeters ) + xOffset
- fontMetrics.width( currentNumericLabel ) / 2.0,
fontMetrics.ascent() + scaledBoxContentSpace ), 0, QgsTextRenderer::AlignLeft,
QStringList() << ( currentNumericLabel + ' ' + settings.unitLabel() ), context, format );
}

0 comments on commit 0708d84

Please sign in to comment.
You can’t perform that action at this time.