How to use the afdko.fdkutils.get_temp_file_path function in afdko

To help you get started, we’ve selected a few afdko examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adobe-type-tools / afdko / tests / test_utils.py View on Github external
def generalizeCFF(otfPath, do_sfnt=True):
    """
    Adapted from similar routine in 'buildmasterotfs'. This uses
    temp files for both tx output and sfntedit output instead of
    overwriting 'otfPath', and also provides an option to skip
    the sfntedit step (so 'otfPath' can be either a .otf file or
    a .cff file).
    """
    tmp_tx_path = get_temp_file_path()
    out_path = get_temp_file_path()
    shutil.copyfile(otfPath, out_path, follow_symlinks=True)

    if not run_shell_command(['tx', '-cff', '+b', '-std', '-no_opt',
                              otfPath, tmp_tx_path]):
        raise Exception

    if do_sfnt:

        if not run_shell_command(['sfntedit', '-a',
                                  f'CFF ={tmp_tx_path}', out_path]):
            raise Exception

        return out_path

    else:
github adobe-type-tools / afdko / tests / test_utils.py View on Github external
def generalizeCFF(otfPath, do_sfnt=True):
    """
    Adapted from similar routine in 'buildmasterotfs'. This uses
    temp files for both tx output and sfntedit output instead of
    overwriting 'otfPath', and also provides an option to skip
    the sfntedit step (so 'otfPath' can be either a .otf file or
    a .cff file).
    """
    tmp_tx_path = get_temp_file_path()
    out_path = get_temp_file_path()
    shutil.copyfile(otfPath, out_path, follow_symlinks=True)

    if not run_shell_command(['tx', '-cff', '+b', '-std', '-no_opt',
                              otfPath, tmp_tx_path]):
        raise Exception

    if do_sfnt:

        if not run_shell_command(['sfntedit', '-a',
                                  f'CFF ={tmp_tx_path}', out_path]):
            raise Exception

        return out_path

    else:
github adobe-type-tools / afdko / python / afdko / makeotf.py View on Github external
glyphList = re.findall(r"glyph[^{]+?{([^,]+),[^[\]]+\sseac\s",
                               output)
        if glyphList:
            glyphList = ", ".join(glyphList)
            print("makeotf [Warning] Font at '%s' contains deprecated "
                  "SEAC operator. These composite glyphs will be "
                  "decomposed by makeOTF:\n%s" % (filePath, glyphList))
            needsConversion = True
            needsSEACRemoval = True

    if needsConversion:
        fontPath = fdkutils.get_temp_file_path()

        if isTextPS:
            tempTxtPath = fdkutils.get_temp_file_path()

            # convert PS decrypted to PS encrypted with 'type1'
            if not fdkutils.run_shell_command([
                    'type1', filePath, tempTxtPath]):
                raise MakeOTFShellError
            filePath = tempTxtPath

        if needsSEACRemoval:
            tempSeacPath = fdkutils.get_temp_file_path()

            # convert to CFF using 'tx'
            if not fdkutils.run_shell_command([
                    'tx', '-cff', '-Z', '+b', filePath, tempSeacPath]):
                raise MakeOTFShellError
            filePath = tempSeacPath
github adobe-type-tools / afdko / python / afdko / buildmasterotfs.py View on Github external
def generalizeCFF(otfPath):
    tempFilePath = get_temp_file_path()

    if not run_shell_command(['tx', '-cff', '+b', '-std', '-no_opt',
                              otfPath, tempFilePath]):
        raise ShellCommandError

    if not run_shell_command(['sfntedit', '-a',
                              f'CFF ={tempFilePath}', otfPath]):
        raise ShellCommandError
github adobe-type-tools / afdko / python / afdko / makeotf.py View on Github external
def writeTempGOADB(srcGOADBList):
    fpath = fdkutils.get_temp_file_path()
    with open(fpath, "w") as fp:
        for entry in srcGOADBList:
            fp.write("%s\t%s\t%s\n" % (entry[0], entry[1], entry[2]))
    return fpath
