source: packages/extractor/branches/ufo3/Lib/extractor/formats/woff.py @ 1137

Revision 1137, 1.3 KB checked in by tal, 15 months ago (diff)
Oops.
Line 
1from opentype import extractOpenTypeInfo, extractOpenTypeGlyphs, extractOpenTypeKerning
2
3# ----------------
4# Public Functions
5# ----------------
6
7def isWOFF(pathOrFile):
8    from woffTools import WOFFFont, WOFFLibError
9    try:
10        font = WOFFFont(pathOrFile)
11        del font
12    except WOFFLibError:
13        return False
14    return True
15
16def extractFontFromWOFF(pathOrFile, destination, doGlyphs=True, doInfo=True, doKerning=True, customFunctions=[]):
17    from woffTools import WOFFFont
18    source = WOFFFont(pathOrFile)
19    if doInfo:
20        extractWOFFInfo(source, destination)
21    if doGlyphs:
22        extractWOFFGlyphs(source, destination)
23    if doKerning:
24        kerning, groups = extractWOFFKerning(source, destination)
25        destination.groups.update(groups)
26        destination.kerning.clear()
27        destination.kerning.update(kerning)
28    for function in customFunctions:
29        function(source, destination)
30    source.close()
31
32# ----------------
33# Specific Imports
34# ----------------
35
36def extractWOFFInfo(source, destination):
37    return extractOpenTypeInfo(source, destination)
38
39def extractWOFFGlyphs(source, destination):
40    return extractOpenTypeGlyphs(source, destination)
41
42def extractWOFFKerning(source, destination):
43    return extractOpenTypeKerning(source, destination)
Note: See TracBrowser for help on using the repository browser.