How to use the afdko.ufotools.UFOFontData 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 / python / afdko / autohint.py View on Github external
contentsPath = os.path.join(path, "glyphs", "contents.plist")
	if not os.path.exists(contentsPath):
		msg = "Font file must be a PS, CFF, OTF, or ufo font file: %s." % (path)
		logMsg(msg)
		raise ACFontError(msg)

	# If user has specified a path other than the source font path, then copy the entire
	# ufo font, and operate on the copy.
	if (outFilePath != None) and (os.path.abspath(path) != os.path.abspath(outFilePath)):
		msg = "Copying from source UFO font to output UFO font before processing..."
		logMsg(msg)
		if os.path.exists(outFilePath):
			shutil.rmtree(outFilePath)
		shutil.copytree(path , outFilePath)
		path = outFilePath
	font = ufotools.UFOFontData(path, useHashMap, ufotools.kAutohintName)
	font.useProcessedLayer = True
	font.requiredHistory.append(ufotools.kCheckOutlineName) # Programs in this list must be run before autohint, if the outlines have been edited.
	return font
github adobe-type-tools / afdko / python / afdko / checkoutlinesufo.py View on Github external
def open(self, use_hash_map):
        font_path = self.font_path

        if self.font_format == 'UFO':
            self.font_type = UFO_FONT_TYPE
            ufotools.validateLayers(font_path)
            self.defcon_font = defcon.Font(font_path)
            self.ufo_format = self.defcon_font.ufoFormatVersion
            if self.ufo_format < 2:
                self.ufo_format = 2
            self.use_hash_map = use_hash_map
            self.ufo_font_hash_data = ufotools.UFOFontData(
                font_path, self.use_hash_map,
                programName=ufotools.kCheckOutlineName)
            self.ufo_font_hash_data.readHashMap()

        else:
            print("Converting to temp UFO font...")
            self.temp_ufo_path = temp_path = get_temp_dir_path('font.ufo')

            if not run_shell_command([
                    'tx', '-ufo', font_path, temp_path]):
                raise FocusFontError(
                    'Failed to convert input font to UFO.')

            try:
                self.defcon_font = defcon.Font(temp_path)
            except UFOLibError: