mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Also use the new font family parsing code in the conversion pipeline
This commit is contained in:
parent
86f114594c
commit
358ed508ce
@ -11,6 +11,7 @@ from collections import defaultdict
|
|||||||
|
|
||||||
from calibre.ebooks.oeb.base import urlnormalize
|
from calibre.ebooks.oeb.base import urlnormalize
|
||||||
from calibre.utils.fonts.sfnt.subset import subset, NoGlyphs, UnsupportedFont
|
from calibre.utils.fonts.sfnt.subset import subset, NoGlyphs, UnsupportedFont
|
||||||
|
from tinycss.fonts3 import parse_font_family
|
||||||
|
|
||||||
def get_font_properties(rule, default=None):
|
def get_font_properties(rule, default=None):
|
||||||
'''
|
'''
|
||||||
@ -27,7 +28,7 @@ def get_font_properties(rule, default=None):
|
|||||||
val = s.getProperty(q).propertyValue[0]
|
val = s.getProperty(q).propertyValue[0]
|
||||||
val = getattr(val, g)
|
val = getattr(val, g)
|
||||||
if q == 'font-family':
|
if q == 'font-family':
|
||||||
val = [x.value for x in s.getProperty(q).propertyValue if hasattr(x.value, 'lower')]
|
val = parse_font_family(s.getProperty(q).propertyValue.cssText)
|
||||||
if val and val[0] == 'inherit':
|
if val and val[0] == 'inherit':
|
||||||
val = None
|
val = None
|
||||||
except (IndexError, KeyError, AttributeError, TypeError, ValueError):
|
except (IndexError, KeyError, AttributeError, TypeError, ValueError):
|
||||||
@ -272,8 +273,7 @@ class SubsetFonts(object):
|
|||||||
'normal':['normal', 'oblique', 'italic']
|
'normal':['normal', 'oblique', 'italic']
|
||||||
}.get(fs, ['italic', 'oblique', 'normal'])
|
}.get(fs, ['italic', 'oblique', 'normal'])
|
||||||
for q in order:
|
for q in order:
|
||||||
matches = [f for f in matching_set if f.get('font-style', 'normal')
|
matches = [f for f in matching_set if f.get('font-style', 'normal') == q]
|
||||||
== q]
|
|
||||||
if matches:
|
if matches:
|
||||||
matching_set = matches
|
matching_set = matches
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user