Workaround for Adobe Digital Editions crashing when it encounters font-size: medium

This commit is contained in:
Kovid Goyal 2009-12-04 12:55:21 -07:00
parent bcf74965b5
commit ee76cfef67
3 changed files with 10 additions and 0 deletions

View File

@ -39,6 +39,12 @@
- title: "calibredb with output format stanza once again escapes URLs"
tickets: [4084]
- title: Implement work around for a CSS bug in Adobe Digital Editions that causes it to crash
description: >
If the CSS contains the declaration font-size: medium instead of font-size: normal
Adobe Digital Editions will crash. calibre will now automatically replace medium with
normal.
- title: "PML Output: Only create \\a and \\U tags for supported characters."
- title: "PML Input: Allow for images in top-level bookname_image and images directories"

View File

@ -780,6 +780,8 @@ class Manifest(object):
# In particular, it causes tostring to insert xmlns
# declarations, which messes up the coercing logic
idx = data.find('<html')
if idx == -1:
idx = data.find('<HTML')
if idx > -1:
pre = data[:idx]
data = data[idx:]

View File

@ -229,6 +229,8 @@ class CSSFlattener(object):
if 'bgcolor' in node.attrib:
cssdict['background-color'] = node.attrib['bgcolor']
del node.attrib['bgcolor']
if cssdict.get('font-weight', '').lower() == 'medium':
cssdict['font-weight'] = 'normal' # ADE chokes on font-weight medium
if not self.context.disable_font_rescaling:
_sbase = self.sbase if self.sbase is not None else \
self.context.source.fbase