From 2d8c856e7cf250b2a98af58d2d2215a54ed5434a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 24 Nov 2014 19:05:03 +0530 Subject: [PATCH] Book polishing: Ignore zero byte font files in the ebook instead of erroring out on them when subsetting fonts. Fixes #1395694 [Polish failing with errors](https://bugs.launchpad.net/calibre/+bug/1395694) --- src/calibre/ebooks/oeb/polish/subset.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/polish/subset.py b/src/calibre/ebooks/oeb/polish/subset.py index fb8c8daba4..6eccf6eb2c 100644 --- a/src/calibre/ebooks/oeb/polish/subset.py +++ b/src/calibre/ebooks/oeb/polish/subset.py @@ -48,7 +48,13 @@ def subset_all_fonts(container, font_stats, report): continue with container.open(name, 'r+b') as f: raw = f.read() - font_name = get_font_names(raw)[-1] + try: + font_name = get_font_names(raw)[-1] + except Exception as e: + container.log.warning( + 'Corrupted font: %s, ignoring. Error: %s'%( + name, as_unicode(e))) + continue warnings = [] container.log('Subsetting font: %s'%(font_name or name)) try: