@@ -408,6 +408,9 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
408408 double height = mSymbolHeight ;
409409 double width = mSymbolWidth ;
410410 double size = 0 ;
411+ // Center small marker symbols
412+ double widthOffset = 0 ;
413+ double heightOffset = 0 ;
411414
412415 if ( markerSymbol )
413416 {
@@ -420,10 +423,18 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
420423 width *= mmPerMapUnit;
421424 markerSymbol->setSize ( width );
422425 }
426+ if ( width < mSymbolWidth )
427+ {
428+ widthOffset = ( mSymbolWidth - width ) / 2.0 ;
429+ }
430+ if ( height < mSymbolHeight )
431+ {
432+ heightOffset = ( mSymbolHeight - height ) / 2.0 ;
433+ }
423434 }
424435
425436 p->save ();
426- p->translate ( currentXPosition, currentYCoord );
437+ p->translate ( currentXPosition + widthOffset , currentYCoord + heightOffset );
427438 p->scale ( 1.0 / rasterScaleFactor, 1.0 / rasterScaleFactor );
428439
429440 if ( markerSymbol && sizeInMapUnits )
@@ -440,7 +451,8 @@ void QgsComposerLegend::drawSymbolV2( QPainter* p, QgsSymbolV2* s, double curren
440451
441452 p->restore ();
442453 currentXPosition += width;
443- symbolHeight = height;
454+ currentXPosition += 2 * widthOffset;
455+ symbolHeight = height + 2 * heightOffset;
444456}
445457
446458void QgsComposerLegend::drawPointSymbol ( QPainter* p, QgsSymbol* s, double currentYCoord, double & currentXPosition, double & symbolHeight, int opacity ) const
0 commit comments