mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
31cf0040ef
commit
ebf380530d
@ -25,15 +25,22 @@ class InvalidFont(BaseError):
|
|||||||
HELP = _('This font could not be processed. It most likely will'
|
HELP = _('This font could not be processed. It most likely will'
|
||||||
' not work in an ebook reader, either')
|
' not work in an ebook reader, either')
|
||||||
|
|
||||||
def fix_declaration(style, css_name, font_name):
|
def fix_property(prop, css_name, font_name):
|
||||||
ff = style.getPropertyCSSValue('font-family')
|
|
||||||
changed = False
|
changed = False
|
||||||
if ff is not None:
|
ff = prop.propertyValue
|
||||||
for i in xrange(ff.length):
|
for i in xrange(ff.length):
|
||||||
val = ff.item(i)
|
val = ff.item(i)
|
||||||
if hasattr(val.value, 'lower') and val.value.lower() == css_name.lower():
|
if hasattr(val.value, 'lower') and val.value.lower() == css_name.lower():
|
||||||
change_font_family_value(val, font_name)
|
change_font_family_value(val, font_name)
|
||||||
changed = True
|
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
|
return changed
|
||||||
|
|
||||||
def fix_sheet(sheet, css_name, font_name):
|
def fix_sheet(sheet, css_name, font_name):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user