github adobe-type-tools / afdko / python / afdko / convertfonttocid.py View on Github external
def merge_fonts(inputFontPath, outputPath, fontList, glyphList, fontDictList,
                fdGlyphDict):
    cidfontinfoPath = fdkutils.get_temp_file_path()
    makeCIDFontInfo(inputFontPath, cidfontinfoPath)
    lastFont = ""
    dstPath = ''

    for i, fontPath in enumerate(fontList):
        gaPath = fdkutils.get_temp_file_path()
        dstPath = fdkutils.get_temp_file_path()
        removeNotdef = i != 0
        makeGAFile(gaPath, fontPath, glyphList, fontDictList, fdGlyphDict,
                   removeNotdef)
        if lastFont:
            command = 'mergefonts -std -cid "%s" "%s" "%s" "%s" "%s" 2>&1' % (
                cidfontinfoPath, dstPath, lastFont, gaPath, fontPath)
        else:
            command = 'mergefonts -std -cid "%s" "%s" "%s" "%s" 2>&1' % (
                cidfontinfoPath, dstPath, gaPath, fontPath)
        log = fdkutils.runShellCmd(command)
        if "rror" in log:
            raise FontInfoParseError(
                "Error running command '%s'\nLog: %s" % (command, log))

        lastFont = dstPath
github adobe-type-tools / afdko / python / afdko / ufotools.py View on Github external
familyName = fiMap["openTypeNamePreferredFamilyName"]
    except KeyError:
        try:
            familyName = fiMap["familyName"]
        except KeyError:
            print("ufotools [Warning] UFO font is missing 'familyName'")

    try:
        styleName = fiMap["openTypeNamePreferredSubfamilyName"]
    except KeyError:
        try:
            styleName = fiMap["styleName"]
        except KeyError:
            print("ufotools [Warning] UFO font is missing 'styleName'")

    fmndbPath = fdkutils.get_temp_file_path()
    parts = []
    parts.append("[%s]" % (psName))
    parts.append("\tf=%s" % (familyName))
    parts.append("\ts=%s" % (styleName))
    parts.append("")
    data = '\n'.join(parts)
    with open(fmndbPath, "w") as fp:
        fp.write(data)
    return fmndbPath
github adobe-type-tools / afdko / python / afdko / makeotf.py View on Github external
_check_remove_bad_output(outputPath)

    # The following check is here because of the internal Adobe
    # production process for CID fonts, where a Type1 CID font
    # is made with the FSType from the cidfontinfo file, and can
    # be a product independent of the OpenType font. Need to make
    # sure that CID font FSType is the same as the table fsType.
    if hasattr(makeOTFParams, 'FSType'):
        checkFSTypeValue(makeOTFParams.FSType, outputPath)

    # If we need to convert this to a CID keyed font,
    # we do this as a post processing step on the OTF.
    # NOTE: See comment about font.pfa below.
    if doConvertToCID == "true":
        print("Converting CFF table to CID-keyed CFF...")
        tempPath = fdkutils.get_temp_file_path()
        try:
            doSubr = 'true' == getattr(makeOTFParams, kFileOptPrefix + kDoSubr)

            if kMOTFOptions[kDoSubr][0] == kOptionNotSeen:
                doSubr = 'true' == getattr(makeOTFParams,
                                           kFileOptPrefix + kRelease)
            # Send the font.pfa file to convertfonttocid.py
            # rather than the OTF because the GlyphSet
            # definitions in the 'fontinfo' files use production
            # glyph names not final glyph names.
            convertfonttocid.convertFontToCID(
                outputPath, tempPath, makeOTFParams.fontinfoPath)
            convertfonttocid.mergeFontToCFF(tempPath, outputPath, doSubr)

        except(convertfonttocid.FontInfoParseError,
               convertfonttocid.FontParseError):
github adobe-type-tools / afdko / python / afdko / ttxn.py View on Github external
def shellcmd(cmdList):
    # In all cases, assume that cmdList does NOT specify the output file.
    # I use this because tx -dump -6 can be very large.
    tempPath = get_temp_file_path()
    cmdList.append(tempPath)
    subprocess.check_call(cmdList)
    with open(tempPath, "r", encoding="utf-8") as fp:
        data = fp.read()
    return data