From 0260880952ada86f1afa1d1b4c21bd9d10b73069 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 29 Jan 2014 11:07:02 +0530 Subject: [PATCH] Edit book: Fix undo not working for subsetting fonts --- src/calibre/ebooks/oeb/polish/subset.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/subset.py b/src/calibre/ebooks/oeb/polish/subset.py index 8b03693cda..df86dc3804 100644 --- a/src/calibre/ebooks/oeb/polish/subset.py +++ b/src/calibre/ebooks/oeb/polish/subset.py @@ -38,13 +38,14 @@ def subset_all_fonts(container, font_stats, report): for name, mt in container.mime_map.iteritems(): if (mt in OEB_FONTS or name.rpartition('.')[-1].lower() in {'otf', 'ttf'}) and mt != guess_type('a.woff'): chars = font_stats.get(name, set()) - path = container.name_path_map[name] - total_old += os.path.getsize(path) + with container.open(name, 'rb') as f: + f.seek(0, os.SEEK_END) + total_old += f.tell() if not chars: remove.add(name) report('Removed unused font: %s'%name) continue - with open(path, 'r+b') as f: + with container.open(name, 'r+b') as f: raw = f.read() font_name = get_font_names(raw)[-1] warnings = []