How to use the afdko.FDKUtils 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 / python-scripts / vintage / kernCheck.py View on Github external
def collectKernData(fontpath):
	""" return:
		nameDict[leftGlyphName][rightGlyphName] = kern value
		tableList[classDicts], where classDict[leftClassNameList][rightClassNameList] = value
	"""
	scriptDict = {}
	lookupIndexDict = {}
	command = "spot -t GPOS=7 \"%s\"" % (fontpath)
	report = FDKUtils.runShellCmd(command)

	featureText = ""
	fontFlatKernTable = {}

	# pick out the feature blocks
	while 1:
		m = re.search("# (Printing|Skipping) lookup (\S+) in feature 'kern' for script '([^']+)' language '([^']+).*(\s+# because already dumped in script '([^']+)', language '([^']+)')*", report)
		if m:
			report = report[m.end(0):]
			lookup = m.group(2)
			script = m.group(3)
			lang = m.group(4)
			langDict = scriptDict.get(script, {})
			lookupDict = langDict.get(lang, {})
			lookupEntry = lookupDict.get(lookup, None)
			lookupDict[lookup] = lookupEntry
github adobe-type-tools / python-scripts / vintage / kernCheck.py View on Github external
def getBitMaps(fontPath, ppEM, doAll):
	glyphBitMapDict = {}
	command = "tx -bc -z %s  \"%s\"" % (ppEM, fontPath)
	report = FDKUtils.runShellCmd(command)


	# split bitmap text blocks apart
	bitmapList = re.findall(r"glyph (\S+)([^g]+)", report)

	for entry in bitmapList:
		glyphName = entry[0]
		if glyphName == ".notdef":
			continue
		bitMap = TXBitMap(glyphName, entry[1], ppEM)
		glyphBitMapDict[glyphName] = bitMap

	return glyphBitMapDict
github adobe-type-tools / python-scripts / vintage / kernCheck.py View on Github external
ppEM, ptSize, doAll, sortType, limitVal, doCollisionCheck, doPDF, doSubtableCheck, fontPath, logPath, pdfPath = getOptions(sys.argv[1:])

	# kerncheck has two very different modes. With the option -makePDF, it processes a log file to make a PDF.
	# Without the option -makePDF, it makes the log file.
	if doPDF:
		reporter = Reporter()
		logMsg = reporter.write
		logMsg( "Building PDF...")
		makeOverlapPDF(fontPath, logPath, pdfPath, ptSize, sortType, limitVal)
		logMsg( "All done.")
		return

	reporter = Reporter(logPath)
	logMsg = reporter.write
	print "Loading Adobe Glyph Dict..."
	fdkToolsDir, fdkSharedDataDir = FDKUtils.findFDKDirs()
	sys.path.append(fdkSharedDataDir)
	kAGD_TXTPath = os.path.join(fdkSharedDataDir, "AGD.txt")
	fp = open(kAGD_TXTPath, "rU")
	agdTextPath = fp.read()
	fp.close()
	gAGDDict = agd.dictionary(agdTextPath)
	overlapList = conflictMsgList = []
	print "Collecting font kern data..."
	lookupIndexDict, lookupSequenceDict, fontFlatKernTable = collectKernData(fontPath)

	if lookupIndexDict:
		if doCollisionCheck:
			print "Building bitmaps for font..."

			glyphBitMapDict = getBitMaps(fontPath, ppEM, doAll)
github adobe-type-tools / python-scripts / vintage / BuildMMFont.py View on Github external
def __init__(self):
		try:
			self.exe_dir, fdkSharedDataDir = FDKUtils.findFDKDirs()
		except FDKUtils.FDKEnvError:
			raise FDKEnvironmentError

		if not os.path.exists(self.exe_dir ):
			logMsg("The FDK executable dir \"%s\" does not exist." % (self.exe_dir))
			logMsg("Please re-instal. Quitting.")
			raise FDKEnvironmentError

		toolList = ["tx", "autoHint", "IS", "mergeFonts", "stemHist"]
		missingTools = []
		for name in toolList:
			toolPath = name
			exec("self.%s = toolPath" % (name))
			command = "%s -u 2>&1" % toolPath
			pipe = os.popen(command)
			report = pipe.read()
github adobe-type-tools / python-scripts / vintage / BuildMMFont.py View on Github external
def __init__(self):
		try:
			self.exe_dir, fdkSharedDataDir = FDKUtils.findFDKDirs()
		except FDKUtils.FDKEnvError:
			raise FDKEnvironmentError

		if not os.path.exists(self.exe_dir ):
			logMsg("The FDK executable dir \"%s\" does not exist." % (self.exe_dir))
			logMsg("Please re-instal. Quitting.")
			raise FDKEnvironmentError

		toolList = ["tx", "autoHint", "IS", "mergeFonts", "stemHist"]
		missingTools = []
		for name in toolList:
			toolPath = name
			exec("self.%s = toolPath" % (name))
			command = "%s -u 2>&1" % toolPath
			pipe = os.popen(command)
			report = pipe.read()
			pipe.close()