本文整理汇总了Python中FDKUtils.runShellCmd方法的典型用法代码示例。如果您正苦于以下问题:Python FDKUtils.runShellCmd方法的具体用法?Python FDKUtils.runShellCmd怎么用?Python FDKUtils.runShellCmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FDKUtils
的用法示例。
在下文中一共展示了FDKUtils.runShellCmd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mergeFonts
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def mergeFonts(inputFontPath, outputPath, fontList, glyphList, fontDictList, fdGlyphDict):
cidfontinfoPath = "%s.temp.cidfontinfo" % (inputFontPath)
makeCIDFontInfo(inputFontPath, cidfontinfoPath)
lastFont =""
tempfileList = []
i = 0
print "Merging temp fonts:",
for fontPath in fontList:
print ".",
sys.stdout.flush()
gaPath = fontPath + ".ga"
dstPath = "%s.temp.merge.%s" % (inputFontPath, i)
removeNotdef = i != 0
makeGAFile(gaPath, fontPath, glyphList, fontDictList, fdGlyphDict, removeNotdef)
command = "mergeFonts -std -cid \"%s\" \"%s\" %s %s %s 2>&1" % (cidfontinfoPath, dstPath, lastFont, gaPath, fontPath)
log = FDKUtils.runShellCmd(command)
if debug:
print command
print log
if "rror" in log:
msg = "Error merging font %s. Log: %s." % (fontPath, log)
raise FontInfoParseError(msg)
i += 1
lastFont = dstPath
tempfileList.append(gaPath)
tempfileList.append(dstPath)
print ""
os.rename(dstPath, outputPath)
if not debug:
for path in tempfileList:
if os.path.exists(path):
os.remove(path)
os.remove(cidfontinfoPath)
return
示例2: CheckEnvironment
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def CheckEnvironment():
txPath = 'tx'
txError = 0
command = "%s -u 2>&1" % (txPath)
report = FDKUtils.runShellCmd(command)
if "options" not in report:
txError = 1
if txError:
logMsg("Please re-install the FDK. The path to the program 'tx' is not in the environment variable PATH.")
raise FDKEnvironmentError
command = "checkoutlinesexe -u 2>&1"
report = FDKUtils.runShellCmd(command)
if "version" not in report:
logMsg("Please re-install the FDK. The path to the program 'checkoutlinesexe' is not in the environment variable PATH.")
raise FDKEnvironmentError
return
示例3: getBlueFuzz
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def getBlueFuzz(fPath):
blueFuzz = 1.0
command = "tx -dump -0 %s 2>&1" % (fPath)
data = FDKUtils.runShellCmd(command)
if not data:
raise FontInfoParseError("Error: Failed getting log from tx from %, when trying to get FontName." % (fPath))
m = re.search(r"BlueFuzz\s+(\d+(?:\.\d+)*)", data)
if m:
blueFuzz = int(m.group(1))
return blueFuzz
示例4: getFontName
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def getFontName(fPath):
command = "tx -dump -0 %s 2>&1" % (fPath)
data = FDKUtils.runShellCmd(command)
if not data:
raise FontInfoParseError("Error: Failed getting log from tx from %, when tryin to get FontName." % (fPath))
m = re.search(r"FontName\s+\"([^\"]+)", data)
if not m:
print data
raise FontInfoParseError("Error: Failed finding FontName in tx log from %s." % (fPath))
return m.group(1)
示例5: saveChanges
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def saveChanges(self):
ttFont = self.ttFont
fontType = self.fontType
inputPath = self.inputPath
outFilePath = self.outFilePath
overwriteOriginal = 0
if inputPath == outFilePath:
overwriteOriginal = 1
tempPath = inputPath + ".temp.ac"
if fontType == 0: # OTF
if overwriteOriginal:
ttFont.save(tempPath)
ttFont.close()
if os.path.exists(inputPath):
try:
os.remove(inputPath)
os.rename(tempPath, inputPath)
except (OSError, IOError):
self.logMsg( "\t%s" %(traceback.format_exception_only(sys.exc_type, sys.exc_value)[-1]))
self.logMsg("Error: could not overwrite original font file path '%s'. Hinted font file path is '%s'." % (inputPath, tempPath))
else:
ttFont.save(outFilePath)
ttFont.close()
else:
data = ttFont["CFF "].compile(ttFont)
if fontType == 1: # CFF
if overwriteOriginal:
tf = file(tempPath, "wb")
tf.write(data)
tf.close()
os.rename(tempPath, inputPath)
else:
tf = file(outFilePath, "wb")
tf.write(data)
tf.close()
elif fontType == 2: # PS.
tf = file(tempPath, "wb")
tf.write(data)
tf.close()
finalPath = outFilePath
command="tx -t1 -std \"%s\" \"%s\" 2>&1" % (tempPath, outFilePath)
report = FDKUtils.runShellCmd(command)
self.logMsg(report)
if "fatal" in report:
raise IOError("Failed to convert hinted font temp file with tx %s. Maybe target font font file '%s' is set to read-only." % (tempPath, outFilePath))
if os.path.exists(tempPath):
os.remove(tempPath)
示例6: getFontBBox
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def getFontBBox(fPath):
fontBBox = [-200, -200,1000,100]
command = "tx -dump -0 %s 2>&1" % (fPath)
data = FDKUtils.runShellCmd(command)
if not data:
raise FontInfoParseError("Error: Failed getting log from tx from %, when tryingg to get FontBBox." % (fPath))
m = re.search(r"FontBBox[^{]+{([^}]+)}", data)
if not m:
print data
raise FontInfoParseError("Error: Failed finding FontBBox in tx log from %s." % (fPath))
fontBBox = m.group(1).split(",")
fontBBox = map(int, fontBBox)
return fontBBox
示例7: mergeFontToCFF
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def mergeFontToCFF(srcPath, outputPath, doSubr):
# We assume that srcPath is a type 1 font,and outputPath is an OTF font.
# First, convert src font to cff, and subroutinize it if so requested.
tempPath = srcPath + ".temp.cff"
subrArg = ""
if doSubr:
subrArg=" +S"
command="tx -cff +b%s \"%s\" \"%s\" 2>&1" % (subrArg, srcPath, tempPath)
report = FDKUtils.runShellCmd(command)
if ("fatal" in report) or ("error" in report):
print report
raise FontInfoParseError("Failed to convert font '%s' to CFF." % (fontPath))
# Now merge it into the output file.
command="sfntedit -a CFF=\"%s\" \"%s\" 2>&1" % (tempPath, outputPath)
report = FDKUtils.runShellCmd(command)
if not debug:
if os.path.exists(tempPath):
os.remove(tempPath)
if ("fatal" in report) or ("error" in report):
print report
raise FontInfoParseError("Failed to convert font '%s' to CFF." % (fontPath))
示例8: CheckEnvironment
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def CheckEnvironment():
txPath = 'tx'
txError = 0
command = "%s -u 2>&1" % (txPath)
report = FDKUtils.runShellCmd(command)
if "options" not in report:
txError = 1
if txError:
logMsg("Please re-install the FDK. The executable directory \"%s\" is missing the tool: < %s >." % (exe_dir, txPath ))
logMsg("or the files referenced by the shell script is missing.")
raise FDKEnvironmentError
return txPath
示例9: getGlyphList
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def getGlyphList(fPath, removeNotdef = 0):
command = "tx -dump -4 %s 2>&1" % (fPath)
data = FDKUtils.runShellCmd(command)
if not data:
print "Error: Failed getting glyph names from %s with tx." % (fPath)
return []
nameList = re.findall(r"[\r\n]glyph.+?{([^,]+),", data) # initial newline keeps us from picking up the first column header line
if not nameList:
print "Error: Failed getting glyph names from %s with tx." % (fPath)
print data
return []
if removeNotdef:
nameList.remove(".notdef")
return nameList
示例10: makeCIDFontInfo
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def makeCIDFontInfo(fontPath, cidfontinfoPath):
cfiDict = {}
for key in kRequiredCIDFontInfoFields + kOptionalFields:
cfiDict[key] = None
cfiDict["Weight"] = "(Regular)"
cfiDict["AdobeCopyright"] = "0"
# get regular FontDict.
command="tx -0 \"%s\" 2>&1" % (fontPath)
report = FDKUtils.runShellCmd(command)
if ("fatal" in report) or ("error" in report):
print report
raise FontInfoParseError("Failed to dump font dict using tx from font '%s'" % (fontPath))
for entry in txFields:
match = re.search(entry[0]+ "\s+(.+?)[\r\n]", report)
if match:
entry[2] = match.group(1)
cfiDict["Registry"] = "Adobe"
cfiDict["Ordering"] = "Identity"
cfiDict["Supplement"] = "0"
for entry in txFields:
if entry[2]:
cfiDict[entry[1]] = entry[2]
elif entry[1] in kRequiredCIDFontInfoFields:
haveError = 1
print "Error: did not find required info '%s' in tx dump of font '%s'." % (entry[1], fontPath)
try:
fp = open(cidfontinfoPath, "wt")
for key in kCIDFontInfokeyList:
value = cfiDict[key]
if value == None:
continue
if value[0] == "\"":
value = "(" + value[1:-1] + ")"
string = "%s\t%s" % (key, value)
fp.write(string + os.linesep)
fp.write(os.linesep)
fp.close()
except (IOError, OSError):
msg = "Error. Could not open and write file '%s'" % (cidfontinfoPath)
raise FontInfoParseError(msg)
return
示例11: CheckEnvironment
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def CheckEnvironment():
txPath = 'tx'
txError = 0
try:
exe_dir, fdkSharedDataDir = FDKUtils.findFDKDirs()
except FDKUtils.FDKEnvError:
logMsg("Please re-install the FDK. Cannot find the FDK/Tools/SharedData directory.")
raise FDKEnvironmentError
command = "%s -u 2>&1" % (txPath)
report = FDKUtils.runShellCmd(command)
if "options" not in report:
txError = 1
if txError:
logMsg("Please re-install the FDK. The executable directory \"%s\" is missing the tool: < %s >." % (exe_dir, txPath ))
logMsg("or the files referenced by the shell script is missing.")
raise FDKEnvironmentError
return txPath, fdkSharedDataDir
示例12: openFile
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def openFile(path, txPath):
# If input font is CFF or PS, build a dummy ttFont.
tempPathCFF = None
cffPath = None
# If it is CID-keyed font, we need to convert it to a name-keyed font. This is a hack, but I really don't want to add CID support to
# the very simple-minded PDF library.
command="%s -dump -0 \"%s\" 2>&1" % (txPath, path)
report = FDKUtils.runShellCmd(command)
if "CIDFontName" in report:
tfd,tempPath1 = tempfile.mkstemp()
os.close(tfd)
command="%s -t1 -decid -usefd 0 \"%s\" \"%s\" 2>&1" % (txPath, path, tempPath1)
report = FDKUtils.runShellCmd(command)
if "fatal" in report:
logMsg(report)
logMsg("Failed to convert CID-keyed font %s to a temporary Typ1 data file." % path)
tfd,tempPathCFF = tempfile.mkstemp()
os.close(tfd)
command="%s -cff +b \"%s\" \"%s\" 2>&1" % (txPath, tempPath1, tempPathCFF)
report = FDKUtils.runShellCmd(command)
if "fatal" in report:
logMsg(report)
logMsg("Failed to convert CID-keyed font %s to a temporary CFF data file." % path)
cffPath = tempPathCFF
os.remove(tempPath1)
elif os.path.isdir(path):
# See if it is a UFO font by truing to dump it.
command="%s -dump -0 \"%s\" 2>&1" % (txPath, path)
report = FDKUtils.runShellCmd(command)
if not "sup.srcFontType" in report:
logMsg(report)
logMsg("Failed to open directory %s as a UFO font." % path)
tfd,tempPathCFF = tempfile.mkstemp()
os.close(tfd)
command="%s -cff +b \"%s\" \"%s\" 2>&1" % (txPath, path, tempPathCFF)
report = FDKUtils.runShellCmd(command)
if "fatal" in report:
logMsg(report)
logMsg("Failed to convert ufo font %s to a temporary CFF data file." % path)
cffPath = tempPathCFF
else:
try:
ff = file(path, "rb")
data = ff.read(10)
ff.close()
except (IOError, OSError):
import traceback
traceback.print_exc()
raise FontError("Failed to open and read font file %s. Check file/directory permissions." % path)
if len(data) < 10:
raise FontError("Error: font file was zero size: may be a resource fork font, which this program does not process. <%s>." % path)
if (data[:4] == "OTTO") or (data[:4] == "true") or (data[:4] == "\0\1\0\0"): # it is an OTF/TTF font, can process file directly
try:
ttFont = ttLib.TTFont(path)
except (IOError, OSError):
raise FontError("Error opening or reading from font file <%s>." % path)
except TTLibError:
raise FontError("Error parsing font file 333 <%s>." % path)
if not (ttFont.has_key('CFF ') or ttFont.has_key('glyf')):
raise FontError("Error: font is not a CFF or TrueType font <%s>." % path)
return ttFont, tempPathCFF
# It is not an OTF file.
if (data[0] == '\1') and (data[1] == '\0'): # CFF file
cffPath = path
elif not "%" in data:
#not a PS file either
logMsg("Font file must be a PS, CFF or OTF fontfile: %s." % path)
raise FontError("Font file must be PS, CFF or OTF file: %s." % path)
else: # It is a PS file. Convert to CFF.
tfd,tempPathCFF = tempfile.mkstemp()
os.close(tfd)
cffPath = tempPathCFF
command="%s -cff +b \"%s\" \"%s\" 2>&1" % (txPath, path, tempPathCFF)
report = FDKUtils.runShellCmd(command)
if "fatal" in report:
logMsg("Attempted to convert font %s from PS to a temporary CFF data file." % path)
logMsg(report)
raise FontError("Failed to convert PS font %s to a temp CFF font." % path)
# now package the CFF font as an OTF font
ff = file(cffPath, "rb")
data = ff.read()
ff.close()
try:
ttFont = ttLib.TTFont()
cffModule = ttLib.getTableModule('CFF ')
cffTable = cffModule.table_C_F_F_('CFF ')
ttFont['CFF '] = cffTable
cffTable.decompile(data, ttFont)
except:
import traceback
traceback.print_exc()
#.........这里部分代码省略.........
示例13: checkFile
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def checkFile(path, options):
# use fontTools library to open font and extract CFF table.
# If error, skip font and report error.
seenChangedGlyph = 0
fontFileName = os.path.basename(path)
logMsg("Checking font %s. Start time: %s." % (path, time.asctime()))
try:
fontData = openFile(path, options.outFilePath, options.allowChanges)
fontData.allowDecimalCoords = options.allowDecimalCoords
except (IOError, OSError):
logMsg( traceback.format_exception_only(sys.exc_type, sys.exc_value)[-1])
raise focusFontError("Error opening or reading from font file <%s>." % fontFileName)
except:
logMsg( traceback.format_exception_only(sys.exc_type, sys.exc_value)[-1])
raise focusFontError("Error parsing font file <%s>." % fontFileName)
# filter specified list, if any, with font list.
fontGlyphList = fontData.getGlyphList()
glyphList = filterGlyphList(options, fontGlyphList, fontFileName)
if not glyphList:
raise focusFontError("Error: selected glyph list is empty for font <%s>." % fontFileName)
removeHints = 1
reportCB = logMsg
reportText = ""
# If the user has not specified an em-square, and the font has am em-square other than 1000, supply it.
if not options.emSquare:
emSquare = fontData.getUnitsPerEm()
if emSquare != "1000":
options.emSquare = emSquare
arg_string = buildArgString(options)
dotCount = 0
seenGlyphCount = 0
processedGlyphCount = 0
for name in glyphList:
seenGlyphCount +=1
if options.beVerbose:
logMsg("Checking %s -- ," % ( aliasName(name) )) # output message when -v option is used
else:
logMsg(".,")
dotCount += 1
if dotCount > 40:
dotCount = 0
logMsg("") # I do this to never have more than 40 dots on a line.
# This in turn give reasonable performance when calling checkOutlines in a subprocess
# and getting output with std.readline()
if os.path.exists(kTempFilepathOut):
os.remove(kTempFilepathOut)
# Convert to bez format
bezString, width, hasHints = fontData.convertToBez(name, removeHints, options.beVerbose, options.checkAll)
if bezString == None:
continue
processedGlyphCount += 1
if "mt" not in bezString:
# skip empty glyphs.
continue
# write bez file and run checkoutlinesexe
fp = open(kTempFilepath, "wt")
fp.write(bezString)
fp.close()
command = "checkoutlinesexe -o %s %s" % (arg_string, kTempFilepath)
if debug:
print "calling command", command
log = FDKUtils.runShellCmd(command)
# The suffix saying what bez file was written isn't useful here.
log = re.sub(r"Wrote fixed file.+\s*", "", log)
if log:
if not options.beVerbose:
dotCount = 0
logMsg("")
logMsg("Checking %s -- ," % (aliasName(name))) # output message when -v option is NOT used
logMsg(log)
else:
logMsg(log)
if options.allowChanges and os.path.exists(kTempFilepathOut):
fp = open(kTempFilepathOut, "rt")
bezData = fp.read()
fp.close()
if bezData != bezString:
fontData.updateFromBez(bezData, name, width, options.beVerbose)
seenChangedGlyph = 1
if not options.beVerbose:
logMsg("")
if seenChangedGlyph:
# save fontFile.
fontData.saveChanges()
else:
fontData.close()
if processedGlyphCount != seenGlyphCount:
logMsg("Skipped %s of %s glyphs." % (seenGlyphCount - processedGlyphCount, seenGlyphCount))
#.........这里部分代码省略.........
示例14: openOpenTypeFile
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def openOpenTypeFile(path, outFilePath):
# If input font is CFF or PS, build a dummy ttFont in memory..
# return ttFont, and flag if is a real OTF font Return flag is 0 if OTF, 1 if CFF, and 2 if PS/
fontType = 0 # OTF
tempPathCFF = path + kTempCFFSuffix
try:
ff = file(path, "rb")
data = ff.read(10)
ff.close()
except (IOError, OSError):
logMsg("Failed to open and read font file %s." % path)
if data[:4] == "OTTO": # it is an OTF font, can process file directly
try:
ttFont = TTFont(path)
except (IOError, OSError):
raise focusFontError("Error opening or reading from font file <%s>." % path)
except TTLibError:
raise focusFontError("Error parsing font file <%s>." % path)
try:
cffTable = ttFont["CFF "]
except KeyError:
raise focusFontError("Error: font is not a CFF font <%s>." % fontFileName)
else:
# It is not an OTF file.
if (data[0] == '\1') and (data[1] == '\0'): # CFF file
fontType = 1
tempPathCFF = path
elif not "%" in data:
#not a PS file either
logMsg("Font file must be a PS, CFF or OTF fontfile: %s." % path)
raise focusFontError("Font file must be PS, CFF or OTF file: %s." % path)
else: # It is a PS file. Convert to CFF.
fontType = 2
print "Converting Type1 font to temp CFF font file..."
command="tx -cff +b -std \"%s\" \"%s\" 2>&1" % (path, tempPathCFF)
report = FDKUtils.runShellCmd(command)
if "fatal" in report:
logMsg("Attempted to convert font %s from PS to a temporary CFF data file." % path)
logMsg(report)
raise focusFontError("Failed to convert PS font %s to a temp CFF font." % path)
# now package the CFF font as an OTF font.
ff = file(tempPathCFF, "rb")
data = ff.read()
ff.close()
try:
ttFont = TTFont()
cffModule = getTableModule('CFF ')
cffTable = cffModule.table_C_F_F_('CFF ')
ttFont['CFF '] = cffTable
cffTable.decompile(data, ttFont)
except:
logMsg( "\t%s" %(traceback.format_exception_only(sys.exc_type, sys.exc_value)[-1]))
logMsg("Attempted to read font %s as CFF." % path)
raise focusFontError("Error parsing font file <%s>." % path)
fontData = CFFFontData(ttFont, path, outFilePath, fontType, logMsg)
return fontData
示例15: fixFontDict
# 需要导入模块: import FDKUtils [as 别名]
# 或者: from FDKUtils import runShellCmd [as 别名]
def fixFontDict(tempPath, fdDict):
txtPath = tempPath + ".txt"
command = "detype1 %s %s 2>&1" % (tempPath, txtPath)
log = FDKUtils.runShellCmd(command)
if log:
print log
fp = open(txtPath, "rt")
data = fp.read()
fp.close()
# fix font name.
# We always search of it, as it is always present, and we can use the following
# white space to get the file new line.
m = re.search(r"(/FontName\s+/\S+\s+def)(\s+)", data)
newLine = m.group(2)
if not m:
raise FontParseError("Failed to find FontName in input font!. %s" % (tempPath))
if fdDict.FontName:
target = "/FontName /%s def" % (fdDict.FontName)
data = data[:m.start(1)] + target + data[m.end(1):]
# fix em square
if fdDict.OrigEmSqUnits:
m = re.search(r"/FontMatrix\s+\[.+?\]\s+def", data)
if not m:
raise FontParseError("Failed to find FontMatrix in input font! %s" % (tempPath))
emUnits = eval(fdDict.OrigEmSqUnits)
a = 1.0/emUnits
target = "/FontMatrix [%s 0 0 %s 0 0] def" % ( a, a)
data = data[:m.start()] + target + data[m.end():]
# fix StemSnapH. Remove StemSnapH if fdDict.StemSnapH is not defined, else set it.
m = re.search(r"/StemSnapH\s+\[.+?\]\s+def", data)
if fdDict.DominantH:
target = "/StemSnapH %s def" % ( fdDict.DominantH)
data = data[:m.start()] + target + data[m.end():]
insertIndex = m.start() + len(target)
else:
data = data[:m.start()] + data[m.end():]
# fix StemSnapV. Remove StemSnapV entry if fdDict.StemSnapV is not defined, else set it.
m = re.search(r"/StemSnapV\s+\[.+?\]\s+def", data)
if fdDict.DominantV:
target = "/StemSnapV %s def" % ( fdDict.DominantV)
data = data[:m.start()] + target + data[m.end():]
insertIndex = m.start() + len(target)
else:
data = data[:m.start()] + data[m.end():]
# LanguageGroup. Remove LanguageGroup entry if fdDict.LanguageGroup is not defined, else set it.
if fdDict.LanguageGroup:
m = re.search(r"/LanguageGroup\s+\d+\s+def", data)
if not m:
target = "%s/LanguageGroup %s def" % (newLine, fdDict.LanguageGroup)
data = data[:insertIndex] + data[insertIndex] + target + data[insertIndex:]
else:
data = data[:m.start()] + target + data[m.end():]
target = "/LanguageGroup %s def" % (fdDict.LanguageGroup)
else:
m = re.search(r"/LanguageGroup\s+\d+\s+def", data)
if m:
data = data[:m.start()] + data[m.end():]
# Fix BlueValues. Must be present.
m = re.search(r"/BlueValues\s+\[.+?\]\s+def", data)
if not m:
raise FontParseError("Failed to find BlueValues in input font! %s" % (tempPath))
target = "/BlueValues %s def" % (fdDict.BlueValues)
data = data[:m.start()] + target + data[m.end():]
insertIndex = m.start() + len(target)
# Fix OtherBlues, if present. Remove if there are no OtherBlues entry.
m = re.search(r"/OtherBlues\s+\[.+?\]\s+def", data)
if fdDict.OtherBlues:
if not m:
target = "%s/OtherBlues %s def" % (newLine, fdDict.OtherBlues)
data = data[:insertIndex] + target + data[insertIndex:]
else:
target = "/OtherBlues %s def" % (fdDict.OtherBlues)
data = data[:m.start()] + target + data[m.end():]
else:
data = data[:m.start()] + data[m.end():]
fp = open(txtPath, "wt")
fp.write(data)
fp.close()
command = "type1 %s %s 2>&1" % (txtPath, tempPath)
log = FDKUtils.runShellCmd(command)
if log:
print log
if not debug:
os.remove(txtPath)
return