def compareToUFO(self, doInfo=True, doKerning=True, doGroups=True, doLib=True, doFeatures=True):
		reader = UFOReader(self.ufoPath)
		results = {}
		if doInfo:
			infoMatches = True
			info = self.font.info
			for attr, expectedValue in fontInfoVersion2.items():
				# cheat by skipping attrs that aren't supported
				if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None:
					continue
				writtenValue = getattr(info, attr)
				if expectedValue != writtenValue:
					infoMatches = False
					break
			results["info"]= infoMatches
		if doKerning:
			kerning = self.font.kerning.asDict()
			expectedKerning = reader.readKerning()
			results["kerning"] = expectedKerning == kerning
		if doGroups:
			groups = dict(self.font.groups)
			expectedGroups = reader.readGroups()
			results["groups"] = expectedGroups == groups
		if doFeatures:
			features = self.font.features.text
			expectedFeatures = reader.readFeatures()
			results["features"] = expectedFeatures == features
		if doLib:
			lib = dict(self.font.lib)
			expectedLib = reader.readLib()
			results["lib"] = expectedLib == lib
		return results
Example #2
0
	def testInfo(self):
		self.setUpFont()
		info = self.font.info
		for attr, expectedValue in fontInfoVersion2.items():
			writtenValue = getattr(info, attr)
			self.assertEqual((attr, expectedValue), (attr, writtenValue))
		self.tearDownFont()
Example #3
0
	def compareToUFO(self, doInfo=True):
		reader = UFOReader(ufoPath2)
		results = {}
		# info
		infoMatches = True
		info = self.font.info
		for attr, expectedValue in fontInfoVersion2.items():
			writtenValue = getattr(info, attr)
			if expectedValue != writtenValue:
				infoMatches = False
				break
		results["info"]= infoMatches
		# kerning
		kerning = self.font.kerning.asDict()
		expectedKerning = reader.readKerning()
		results["kerning"] = expectedKerning == kerning
		# groups
		groups = dict(self.font.groups)
		expectedGroups = reader.readGroups()
		results["groups"] = expectedGroups == groups
		# features
		features = self.font.features.text
		expectedFeatures = reader.readFeatures()
		results["features"] = expectedFeatures == features
		# lib
		lib = dict(self.font.lib)
		expectedLib = reader.readLib()
		results["lib"] = expectedLib == lib
		return results
Example #4
0
	def testRoundTripVersion2(self):
		font = NewFont()
		infoObject = font.info
		for attr, value in fontInfoVersion2.items():
			if attr in infoObject._ufoToFLAttrMapping and infoObject._ufoToFLAttrMapping[attr]["nakedAttribute"] is None:
				continue
			setattr(infoObject, attr, value)
			newValue = getattr(infoObject, attr)
			self.assertEqual((attr, newValue), (attr, value))
		font.close()
 def testRoundTripVersion2(self):
     font = NewFont()
     infoObject = font.info
     for attr, value in fontInfoVersion2.items():
         if attr in infoObject._ufoToFLAttrMapping and infoObject._ufoToFLAttrMapping[
                 attr]["nakedAttribute"] is None:
             continue
         setattr(infoObject, attr, value)
         newValue = getattr(infoObject, attr)
         self.assertEqual((attr, newValue), (attr, value))
     font.close()
	def testInfo(self):
		self.setUpFont(doInfo=True)
		otherResults = self.compareToUFO(doInfo=False)
		self.assertEqual(otherResults["kerning"], False)
		self.assertEqual(otherResults["groups"], False)
		self.assertEqual(otherResults["features"], False)
		self.assertEqual(otherResults["lib"], False)
		info = self.font.info
		for attr, expectedValue in fontInfoVersion2.items():
			# cheat by skipping attrs that aren't supported
			if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None:
				continue
			writtenValue = getattr(info, attr)
			self.assertEqual((attr, expectedValue), (attr, writtenValue))
		self.tearDownFont()
