mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Preload embedded fonts so that the preview panel works off the bat
This commit is contained in:
parent
6e9f48b175
commit
5c6ec901da
@ -18,7 +18,7 @@ from calibre import prints, prepare_string_for_xml
|
|||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.ebooks.oeb.base import urlnormalize
|
from calibre.ebooks.oeb.base import urlnormalize
|
||||||
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
|
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
|
||||||
from calibre.ebooks.oeb.polish.container import get_container as _gc, clone_container, guess_type
|
from calibre.ebooks.oeb.polish.container import get_container as _gc, clone_container, guess_type, OEB_FONTS
|
||||||
from calibre.ebooks.oeb.polish.cover import mark_as_cover, mark_as_titlepage
|
from calibre.ebooks.oeb.polish.cover import mark_as_cover, mark_as_titlepage
|
||||||
from calibre.ebooks.oeb.polish.pretty import fix_all_html, pretty_all
|
from calibre.ebooks.oeb.polish.pretty import fix_all_html, pretty_all
|
||||||
from calibre.ebooks.oeb.polish.replace import rename_files, replace_file
|
from calibre.ebooks.oeb.polish.replace import rename_files, replace_file
|
||||||
@ -36,7 +36,16 @@ from calibre.gui2.tweak_book.preferences import Preferences
|
|||||||
|
|
||||||
def get_container(*args, **kwargs):
|
def get_container(*args, **kwargs):
|
||||||
kwargs['tweak_mode'] = True
|
kwargs['tweak_mode'] = True
|
||||||
return _gc(*args, **kwargs)
|
container = _gc(*args, **kwargs)
|
||||||
|
# We preload the embedded fonts from this book, so that the preview panel
|
||||||
|
# works
|
||||||
|
font_cache.remove_fonts()
|
||||||
|
for name, mt in container.mime_map.iteritems():
|
||||||
|
if mt in OEB_FONTS and container.exists(name):
|
||||||
|
with container.open(name, 'rb') as f:
|
||||||
|
raw = f.read()
|
||||||
|
font_cache.add_font(raw)
|
||||||
|
return container
|
||||||
|
|
||||||
class BusyCursor(object):
|
class BusyCursor(object):
|
||||||
|
|
||||||
@ -167,7 +176,6 @@ class Boss(QObject):
|
|||||||
parse_worker.clear()
|
parse_worker.clear()
|
||||||
container = job.result
|
container = job.result
|
||||||
set_current_container(container)
|
set_current_container(container)
|
||||||
font_cache.remove_fonts()
|
|
||||||
self.current_metadata = self.gui.current_metadata = container.mi
|
self.current_metadata = self.gui.current_metadata = container.mi
|
||||||
self.global_undo.open_book(container)
|
self.global_undo.open_book(container)
|
||||||
self.gui.update_window_title()
|
self.gui.update_window_title()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user