Beispiel #1
0
def extractUFO(pathOrFile, destination, doGlyphs=True, doInfo=True, doKerning=True, customFunctions={}):
    if isOpenType(pathOrFile):
        func = extractFontFromOpenType
        format = "OTF"
    elif isWOFF(pathOrFile):
        func = extractFontFromWOFF
        format = "WOFF"
    else:
        raise ExtractorError("Unknown file format.")
    func(pathOrFile, destination, doGlyphs=doGlyphs, doInfo=doInfo, doKerning=doKerning, customFunctions=customFunctions.get(format, []))
Beispiel #2
0
def extractUFO(pathOrFile,
               destination,
               doGlyphs=True,
               doInfo=True,
               doKerning=True,
               doGroups=True,
               doFeatures=True,
               doLib=True,
               customFunctions={}):
    if isUFO(pathOrFile):
        func = extractFontFromUFO
        format = "UFO"
    elif isOpenType(pathOrFile):
        func = extractFontFromOpenType
        format = "OTF"
    elif isType1(pathOrFile):
        func = extractFontFromType1
        format = "Type1"
    elif isWOFF(pathOrFile):
        func = extractFontFromWOFF
        format = "WOFF"
    elif isTTX(pathOrFile):
        func = extractFontFromTTX
        format = "ttx"
    elif isVFB(pathOrFile) and ".vfb" in supportedFormats:
        func = extractFontFromVFB
        format = "VFB"
    else:
        raise ExtractorError("Unknown file format.")
    # wrap the extraction in a try: except: so that
    # callers don't need to worry about lower level
    # (fontTools, woffTools, etc.) errors. if an error
    # occurs, print the traceback for debugging and
    # raise an ExtractorError.
    try:
        func(pathOrFile,
             destination,
             doGlyphs=doGlyphs,
             doInfo=doInfo,
             doKerning=doKerning,
             doGroups=doGroups,
             doFeatures=doFeatures,
             doLib=doLib,
             customFunctions=customFunctions.get(format, []))
    except:
        import sys
        import traceback
        traceback.print_exc(file=sys.stdout)
        raise ExtractorError("There was an error reading the %s file." %
                             format)
Beispiel #3
0
def extractUFO(pathOrFile, destination, doGlyphs=True, doInfo=True, doKerning=True, doGroups=True, doFeatures=True, doLib=True, customFunctions={}):
    if isUFO(pathOrFile):
        func = extractFontFromUFO
        format = "UFO"
    elif isOpenType(pathOrFile):
        func = extractFontFromOpenType
        format = "OTF"
    elif isType1(pathOrFile):
        func = extractFontFromType1
        format = "Type1"
    elif isWOFF(pathOrFile):
        func = extractFontFromWOFF
        format = "WOFF"
    elif isTTX(pathOrFile):
        func = extractFontFromTTX
        format = "ttx"
    elif isVFB(pathOrFile) and ".vfb" in supportedFormats:
        func = extractFontFromVFB
        format = "VFB"
    else:
        raise ExtractorError("Unknown file format.")
    # wrap the extraction in a try: except: so that
    # callers don't need to worry about lower level
    # (fontTools, woffTools, etc.) errors. if an error
    # occurs, print the traceback for debugging and
    # raise an ExtractorError.
    try:
        func(pathOrFile, destination,
            doGlyphs=doGlyphs, doInfo=doInfo,
            doKerning=doKerning, doGroups=doGroups,
            doFeatures=doFeatures, doLib=doLib,
            customFunctions=customFunctions.get(format, [])
        )
    except:
        import sys
        import traceback
        traceback.print_exc(file=sys.stdout)
        raise ExtractorError("There was an error reading the %s file." % format)