Example #7
0
 def testInfo(self):
     self.setUpFont(doInfo=True)
     otherResults = self.compareToUFO(doInfo=False)
     self.assertEqual(otherResults["kerning"], False)
     self.assertEqual(otherResults["groups"], False)
     self.assertEqual(otherResults["features"], False)
     self.assertEqual(otherResults["lib"], False)
     info = self.font.info
     for attr, expectedValue in fontInfoVersion2.items():
         # cheat by skipping attrs that aren't supported
         if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None:
             continue
         writtenValue = getattr(info, attr)
         self.assertEqual((attr, expectedValue), (attr, writtenValue))
     self.tearDownFont()
Example #8
0
	def testVersion2UnsupportedGet(self):
		saveStderr = sys.stderr
		saveStdout = sys.stdout
		tempStderr = StringIO()
		sys.stderr = tempStderr
		sys.stdout = tempStderr
		font = NewFont()
		infoObject = font.info
		requiredWarnings = []
		try:
			for attr, value in fontInfoVersion2.items():
				if attr in infoObject._ufoToFLAttrMapping and infoObject._ufoToFLAttrMapping[attr]["nakedAttribute"] is not None:
					continue
				getattr(infoObject, attr, value)
				s = "The attribute %s is not supported by FontLab." % attr
				requiredWarnings.append((attr, s))
		finally:
			sys.stderr = saveStderr
			sys.stdout = saveStdout
		tempStderr = tempStderr.getvalue()
		for attr, line in requiredWarnings:
			self.assertEquals((attr, line in tempStderr), (attr, True))
		font.close()
Example #9
0
 def compareToUFO(self,
                  doInfo=True,
                  doKerning=True,
                  doGroups=True,
                  doLib=True,
                  doFeatures=True):
     reader = UFOReader(self.ufoPath)
     results = {}
     if doInfo:
         infoMatches = True
         info = self.font.info
         for attr, expectedValue in fontInfoVersion2.items():
             # cheat by skipping attrs that aren't supported
             if info._ufoToFLAttrMapping[attr]["nakedAttribute"] is None:
                 continue
             writtenValue = getattr(info, attr)
             if expectedValue != writtenValue:
                 infoMatches = False
                 break
         results["info"] = infoMatches
     if doKerning:
         kerning = self.font.kerning.asDict()
         expectedKerning = reader.readKerning()
         results["kerning"] = expectedKerning == kerning
     if doGroups:
         groups = dict(self.font.groups)
         expectedGroups = reader.readGroups()
         results["groups"] = expectedGroups == groups
     if doFeatures:
         features = self.font.features.text
         expectedFeatures = reader.readFeatures()
         results["features"] = expectedFeatures == features
     if doLib:
         lib = dict(self.font.lib)
         expectedLib = reader.readLib()
         results["lib"] = expectedLib == lib
     return results
 def testVersion2UnsupportedGet(self):
     saveStderr = sys.stderr
     saveStdout = sys.stdout
     tempStderr = StringIO()
     sys.stderr = tempStderr
     sys.stdout = tempStderr
     font = NewFont()
     infoObject = font.info
     requiredWarnings = []
     try:
         for attr, value in fontInfoVersion2.items():
             if attr in infoObject._ufoToFLAttrMapping and infoObject._ufoToFLAttrMapping[
                     attr]["nakedAttribute"] is not None:
                 continue
             getattr(infoObject, attr, value)
             s = "The attribute %s is not supported by FontLab." % attr
             requiredWarnings.append((attr, s))
     finally:
         sys.stderr = saveStderr
         sys.stdout = saveStdout
     tempStderr = tempStderr.getvalue()
     for attr, line in requiredWarnings:
         self.assertEquals((attr, line in tempStderr), (attr, True))
     font.close()
 def testRoundTripVersion2(self):
     infoObject = RInfo()
     for attr, value in fontInfoVersion2.items():
         setattr(infoObject, attr, value)
         newValue = getattr(infoObject, attr)
         self.assertEqual((attr, newValue), (attr, value))
Example #12
0
	def testRoundTripVersion2(self):
		infoObject = RInfo()
		for attr, value in fontInfoVersion2.items():
			setattr(infoObject, attr, value)
			newValue = getattr(infoObject, attr)
			self.assertEqual((attr, newValue), (attr, value))