Skip to content

Commit

Permalink
support non-squared svg symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Sep 17, 2012
1 parent 6589fbe commit 98a18ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/symbology-ng/qgssvgcache.cpp
Expand Up @@ -222,7 +222,17 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )

QPainter p( image );
QSvgRenderer r( entry->svgContent );
r.render( &p );
if ( r.viewBox().width() == r.viewBox().height() )
{
r.render( &p );
}
else
{
QSize s( r.viewBox().size() );
s.scale( imageSize, imageSize, Qt::KeepAspectRatio );
QRect rect(( imageSize - s.width() ) / 2, ( imageSize - s.height() ) / 2, s.width(), s.height() );
r.render( &p, rect );
}

entry->image = image;
mTotalSize += ( image->width() * image->height() * 32 );
Expand Down

0 comments on commit 98a18ef

Please sign in to comment.