mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Add support for SVG images
This commit is contained in:
parent
d54c1a867e
commit
de2e424c88
@ -34,6 +34,6 @@ function extract_svged_images() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
extract_svged_images();
|
//extract_svged_images();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ from base64 import b64encode
|
|||||||
from PyQt4.Qt import QSize, QSizePolicy, QUrl, SIGNAL, Qt, QTimer, \
|
from PyQt4.Qt import QSize, QSizePolicy, QUrl, SIGNAL, Qt, QTimer, \
|
||||||
QPainter, QPalette, QBrush, QFontDatabase, QDialog, \
|
QPainter, QPalette, QBrush, QFontDatabase, QDialog, \
|
||||||
QColor, QPoint, QImage, QRegion, QVariant, QIcon, \
|
QColor, QPoint, QImage, QRegion, QVariant, QIcon, \
|
||||||
QFont, pyqtSignature, QAction
|
QFont, pyqtSignature, QAction, QByteArray
|
||||||
from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings
|
from PyQt4.QtWebKit import QWebPage, QWebView, QWebSettings
|
||||||
|
|
||||||
from calibre.utils.config import Config, StringConfig
|
from calibre.utils.config import Config, StringConfig
|
||||||
@ -514,13 +514,16 @@ class DocumentView(QWebView):
|
|||||||
mt = guess_type(path)[0]
|
mt = guess_type(path)[0]
|
||||||
html = open(path, 'rb').read().decode(path.encoding, 'replace')
|
html = open(path, 'rb').read().decode(path.encoding, 'replace')
|
||||||
html = EntityDeclarationProcessor(html).processed_html
|
html = EntityDeclarationProcessor(html).processed_html
|
||||||
|
has_svg = re.search(r'<\S*svg', html) is not None
|
||||||
|
|
||||||
if 'xhtml' in mt:
|
if 'xhtml' in mt:
|
||||||
html = self.self_closing_pat.sub(self.self_closing_sub, html)
|
html = self.self_closing_pat.sub(self.self_closing_sub, html)
|
||||||
if self.manager is not None:
|
if self.manager is not None:
|
||||||
self.manager.load_started()
|
self.manager.load_started()
|
||||||
self.loading_url = QUrl.fromLocalFile(path)
|
self.loading_url = QUrl.fromLocalFile(path)
|
||||||
#self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path))
|
if has_svg:
|
||||||
#open('/tmp/t.html', 'wb').write(html.encode(path.encoding))
|
self.setContent(QByteArray(html.encode(path.encoding)), mt, QUrl.fromLocalFile(path))
|
||||||
|
else:
|
||||||
self.setHtml(html, self.loading_url)
|
self.setHtml(html, self.loading_url)
|
||||||
self.turn_off_internal_scrollbars()
|
self.turn_off_internal_scrollbars()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user