diff --git a/Lib/ufoLib/glifLib.py b/Lib/ufoLib/glifLib.py index 220a8ac3e..362fccc2f 100755 --- a/Lib/ufoLib/glifLib.py +++ b/Lib/ufoLib/glifLib.py @@ -1255,8 +1255,8 @@ def _validateAndMassagePointStructures(children, pointAttributes, openContourOff smooth = smooth == "yes" attrs["smooth"] = smooth # smooth can only be applied to curve and qcurve - if smooth and pointType not in ("curve", "qcurve"): - raise GlifLibError("smooth attribute set in a %s point." % pointType) + if smooth and pointType is None: + raise GlifLibError("smooth attribute set in an offcurve point.") # name is optional if "name" not in attrs: attrs["name"] = None @@ -1538,8 +1538,8 @@ class GLIFPointPen(AbstractPointPen): self.prevPointTypes.append(segmentType) # smooth if smooth: - if segmentType not in ("curve", "qcurve"): - raise GlifLibError("can't set smooth in a %s point." % segmentType) + if segmentType == "offcurve": + raise GlifLibError("can't set smooth in an offcurve point.") attrs.append(("smooth", "yes")) # name if name is not None: diff --git a/Lib/ufoLib/test/test_GLIF1.py b/Lib/ufoLib/test/test_GLIF1.py index 09a621742..b3db7b1df 100644 --- a/Lib/ufoLib/test/test_GLIF1.py +++ b/Lib/ufoLib/test/test_GLIF1.py @@ -618,7 +618,7 @@ class TestGLIF1(unittest.TestCase): resultPy = self.glifToPy(glif) self.assertEqual(glif, resultGlif) self.assertEqual(py, resultPy) - # illegal: smooth=True + # legal: smooth=True glif = """ @@ -636,8 +636,10 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) # illegal: not at start glif = """ @@ -704,7 +706,7 @@ class TestGLIF1(unittest.TestCase): resultPy = self.glifToPy(glif) self.assertEqual(glif, resultGlif) self.assertEqual(py, resultPy) - # illegal: smooth=True + # legal: smooth=True glif = """ @@ -722,8 +724,10 @@ class TestGLIF1(unittest.TestCase): pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : True}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) def testPointTypeCurve(self): # legal @@ -1151,7 +1155,7 @@ class TestGLIF1(unittest.TestCase): - + diff --git a/Lib/ufoLib/test/test_GLIF2.py b/Lib/ufoLib/test/test_GLIF2.py index 9dce9d810..9f0393b97 100644 --- a/Lib/ufoLib/test/test_GLIF2.py +++ b/Lib/ufoLib/test/test_GLIF2.py @@ -978,7 +978,7 @@ class TestGLIF2(unittest.TestCase): resultPy = self.glifToPy(glif) self.assertEqual(glif, resultGlif) self.assertEqual(py, resultPy) - # illegal: smooth=True + # legal: smooth=True glif = """ @@ -996,8 +996,10 @@ class TestGLIF2(unittest.TestCase): pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) # illegal: not at start glif = """ @@ -1064,7 +1066,7 @@ class TestGLIF2(unittest.TestCase): resultPy = self.glifToPy(glif) self.assertEqual(glif, resultGlif) self.assertEqual(py, resultPy) - # illegal: smooth=True + # legal: smooth=True glif = """ @@ -1082,8 +1084,10 @@ class TestGLIF2(unittest.TestCase): pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : True}) pointPen.endPath() """ - self.assertRaises(GlifLibError, self.pyToGLIF, py) - self.assertRaises(GlifLibError, self.glifToPy, glif) + resultGlif = self.pyToGLIF(py) + resultPy = self.glifToPy(glif) + self.assertEqual(glif, resultGlif) + self.assertEqual(py, resultPy) def testPointTypeCurve(self): # legal