From d10a1a0b9019d193e1d8047224e82bc0cb1e73de Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 Feb 2013 11:15:49 +0530 Subject: [PATCH] Conversion: Do not rescale fonts sizes/adjust line heights for text based drop caps defined using a separate tag (note that drop caps defined using :first-letter were already handled correctly) --- src/calibre/ebooks/oeb/transforms/flatcss.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index 03410e1a65..f2a0b1f2ea 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -363,7 +363,10 @@ class CSSFlattener(object): cssdict['font-weight'] = 'normal' # ADE chokes on font-weight medium fsize = font_size - if not self.context.disable_font_rescaling: + 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) + 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 dyn_rescale = dynamic_rescale_factor(node) @@ -382,7 +385,7 @@ class CSSFlattener(object): try: minlh = self.context.minimum_line_height / 100. - if style['line-height'] < minlh * fsize: + if not is_drop_cap and style['line-height'] < minlh * fsize: cssdict['line-height'] = str(minlh) except: self.oeb.logger.exception('Failed to set minimum line-height')