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: