mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
parent
0510da77ee
commit
2265115f80
@ -328,7 +328,13 @@ void QgsSvgCache::replaceParamsAndCacheSvg( QgsSvgCacheEntry* entry )
|
||||
entry->viewboxSize = viewboxSize;
|
||||
replaceElemParams( docElem, entry->fill, entry->outline, entry->outlineWidth * sizeScaleFactor );
|
||||
|
||||
entry->svgContent = svgDoc.toByteArray();
|
||||
entry->svgContent = svgDoc.toByteArray( 0 );
|
||||
|
||||
// toByteArray screws up tspans inside text by adding new lines before and after each span... this should help, at the
|
||||
// risk of potentially breaking some svgs where the newline is desired
|
||||
entry->svgContent.replace( "\n<tspan", "<tspan" );
|
||||
entry->svgContent.replace( "</tspan>\n", "</tspan>" );
|
||||
|
||||
mTotalSize += entry->svgContent.size();
|
||||
}
|
||||
|
||||
@ -342,16 +348,23 @@ double QgsSvgCache::calcSizeScaleFactor( QgsSvgCacheEntry* entry, const QDomElem
|
||||
|
||||
//find svg viewbox attribute
|
||||
//first check if docElem is svg element
|
||||
if ( docElem.tagName() == "svg" )
|
||||
if ( docElem.tagName() == "svg" && docElem.hasAttribute( "viewBox" ) )
|
||||
{
|
||||
viewBox = docElem.attribute( "viewBox", QString() );
|
||||
}
|
||||
else if ( docElem.tagName() == "svg" && docElem.hasAttribute( "viewbox" ) )
|
||||
{
|
||||
viewBox = docElem.attribute( "viewbox", QString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
QDomElement svgElem = docElem.firstChildElement( "svg" ) ;
|
||||
if ( !svgElem.isNull() )
|
||||
{
|
||||
viewBox = svgElem.attribute( "viewBox", QString() );
|
||||
if ( svgElem.hasAttribute( "viewBox" ) )
|
||||
viewBox = svgElem.attribute( "viewBox", QString() );
|
||||
else if ( svgElem.hasAttribute( "viewbox" ) )
|
||||
viewBox = svgElem.attribute( "viewbox", QString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,12 @@ class TestQgsComposerPicture : public QObject
|
||||
void pictureSvgFrameToImage();
|
||||
|
||||
void svgParameters();
|
||||
void issue_14644();
|
||||
|
||||
void pictureExpression();
|
||||
void pictureInvalidExpression();
|
||||
|
||||
|
||||
private:
|
||||
QgsComposition* mComposition;
|
||||
QgsComposerPicture* mComposerPicture;
|
||||
@ -387,6 +389,22 @@ void TestQgsComposerPicture::svgParameters()
|
||||
mComposerPicture->setPicturePath( mPngImage );
|
||||
}
|
||||
|
||||
void TestQgsComposerPicture::issue_14644()
|
||||
{
|
||||
//test rendering SVG file with text
|
||||
mComposition->addComposerPicture( mComposerPicture );
|
||||
mComposerPicture->setResizeMode( QgsComposerPicture::Zoom );
|
||||
mComposerPicture->setPicturePath( QString( TEST_DATA_DIR ) + "/svg/issue_14644.svg" );
|
||||
|
||||
QgsCompositionChecker checker( "composerpicture_issue_14644", mComposition );
|
||||
checker.setControlPathPrefix( "composer_picture" );
|
||||
QVERIFY( checker.testComposition( mReport, 0, 0 ) );
|
||||
|
||||
mComposition->removeItem( mComposerPicture );
|
||||
mComposerPicture->setSceneRect( QRectF( 70, 70, 100, 100 ) );
|
||||
mComposerPicture->setPicturePath( mPngImage );
|
||||
}
|
||||
|
||||
void TestQgsComposerPicture::pictureExpression()
|
||||
{
|
||||
//test picture source via expression
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
194
tests/testdata/svg/issue_14644.svg
vendored
Normal file
194
tests/testdata/svg/issue_14644.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 24 KiB |
Loading…
x
Reference in New Issue
Block a user