Clarified a requirement in the spec: smooth is allowed in any point type except offcurve.

git-svn-id: http://svn.robofab.com/branches/ufo3k@546 b5fa9d6c-a76f-4ffd-b3cb-f825fc41095c
This commit is contained in:
Tal Leming 2012-01-17 15:13:52 +00:00
parent 96dd66b6da
commit 4cf0d74b48
3 changed files with 25 additions and 17 deletions

View File

@ -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:

View File

@ -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 = """
<glyph name="a" format="1">
<outline>
@ -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 = """
<glyph name="a" format="1">
@ -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 = """
<glyph name="a" format="1">
<outline>
@ -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):
<glyph name="a" format="1">
<outline>
<contour>
<point x="0" y="65" smooth="yess"/>
<point x="0" y="65" smooth="yes"/>
<point x="0" y="0" type="curve"/>
</contour>
</outline>

View File

@ -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 = """
<glyph name="a" format="2">
<outline>
@ -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 = """
<glyph name="a" format="2">
@ -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 = """
<glyph name="a" format="2">
<outline>
@ -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