From 825045db71bb0540555e83a5438d06f6918b23db Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 17 Jun 2009 12:17:15 -0700 Subject: [PATCH] Fix #2644 (KeyError: 0) --- src/calibre/ebooks/oeb/transforms/flatcss.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index c726ae30c9..49119ecb9b 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -205,7 +205,12 @@ class CSSFlattener(object): fnums = self.context.source.fnums if size[0] in ('+', '-'): # Oh, the warcrimes - cssdict['font-size'] = fnums[3+int(size)] + esize = 3 + int(size) + if esize < 1: + esize = 1 + if esize > 7: + esize = 7 + cssdict['font-size'] = fnums[esize] else: cssdict['font-size'] = fnums[int(size)] del node.attrib['size']