~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/oeb/polish/font_stats.coffee

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
ImportĀ upstreamĀ versionĀ 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    ans['text'] = text
39
39
    return ans
40
40
 
 
41
process_sheet = (sheet, font_faces) ->
 
42
    for rule in sheet.cssRules
 
43
        if rule.type == rule.FONT_FACE_RULE
 
44
            process_font_face_rule(rule, font_faces)
 
45
        else if rule.type == rule.IMPORT_RULE and rule.styleSheet
 
46
            process_sheet(rule.styleSheet, font_faces)
 
47
 
 
48
process_font_face_rule = (rule, font_faces) ->
 
49
    fd = font_dict(rule.style)
 
50
    fd['src'] = rule.style.getPropertyValue('src')
 
51
    font_faces.push(fd)
 
52
 
41
53
class FontStats
42
54
    # This class is a namespace to expose functions via the
43
55
    # window.font_stats object.
49
61
    get_font_face_rules: () ->
50
62
        font_faces = []
51
63
        for sheet in document.styleSheets
52
 
            for rule in sheet.cssRules
53
 
                if rule.type == rule.FONT_FACE_RULE
54
 
                    fd = font_dict(rule.style)
55
 
                    fd['src'] = rule.style.getPropertyValue('src')
56
 
                    font_faces.push(fd)
 
64
            process_sheet(sheet, font_faces)
57
65
        py_bridge.value = font_faces
58
66
 
59
67
    get_font_usage: () ->