From b2bea092fc5641f057c0964b7a47a55f58ab9c90 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Nov 2011 21:33:00 +0530 Subject: [PATCH] Conversion pipeline: Do not error out on books that set font size to zero. Fixes #898194 (Private bug) --- src/calibre/ebooks/oeb/stylizer.py | 3 ++- src/calibre/ebooks/oeb/transforms/flatcss.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index adef0f1bfb..20be750925 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -539,7 +539,8 @@ class Style(object): 'Return value in pts' if base is None: base = self.width - font = font or self.fontSize + if not font and font != 0: + font = self.fontSize return unit_convert(value, base, font, self._profile.dpi) def pt_to_px(self, value): diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index ba90a31632..489498d90c 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -283,7 +283,10 @@ class CSSFlattener(object): psize = fsize elif 'font-size' in cssdict or tag == 'body': fsize = self.fmap[font_size] - cssdict['font-size'] = "%0.5fem" % (fsize / psize) + try: + cssdict['font-size'] = "%0.5fem" % (fsize / psize) + except ZeroDivisionError: + cssdict['font-size'] = '%.1fpt'%fsize psize = fsize try: