Skip to content

Commit 98a18ef

Browse files
committed
support non-squared svg symbols
1 parent 6589fbe commit 98a18ef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/core/symbology-ng/qgssvgcache.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,17 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )
222222

223223
QPainter p( image );
224224
QSvgRenderer r( entry->svgContent );
225-
r.render( &p );
225+
if ( r.viewBox().width() == r.viewBox().height() )
226+
{
227+
r.render( &p );
228+
}
229+
else
230+
{
231+
QSize s( r.viewBox().size() );
232+
s.scale( imageSize, imageSize, Qt::KeepAspectRatio );
233+
QRect rect(( imageSize - s.width() ) / 2, ( imageSize - s.height() ) / 2, s.width(), s.height() );
234+
r.render( &p, rect );
235+
}
226236

227237
entry->image = image;
228238
mTotalSize += ( image->width() * image->height() * 32 );

0 commit comments

Comments
 (0)