diff --git a/dsl.cc b/dsl.cc index b8353c7c..a7a9b7c6 100644 --- a/dsl.cc +++ b/dsl.cc @@ -45,6 +45,9 @@ #include #include +// For SVG handling +#include + namespace Dsl { using namespace Details; @@ -821,10 +824,26 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) if( !imgdata.empty() ) { - QImage img = QImage::fromData( (unsigned char *) &imgdata.front(), - imgdata.size() ); - resize = maxPictureWidth > 0 - && img.width() > maxPictureWidth; + if( Filetype::isNameOfSvg( filename ) ) + { + // We don't need to render svg file now + + QSvgRenderer svg; + svg.load( QByteArray::fromRawData( imgdata.data(), imgdata.size() ) ); + if( svg.isValid() ) + { + QSize imgsize = svg.defaultSize(); + resize = maxPictureWidth > 0 + && imgsize.width() > maxPictureWidth; + } + } + else + { + QImage img = QImage::fromData( (unsigned char *) &imgdata.front(), + imgdata.size() ); + resize = maxPictureWidth > 0 + && img.width() > maxPictureWidth; + } } if( resize ) diff --git a/filetype.cc b/filetype.cc index aca3dbfc..461878e0 100644 --- a/filetype.cc +++ b/filetype.cc @@ -102,4 +102,12 @@ bool isNameOfCSS( string const & name ) endsWith( s, ".css" ); } +bool isNameOfSvg( string const & name ) +{ + string s = simplifyString( name ); + + return + endsWith( s, ".svg" ); +} + } diff --git a/filetype.hh b/filetype.hh index 30379f96..07b7fa75 100644 --- a/filetype.hh +++ b/filetype.hh @@ -23,6 +23,8 @@ bool isNameOfPicture( string const & ); bool isNameOfTiff( string const & ); /// Returns true if the name resembles the one of a .css file bool isNameOfCSS( string const & ); +/// Returns true if the name resembles the one of a .svg file +bool isNameOfSvg( string const & name ); } diff --git a/goldendict.pro b/goldendict.pro index 256dca4b..badf9065 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -22,6 +22,7 @@ INCLUDEPATH += . QT += webkit QT += xml QT += network +QT += svg CONFIG += exceptions \ rtti \ stl