| 1 | from opentype import extractOpenTypeInfo, extractOpenTypeGlyphs, extractOpenTypeKerning |
|---|
| 2 | |
|---|
| 3 | # ---------------- |
|---|
| 4 | # Public Functions |
|---|
| 5 | # ---------------- |
|---|
| 6 | |
|---|
| 7 | def 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 | |
|---|
| 16 | def 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 | |
|---|
| 36 | def extractWOFFInfo(source, destination): |
|---|
| 37 | return extractOpenTypeInfo(source, destination) |
|---|
| 38 | |
|---|
| 39 | def extractWOFFGlyphs(source, destination): |
|---|
| 40 | return extractOpenTypeGlyphs(source, destination) |
|---|
| 41 | |
|---|
| 42 | def extractWOFFKerning(source, destination): |
|---|
| 43 | return extractOpenTypeKerning(source, destination) |
|---|