mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Fix subsetting embedded fonts not processing fonts included in a stylesheet that is itself referenced only by an @import rule
This commit is contained in:
parent
84a1eb96fa
commit
2d96b9a835
Binary file not shown.
@ -38,6 +38,18 @@ font_usage = (node) ->
|
|||||||
ans['text'] = text
|
ans['text'] = text
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
process_sheet = (sheet, font_faces) ->
|
||||||
|
for rule in sheet.cssRules
|
||||||
|
if rule.type == rule.FONT_FACE_RULE
|
||||||
|
process_font_face_rule(rule, font_faces)
|
||||||
|
else if rule.type == rule.IMPORT_RULE and rule.styleSheet
|
||||||
|
process_sheet(rule.styleSheet, font_faces)
|
||||||
|
|
||||||
|
process_font_face_rule = (rule, font_faces) ->
|
||||||
|
fd = font_dict(rule.style)
|
||||||
|
fd['src'] = rule.style.getPropertyValue('src')
|
||||||
|
font_faces.push(fd)
|
||||||
|
|
||||||
class FontStats
|
class FontStats
|
||||||
# This class is a namespace to expose functions via the
|
# This class is a namespace to expose functions via the
|
||||||
# window.font_stats object.
|
# window.font_stats object.
|
||||||
@ -49,11 +61,7 @@ class FontStats
|
|||||||
get_font_face_rules: () ->
|
get_font_face_rules: () ->
|
||||||
font_faces = []
|
font_faces = []
|
||||||
for sheet in document.styleSheets
|
for sheet in document.styleSheets
|
||||||
for rule in sheet.cssRules
|
process_sheet(sheet, font_faces)
|
||||||
if rule.type == rule.FONT_FACE_RULE
|
|
||||||
fd = font_dict(rule.style)
|
|
||||||
fd['src'] = rule.style.getPropertyValue('src')
|
|
||||||
font_faces.push(fd)
|
|
||||||
py_bridge.value = font_faces
|
py_bridge.value = font_faces
|
||||||
|
|
||||||
get_font_usage: () ->
|
get_font_usage: () ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user