From aefab3b47abfb4077e7c58cd83a4f452ffd99b7f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 18 Jul 2013 13:30:44 +0530 Subject: [PATCH] Fix regression that caused rescaling of ont size in dropcaps generated by the DOCX input plugin --- src/calibre/ebooks/oeb/transforms/flatcss.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 9c08934938..1b678a3fe5 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -371,11 +371,13 @@ class CSSFlattener(object): is_drop_cap = (cssdict.get('float', None) == 'left' and 'font-size' in cssdict and len(node) == 0 and node.text and len(node.text) == 1) - is_drop_cap = is_drop_cap or ( - # The docx input plugin generates drop caps that look like this - len(node) == 1 and not node.text and len(node[0]) == 0 and - node[0].text and not node[0].tail and len(node[0].text) == 1 and - 'line-height' in cssdict and 'font-size' in cssdict) + # Detect drop caps generated by the docx input plugin + if (node.tag and node.tag.endswith('}p') and len(node) == 0 and node.text and len(node.text.strip()) == 1 and + not node.tail and 'line-height' in cssdict and 'font-size' in cssdict): + dp = node.getparent() + if dp.tag and dp.tag.endswith('}div') and len(dp) == 1 and not dp.text: + if stylizer.style(dp).cssdict().get('float', None) == 'left': + is_drop_cap = True if not self.context.disable_font_rescaling and not is_drop_cap: _sbase = self.sbase if self.sbase is not None else \ self.context.source.fbase