Edit Book: Check book: When auto-changing font name to match actual name in font file, also change the font name in shorthand font declarations

This commit is contained in:
Kovid Goyal 2014-06-12 21:20:02 +05:30
parent 31cf0040ef
commit ebf380530d

View File

@ -25,10 +25,9 @@ class InvalidFont(BaseError):
HELP = _('This font could not be processed. It most likely will'
' not work in an ebook reader, either')
def fix_declaration(style, css_name, font_name):
ff = style.getPropertyCSSValue('font-family')
def fix_property(prop, css_name, font_name):
changed = False
if ff is not None:
ff = prop.propertyValue
for i in xrange(ff.length):
val = ff.item(i)
if hasattr(val.value, 'lower') and val.value.lower() == css_name.lower():
@ -36,6 +35,14 @@ def fix_declaration(style, css_name, font_name):
changed = True
return changed
def fix_declaration(style, css_name, font_name):
changed = False
for x in ('font-family', 'font'):
prop = style.getProperty(x)
if prop is not None:
changed |= fix_property(prop, css_name, font_name)
return changed
def fix_sheet(sheet, css_name, font_name):
changed = False
for rule in sheet.cssRules: