1*e1fe3e4aSElliott Hughesimport unittest 2*e1fe3e4aSElliott Hughesfrom fontTools.ufoLib.glifLib import ( 3*e1fe3e4aSElliott Hughes GlifLibError, 4*e1fe3e4aSElliott Hughes readGlyphFromString, 5*e1fe3e4aSElliott Hughes writeGlyphToString, 6*e1fe3e4aSElliott Hughes) 7*e1fe3e4aSElliott Hughesfrom .testSupport import Glyph, stripText 8*e1fe3e4aSElliott Hughesfrom itertools import islice 9*e1fe3e4aSElliott Hughes 10*e1fe3e4aSElliott Hughes# ---------- 11*e1fe3e4aSElliott Hughes# Test Cases 12*e1fe3e4aSElliott Hughes# ---------- 13*e1fe3e4aSElliott Hughes 14*e1fe3e4aSElliott Hughes 15*e1fe3e4aSElliott Hughesclass TestGLIF2(unittest.TestCase): 16*e1fe3e4aSElliott Hughes def assertEqual(self, first, second, msg=None): 17*e1fe3e4aSElliott Hughes if isinstance(first, str): 18*e1fe3e4aSElliott Hughes first = stripText(first) 19*e1fe3e4aSElliott Hughes if isinstance(second, str): 20*e1fe3e4aSElliott Hughes second = stripText(second) 21*e1fe3e4aSElliott Hughes return super().assertEqual(first, second, msg=msg) 22*e1fe3e4aSElliott Hughes 23*e1fe3e4aSElliott Hughes def pyToGLIF(self, py): 24*e1fe3e4aSElliott Hughes py = stripText(py) 25*e1fe3e4aSElliott Hughes glyph = Glyph() 26*e1fe3e4aSElliott Hughes exec(py, {"glyph": glyph, "pointPen": glyph}) 27*e1fe3e4aSElliott Hughes glif = writeGlyphToString( 28*e1fe3e4aSElliott Hughes glyph.name, 29*e1fe3e4aSElliott Hughes glyphObject=glyph, 30*e1fe3e4aSElliott Hughes drawPointsFunc=glyph.drawPoints, 31*e1fe3e4aSElliott Hughes formatVersion=2, 32*e1fe3e4aSElliott Hughes validate=True, 33*e1fe3e4aSElliott Hughes ) 34*e1fe3e4aSElliott Hughes # discard the first line containing the xml declaration 35*e1fe3e4aSElliott Hughes return "\n".join(islice(glif.splitlines(), 1, None)) 36*e1fe3e4aSElliott Hughes 37*e1fe3e4aSElliott Hughes def glifToPy(self, glif): 38*e1fe3e4aSElliott Hughes glif = stripText(glif) 39*e1fe3e4aSElliott Hughes glif = '<?xml version="1.0"?>\n' + glif 40*e1fe3e4aSElliott Hughes glyph = Glyph() 41*e1fe3e4aSElliott Hughes readGlyphFromString(glif, glyphObject=glyph, pointPen=glyph, validate=True) 42*e1fe3e4aSElliott Hughes return glyph.py() 43*e1fe3e4aSElliott Hughes 44*e1fe3e4aSElliott Hughes def testTopElement(self): 45*e1fe3e4aSElliott Hughes # not glyph 46*e1fe3e4aSElliott Hughes glif = """ 47*e1fe3e4aSElliott Hughes <notglyph name="a" format="2"> 48*e1fe3e4aSElliott Hughes <outline> 49*e1fe3e4aSElliott Hughes </outline> 50*e1fe3e4aSElliott Hughes </notglyph> 51*e1fe3e4aSElliott Hughes """ 52*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 53*e1fe3e4aSElliott Hughes 54*e1fe3e4aSElliott Hughes def testName_legal(self): 55*e1fe3e4aSElliott Hughes # legal 56*e1fe3e4aSElliott Hughes glif = """ 57*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 58*e1fe3e4aSElliott Hughes <outline> 59*e1fe3e4aSElliott Hughes </outline> 60*e1fe3e4aSElliott Hughes </glyph> 61*e1fe3e4aSElliott Hughes """ 62*e1fe3e4aSElliott Hughes py = """ 63*e1fe3e4aSElliott Hughes glyph.name = "a" 64*e1fe3e4aSElliott Hughes """ 65*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 66*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 67*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 68*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 69*e1fe3e4aSElliott Hughes 70*e1fe3e4aSElliott Hughes def testName_empty(self): 71*e1fe3e4aSElliott Hughes # empty 72*e1fe3e4aSElliott Hughes glif = """ 73*e1fe3e4aSElliott Hughes <glyph name="" format="2"> 74*e1fe3e4aSElliott Hughes <outline> 75*e1fe3e4aSElliott Hughes </outline> 76*e1fe3e4aSElliott Hughes </glyph> 77*e1fe3e4aSElliott Hughes """ 78*e1fe3e4aSElliott Hughes py = """ 79*e1fe3e4aSElliott Hughes glyph.name = "" 80*e1fe3e4aSElliott Hughes """ 81*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 82*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 83*e1fe3e4aSElliott Hughes 84*e1fe3e4aSElliott Hughes def testName_not_a_string(self): 85*e1fe3e4aSElliott Hughes # not a string 86*e1fe3e4aSElliott Hughes py = """ 87*e1fe3e4aSElliott Hughes glyph.name = 1 88*e1fe3e4aSElliott Hughes """ 89*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 90*e1fe3e4aSElliott Hughes 91*e1fe3e4aSElliott Hughes def testFormat_legal(self): 92*e1fe3e4aSElliott Hughes # legal 93*e1fe3e4aSElliott Hughes glif = """ 94*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 95*e1fe3e4aSElliott Hughes <outline> 96*e1fe3e4aSElliott Hughes </outline> 97*e1fe3e4aSElliott Hughes </glyph> 98*e1fe3e4aSElliott Hughes """ 99*e1fe3e4aSElliott Hughes py = """ 100*e1fe3e4aSElliott Hughes glyph.name = "a" 101*e1fe3e4aSElliott Hughes """ 102*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 103*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 104*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 105*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 106*e1fe3e4aSElliott Hughes 107*e1fe3e4aSElliott Hughes def testFormat_illegal_wrong_number(self): 108*e1fe3e4aSElliott Hughes # wrong number 109*e1fe3e4aSElliott Hughes glif = """ 110*e1fe3e4aSElliott Hughes <glyph name="a" format="-1"> 111*e1fe3e4aSElliott Hughes <outline> 112*e1fe3e4aSElliott Hughes </outline> 113*e1fe3e4aSElliott Hughes </glyph> 114*e1fe3e4aSElliott Hughes """ 115*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 116*e1fe3e4aSElliott Hughes 117*e1fe3e4aSElliott Hughes def testFormat_illegal_not_int(self): 118*e1fe3e4aSElliott Hughes # not an int 119*e1fe3e4aSElliott Hughes glif = """ 120*e1fe3e4aSElliott Hughes <glyph name="a" format="A"> 121*e1fe3e4aSElliott Hughes <outline> 122*e1fe3e4aSElliott Hughes </outline> 123*e1fe3e4aSElliott Hughes </glyph> 124*e1fe3e4aSElliott Hughes """ 125*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 126*e1fe3e4aSElliott Hughes 127*e1fe3e4aSElliott Hughes def testBogusGlyphStructure_unknown_element(self): 128*e1fe3e4aSElliott Hughes # unknown element 129*e1fe3e4aSElliott Hughes glif = """ 130*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 131*e1fe3e4aSElliott Hughes <unknown /> 132*e1fe3e4aSElliott Hughes </glyph> 133*e1fe3e4aSElliott Hughes """ 134*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 135*e1fe3e4aSElliott Hughes 136*e1fe3e4aSElliott Hughes def testBogusGlyphStructure_content(self): 137*e1fe3e4aSElliott Hughes # content 138*e1fe3e4aSElliott Hughes glif = """ 139*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 140*e1fe3e4aSElliott Hughes Hello World. 141*e1fe3e4aSElliott Hughes </glyph> 142*e1fe3e4aSElliott Hughes """ 143*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 144*e1fe3e4aSElliott Hughes 145*e1fe3e4aSElliott Hughes def testAdvance_legal_widht_and_height(self): 146*e1fe3e4aSElliott Hughes # legal: width and height 147*e1fe3e4aSElliott Hughes glif = """ 148*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 149*e1fe3e4aSElliott Hughes <advance height="200" width="100"/> 150*e1fe3e4aSElliott Hughes <outline> 151*e1fe3e4aSElliott Hughes </outline> 152*e1fe3e4aSElliott Hughes </glyph> 153*e1fe3e4aSElliott Hughes """ 154*e1fe3e4aSElliott Hughes py = """ 155*e1fe3e4aSElliott Hughes glyph.name = "a" 156*e1fe3e4aSElliott Hughes glyph.width = 100 157*e1fe3e4aSElliott Hughes glyph.height = 200 158*e1fe3e4aSElliott Hughes """ 159*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 160*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 161*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 162*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 163*e1fe3e4aSElliott Hughes 164*e1fe3e4aSElliott Hughes def testAdvance_legal_width_and_height_floats(self): 165*e1fe3e4aSElliott Hughes # legal: width and height floats 166*e1fe3e4aSElliott Hughes glif = """ 167*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 168*e1fe3e4aSElliott Hughes <advance height="200.1" width="100.1"/> 169*e1fe3e4aSElliott Hughes <outline> 170*e1fe3e4aSElliott Hughes </outline> 171*e1fe3e4aSElliott Hughes </glyph> 172*e1fe3e4aSElliott Hughes """ 173*e1fe3e4aSElliott Hughes py = """ 174*e1fe3e4aSElliott Hughes glyph.name = "a" 175*e1fe3e4aSElliott Hughes glyph.width = 100.1 176*e1fe3e4aSElliott Hughes glyph.height = 200.1 177*e1fe3e4aSElliott Hughes """ 178*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 179*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 180*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 181*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 182*e1fe3e4aSElliott Hughes 183*e1fe3e4aSElliott Hughes def testAdvance_legal_width(self): 184*e1fe3e4aSElliott Hughes # legal: width 185*e1fe3e4aSElliott Hughes glif = """ 186*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 187*e1fe3e4aSElliott Hughes <advance width="100"/> 188*e1fe3e4aSElliott Hughes <outline> 189*e1fe3e4aSElliott Hughes </outline> 190*e1fe3e4aSElliott Hughes </glyph> 191*e1fe3e4aSElliott Hughes """ 192*e1fe3e4aSElliott Hughes py = """ 193*e1fe3e4aSElliott Hughes glyph.name = "a" 194*e1fe3e4aSElliott Hughes glyph.width = 100 195*e1fe3e4aSElliott Hughes """ 196*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 197*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 198*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 199*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 200*e1fe3e4aSElliott Hughes 201*e1fe3e4aSElliott Hughes def testAdvance_legal_height(self): 202*e1fe3e4aSElliott Hughes # legal: height 203*e1fe3e4aSElliott Hughes glif = """ 204*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 205*e1fe3e4aSElliott Hughes <advance height="200"/> 206*e1fe3e4aSElliott Hughes <outline> 207*e1fe3e4aSElliott Hughes </outline> 208*e1fe3e4aSElliott Hughes </glyph> 209*e1fe3e4aSElliott Hughes """ 210*e1fe3e4aSElliott Hughes py = """ 211*e1fe3e4aSElliott Hughes glyph.name = "a" 212*e1fe3e4aSElliott Hughes glyph.height = 200 213*e1fe3e4aSElliott Hughes """ 214*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 215*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 216*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 217*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 218*e1fe3e4aSElliott Hughes 219*e1fe3e4aSElliott Hughes def testAdvance_illegal_width(self): 220*e1fe3e4aSElliott Hughes # illegal: not a number 221*e1fe3e4aSElliott Hughes glif = """ 222*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 223*e1fe3e4aSElliott Hughes <advance width="a"/> 224*e1fe3e4aSElliott Hughes <outline> 225*e1fe3e4aSElliott Hughes </outline> 226*e1fe3e4aSElliott Hughes </glyph> 227*e1fe3e4aSElliott Hughes """ 228*e1fe3e4aSElliott Hughes py = """ 229*e1fe3e4aSElliott Hughes glyph.name = "a" 230*e1fe3e4aSElliott Hughes glyph.width = "a" 231*e1fe3e4aSElliott Hughes """ 232*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 233*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 234*e1fe3e4aSElliott Hughes 235*e1fe3e4aSElliott Hughes def testAdvance_illegal_height(self): 236*e1fe3e4aSElliott Hughes glif = """ 237*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 238*e1fe3e4aSElliott Hughes <advance height="a"/> 239*e1fe3e4aSElliott Hughes <outline> 240*e1fe3e4aSElliott Hughes </outline> 241*e1fe3e4aSElliott Hughes </glyph> 242*e1fe3e4aSElliott Hughes """ 243*e1fe3e4aSElliott Hughes py = """ 244*e1fe3e4aSElliott Hughes glyph.name = "a" 245*e1fe3e4aSElliott Hughes glyph.height = "a" 246*e1fe3e4aSElliott Hughes """ 247*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 248*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 249*e1fe3e4aSElliott Hughes 250*e1fe3e4aSElliott Hughes def testUnicodes_legal(self): 251*e1fe3e4aSElliott Hughes # legal 252*e1fe3e4aSElliott Hughes glif = """ 253*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 254*e1fe3e4aSElliott Hughes <unicode hex="0061"/> 255*e1fe3e4aSElliott Hughes <outline> 256*e1fe3e4aSElliott Hughes </outline> 257*e1fe3e4aSElliott Hughes </glyph> 258*e1fe3e4aSElliott Hughes """ 259*e1fe3e4aSElliott Hughes py = """ 260*e1fe3e4aSElliott Hughes glyph.name = "a" 261*e1fe3e4aSElliott Hughes glyph.unicodes = [97] 262*e1fe3e4aSElliott Hughes """ 263*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 264*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 265*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 266*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 267*e1fe3e4aSElliott Hughes 268*e1fe3e4aSElliott Hughes def testUnicodes_legal_multiple(self): 269*e1fe3e4aSElliott Hughes glif = """ 270*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 271*e1fe3e4aSElliott Hughes <unicode hex="0062"/> 272*e1fe3e4aSElliott Hughes <unicode hex="0063"/> 273*e1fe3e4aSElliott Hughes <unicode hex="0061"/> 274*e1fe3e4aSElliott Hughes <outline> 275*e1fe3e4aSElliott Hughes </outline> 276*e1fe3e4aSElliott Hughes </glyph> 277*e1fe3e4aSElliott Hughes """ 278*e1fe3e4aSElliott Hughes py = """ 279*e1fe3e4aSElliott Hughes glyph.name = "a" 280*e1fe3e4aSElliott Hughes glyph.unicodes = [98, 99, 97] 281*e1fe3e4aSElliott Hughes """ 282*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 283*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 284*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 285*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 286*e1fe3e4aSElliott Hughes 287*e1fe3e4aSElliott Hughes def testUnicodes_illegal(self): 288*e1fe3e4aSElliott Hughes # illegal 289*e1fe3e4aSElliott Hughes glif = """ 290*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 291*e1fe3e4aSElliott Hughes <unicode hex="1.1"/> 292*e1fe3e4aSElliott Hughes <outline> 293*e1fe3e4aSElliott Hughes </outline> 294*e1fe3e4aSElliott Hughes </glyph> 295*e1fe3e4aSElliott Hughes """ 296*e1fe3e4aSElliott Hughes py = """ 297*e1fe3e4aSElliott Hughes glyph.name = "zzzzzz" 298*e1fe3e4aSElliott Hughes glyph.unicodes = ["1.1"] 299*e1fe3e4aSElliott Hughes """ 300*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 301*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 302*e1fe3e4aSElliott Hughes 303*e1fe3e4aSElliott Hughes def testNote(self): 304*e1fe3e4aSElliott Hughes glif = """ 305*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 306*e1fe3e4aSElliott Hughes <note> 307*e1fe3e4aSElliott Hughes hëllö 308*e1fe3e4aSElliott Hughes </note> 309*e1fe3e4aSElliott Hughes <outline> 310*e1fe3e4aSElliott Hughes </outline> 311*e1fe3e4aSElliott Hughes </glyph> 312*e1fe3e4aSElliott Hughes """ 313*e1fe3e4aSElliott Hughes py = """ 314*e1fe3e4aSElliott Hughes glyph.name = "a" 315*e1fe3e4aSElliott Hughes glyph.note = "hëllö" 316*e1fe3e4aSElliott Hughes """ 317*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 318*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 319*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 320*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 321*e1fe3e4aSElliott Hughes 322*e1fe3e4aSElliott Hughes def testLib(self): 323*e1fe3e4aSElliott Hughes glif = """ 324*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 325*e1fe3e4aSElliott Hughes <outline> 326*e1fe3e4aSElliott Hughes </outline> 327*e1fe3e4aSElliott Hughes <lib> 328*e1fe3e4aSElliott Hughes <dict> 329*e1fe3e4aSElliott Hughes <key>dict</key> 330*e1fe3e4aSElliott Hughes <dict> 331*e1fe3e4aSElliott Hughes <key>hello</key> 332*e1fe3e4aSElliott Hughes <string>world</string> 333*e1fe3e4aSElliott Hughes </dict> 334*e1fe3e4aSElliott Hughes <key>float</key> 335*e1fe3e4aSElliott Hughes <real>2.5</real> 336*e1fe3e4aSElliott Hughes <key>int</key> 337*e1fe3e4aSElliott Hughes <integer>1</integer> 338*e1fe3e4aSElliott Hughes <key>list</key> 339*e1fe3e4aSElliott Hughes <array> 340*e1fe3e4aSElliott Hughes <string>a</string> 341*e1fe3e4aSElliott Hughes <string>b</string> 342*e1fe3e4aSElliott Hughes <integer>1</integer> 343*e1fe3e4aSElliott Hughes <real>2.5</real> 344*e1fe3e4aSElliott Hughes </array> 345*e1fe3e4aSElliott Hughes <key>string</key> 346*e1fe3e4aSElliott Hughes <string>a</string> 347*e1fe3e4aSElliott Hughes </dict> 348*e1fe3e4aSElliott Hughes </lib> 349*e1fe3e4aSElliott Hughes </glyph> 350*e1fe3e4aSElliott Hughes """ 351*e1fe3e4aSElliott Hughes py = """ 352*e1fe3e4aSElliott Hughes glyph.name = "a" 353*e1fe3e4aSElliott Hughes glyph.lib = {"dict" : {"hello" : "world"}, "float" : 2.5, "int" : 1, "list" : ["a", "b", 1, 2.5], "string" : "a"} 354*e1fe3e4aSElliott Hughes """ 355*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 356*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 357*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 358*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 359*e1fe3e4aSElliott Hughes 360*e1fe3e4aSElliott Hughes def testGuidelines_legal(self): 361*e1fe3e4aSElliott Hughes # legal 362*e1fe3e4aSElliott Hughes glif = """ 363*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 364*e1fe3e4aSElliott Hughes <guideline x="1"/> 365*e1fe3e4aSElliott Hughes <guideline y="1"/> 366*e1fe3e4aSElliott Hughes <guideline x="1" y="1" angle="0"/> 367*e1fe3e4aSElliott Hughes <guideline x="1" y="1" angle="360"/> 368*e1fe3e4aSElliott Hughes <guideline x="1.1" y="1.1" angle="45.5"/> 369*e1fe3e4aSElliott Hughes <guideline x="1" name="a"/> 370*e1fe3e4aSElliott Hughes <guideline x="1" color="1,1,1,1"/> 371*e1fe3e4aSElliott Hughes <outline> 372*e1fe3e4aSElliott Hughes </outline> 373*e1fe3e4aSElliott Hughes </glyph> 374*e1fe3e4aSElliott Hughes """ 375*e1fe3e4aSElliott Hughes py = """ 376*e1fe3e4aSElliott Hughes glyph.name = "a" 377*e1fe3e4aSElliott Hughes glyph.guidelines = [{"x" : 1}, {"y" : 1}, {"angle" : 0, "x" : 1, "y" : 1}, {"angle" : 360, "x" : 1, "y" : 1}, {"angle" : 45.5, "x" : 1.1, "y" : 1.1}, {"name" : "a", "x" : 1}, {"color" : "1,1,1,1", "x" : 1}] 378*e1fe3e4aSElliott Hughes """ 379*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 380*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 381*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 382*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 383*e1fe3e4aSElliott Hughes 384*e1fe3e4aSElliott Hughes def testGuidelines_illegal_x(self): 385*e1fe3e4aSElliott Hughes # x not an int or float 386*e1fe3e4aSElliott Hughes glif = """ 387*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 388*e1fe3e4aSElliott Hughes <guideline x="a" y="1" angle="45"/> 389*e1fe3e4aSElliott Hughes <outline> 390*e1fe3e4aSElliott Hughes </outline> 391*e1fe3e4aSElliott Hughes </glyph> 392*e1fe3e4aSElliott Hughes """ 393*e1fe3e4aSElliott Hughes py = """ 394*e1fe3e4aSElliott Hughes glyph.name = "a" 395*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : 45, "x" : "a", "y" : 1}] 396*e1fe3e4aSElliott Hughes """ 397*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 398*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 399*e1fe3e4aSElliott Hughes 400*e1fe3e4aSElliott Hughes def testGuidelines_illegal_y(self): 401*e1fe3e4aSElliott Hughes # y not an int or float 402*e1fe3e4aSElliott Hughes glif = """ 403*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 404*e1fe3e4aSElliott Hughes <guideline x="1" y="y" angle="45"/> 405*e1fe3e4aSElliott Hughes <outline> 406*e1fe3e4aSElliott Hughes </outline> 407*e1fe3e4aSElliott Hughes </glyph> 408*e1fe3e4aSElliott Hughes """ 409*e1fe3e4aSElliott Hughes py = """ 410*e1fe3e4aSElliott Hughes glyph.name = "a" 411*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : 45, "x" : 1, "y" : "a"}] 412*e1fe3e4aSElliott Hughes """ 413*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 414*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 415*e1fe3e4aSElliott Hughes 416*e1fe3e4aSElliott Hughes def testGuidelines_illegal_angle(self): 417*e1fe3e4aSElliott Hughes # angle not an int or float 418*e1fe3e4aSElliott Hughes glif = """ 419*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 420*e1fe3e4aSElliott Hughes <guideline x="1" y="1" angle="a"/> 421*e1fe3e4aSElliott Hughes <outline> 422*e1fe3e4aSElliott Hughes </outline> 423*e1fe3e4aSElliott Hughes </glyph> 424*e1fe3e4aSElliott Hughes """ 425*e1fe3e4aSElliott Hughes py = """ 426*e1fe3e4aSElliott Hughes glyph.name = "a" 427*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : "a", "x" : 1, "y" : 1}] 428*e1fe3e4aSElliott Hughes """ 429*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 430*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 431*e1fe3e4aSElliott Hughes 432*e1fe3e4aSElliott Hughes def testGuidelines_illegal_x_missing(self): 433*e1fe3e4aSElliott Hughes # x missing 434*e1fe3e4aSElliott Hughes glif = """ 435*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 436*e1fe3e4aSElliott Hughes <guideline y="1" angle="45"/> 437*e1fe3e4aSElliott Hughes <outline> 438*e1fe3e4aSElliott Hughes </outline> 439*e1fe3e4aSElliott Hughes </glyph> 440*e1fe3e4aSElliott Hughes """ 441*e1fe3e4aSElliott Hughes py = """ 442*e1fe3e4aSElliott Hughes glyph.name = "a" 443*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : 45, "y" : 1}] 444*e1fe3e4aSElliott Hughes """ 445*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 446*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 447*e1fe3e4aSElliott Hughes 448*e1fe3e4aSElliott Hughes def testGuidelines_illegal_y_missing(self): 449*e1fe3e4aSElliott Hughes # y missing 450*e1fe3e4aSElliott Hughes glif = """ 451*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 452*e1fe3e4aSElliott Hughes <guideline x="1" angle="45"/> 453*e1fe3e4aSElliott Hughes <outline> 454*e1fe3e4aSElliott Hughes </outline> 455*e1fe3e4aSElliott Hughes </glyph> 456*e1fe3e4aSElliott Hughes """ 457*e1fe3e4aSElliott Hughes py = """ 458*e1fe3e4aSElliott Hughes glyph.name = "a" 459*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : 45, "x" : 1}] 460*e1fe3e4aSElliott Hughes """ 461*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 462*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 463*e1fe3e4aSElliott Hughes 464*e1fe3e4aSElliott Hughes def testGuidelines_illegal_angle_missing(self): 465*e1fe3e4aSElliott Hughes # angle missing 466*e1fe3e4aSElliott Hughes glif = """ 467*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 468*e1fe3e4aSElliott Hughes <guideline x="1" y="1"/> 469*e1fe3e4aSElliott Hughes <outline> 470*e1fe3e4aSElliott Hughes </outline> 471*e1fe3e4aSElliott Hughes </glyph> 472*e1fe3e4aSElliott Hughes """ 473*e1fe3e4aSElliott Hughes py = """ 474*e1fe3e4aSElliott Hughes glyph.name = "a" 475*e1fe3e4aSElliott Hughes glyph.guidelines = [{"x" : 1, "y" : 1}] 476*e1fe3e4aSElliott Hughes """ 477*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 478*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 479*e1fe3e4aSElliott Hughes 480*e1fe3e4aSElliott Hughes def testGuidelines_illegal_angle_out_of_range(self): 481*e1fe3e4aSElliott Hughes # angle out of range 482*e1fe3e4aSElliott Hughes glif = """ 483*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 484*e1fe3e4aSElliott Hughes <guideline x="1" y="1" angle="-1"/> 485*e1fe3e4aSElliott Hughes <outline> 486*e1fe3e4aSElliott Hughes </outline> 487*e1fe3e4aSElliott Hughes </glyph> 488*e1fe3e4aSElliott Hughes """ 489*e1fe3e4aSElliott Hughes py = """ 490*e1fe3e4aSElliott Hughes glyph.name = "a" 491*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : -1, "x" : "1", "y" : 1}] 492*e1fe3e4aSElliott Hughes """ 493*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 494*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 495*e1fe3e4aSElliott Hughes glif = """ 496*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 497*e1fe3e4aSElliott Hughes <guideline x="1" y="1" angle="361"/> 498*e1fe3e4aSElliott Hughes <outline> 499*e1fe3e4aSElliott Hughes </outline> 500*e1fe3e4aSElliott Hughes </glyph> 501*e1fe3e4aSElliott Hughes """ 502*e1fe3e4aSElliott Hughes py = """ 503*e1fe3e4aSElliott Hughes glyph.name = "a" 504*e1fe3e4aSElliott Hughes glyph.guidelines = [{"angle" : 361, "x" : "1", "y" : 1}] 505*e1fe3e4aSElliott Hughes """ 506*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 507*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 508*e1fe3e4aSElliott Hughes 509*e1fe3e4aSElliott Hughes def testAnchors_legal(self): 510*e1fe3e4aSElliott Hughes # legal 511*e1fe3e4aSElliott Hughes glif = """ 512*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 513*e1fe3e4aSElliott Hughes <anchor x="1" y="2" name="test" color="1,0,0,1"/> 514*e1fe3e4aSElliott Hughes <anchor x="1" y="2"/> 515*e1fe3e4aSElliott Hughes <outline> 516*e1fe3e4aSElliott Hughes </outline> 517*e1fe3e4aSElliott Hughes </glyph> 518*e1fe3e4aSElliott Hughes """ 519*e1fe3e4aSElliott Hughes py = """ 520*e1fe3e4aSElliott Hughes glyph.name = "a" 521*e1fe3e4aSElliott Hughes glyph.anchors = [{"color" : "1,0,0,1", "name" : "test", "x" : 1, "y" : 2}, {"x" : 1, "y" : 2}] 522*e1fe3e4aSElliott Hughes """ 523*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 524*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 525*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 526*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 527*e1fe3e4aSElliott Hughes 528*e1fe3e4aSElliott Hughes def testAnchors_illegal_x(self): 529*e1fe3e4aSElliott Hughes # x not an int or float 530*e1fe3e4aSElliott Hughes glif = """ 531*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 532*e1fe3e4aSElliott Hughes <anchor x="a" y="1"/> 533*e1fe3e4aSElliott Hughes <outline> 534*e1fe3e4aSElliott Hughes </outline> 535*e1fe3e4aSElliott Hughes </glyph> 536*e1fe3e4aSElliott Hughes """ 537*e1fe3e4aSElliott Hughes py = """ 538*e1fe3e4aSElliott Hughes glyph.name = "a" 539*e1fe3e4aSElliott Hughes glyph.anchors = [{"x" : "a", "y" : 1}] 540*e1fe3e4aSElliott Hughes """ 541*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 542*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 543*e1fe3e4aSElliott Hughes 544*e1fe3e4aSElliott Hughes def testAnchors_illegal_y(self): 545*e1fe3e4aSElliott Hughes # y not an int or float 546*e1fe3e4aSElliott Hughes glif = """ 547*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 548*e1fe3e4aSElliott Hughes <anchor x="1" y="a"/> 549*e1fe3e4aSElliott Hughes <outline> 550*e1fe3e4aSElliott Hughes </outline> 551*e1fe3e4aSElliott Hughes </glyph> 552*e1fe3e4aSElliott Hughes """ 553*e1fe3e4aSElliott Hughes py = """ 554*e1fe3e4aSElliott Hughes glyph.name = "a" 555*e1fe3e4aSElliott Hughes glyph.anchors = [{"x" : 1, "y" : "a"}] 556*e1fe3e4aSElliott Hughes """ 557*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 558*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 559*e1fe3e4aSElliott Hughes 560*e1fe3e4aSElliott Hughes def testAnchors_illegal_x_missing(self): 561*e1fe3e4aSElliott Hughes # x missing 562*e1fe3e4aSElliott Hughes glif = """ 563*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 564*e1fe3e4aSElliott Hughes <anchor y="1"/> 565*e1fe3e4aSElliott Hughes <outline> 566*e1fe3e4aSElliott Hughes </outline> 567*e1fe3e4aSElliott Hughes </glyph> 568*e1fe3e4aSElliott Hughes """ 569*e1fe3e4aSElliott Hughes py = """ 570*e1fe3e4aSElliott Hughes glyph.name = "a" 571*e1fe3e4aSElliott Hughes glyph.anchors = [{"y" : 1}] 572*e1fe3e4aSElliott Hughes """ 573*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 574*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 575*e1fe3e4aSElliott Hughes 576*e1fe3e4aSElliott Hughes def testAnchors_illegal_y_missing(self): 577*e1fe3e4aSElliott Hughes # y missing 578*e1fe3e4aSElliott Hughes glif = """ 579*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 580*e1fe3e4aSElliott Hughes <anchor x="1"/> 581*e1fe3e4aSElliott Hughes <outline> 582*e1fe3e4aSElliott Hughes </outline> 583*e1fe3e4aSElliott Hughes </glyph> 584*e1fe3e4aSElliott Hughes """ 585*e1fe3e4aSElliott Hughes py = """ 586*e1fe3e4aSElliott Hughes glyph.name = "a" 587*e1fe3e4aSElliott Hughes glyph.anchors = [{"x" : 1}] 588*e1fe3e4aSElliott Hughes """ 589*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 590*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 591*e1fe3e4aSElliott Hughes 592*e1fe3e4aSElliott Hughes def testImage_legal(self): 593*e1fe3e4aSElliott Hughes # legal 594*e1fe3e4aSElliott Hughes glif = """ 595*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 596*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4" color="1,1,1,1"/> 597*e1fe3e4aSElliott Hughes <outline> 598*e1fe3e4aSElliott Hughes </outline> 599*e1fe3e4aSElliott Hughes </glyph> 600*e1fe3e4aSElliott Hughes """ 601*e1fe3e4aSElliott Hughes py = """ 602*e1fe3e4aSElliott Hughes glyph.name = "a" 603*e1fe3e4aSElliott Hughes glyph.image = {"color" : "1,1,1,1", "fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} 604*e1fe3e4aSElliott Hughes """ 605*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 606*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 607*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 608*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 609*e1fe3e4aSElliott Hughes 610*e1fe3e4aSElliott Hughes def testImage_legal_no_color_or_transformation(self): 611*e1fe3e4aSElliott Hughes # legal: no color or transformation 612*e1fe3e4aSElliott Hughes glif = """ 613*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 614*e1fe3e4aSElliott Hughes <image fileName="test.png"/> 615*e1fe3e4aSElliott Hughes <outline> 616*e1fe3e4aSElliott Hughes </outline> 617*e1fe3e4aSElliott Hughes </glyph> 618*e1fe3e4aSElliott Hughes """ 619*e1fe3e4aSElliott Hughes py = """ 620*e1fe3e4aSElliott Hughes glyph.name = "a" 621*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 0, "xScale" : 1, "xyScale" : 0, "yOffset" : 0, "yScale" : 1, "yxScale" : 0} 622*e1fe3e4aSElliott Hughes """ 623*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 624*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 625*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 626*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 627*e1fe3e4aSElliott Hughes 628*e1fe3e4aSElliott Hughes def testImage_illegal_no_file_name(self): 629*e1fe3e4aSElliott Hughes # no file name 630*e1fe3e4aSElliott Hughes glif = """ 631*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 632*e1fe3e4aSElliott Hughes <image xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4" color="1,1,1,1"/> 633*e1fe3e4aSElliott Hughes <outline> 634*e1fe3e4aSElliott Hughes </outline> 635*e1fe3e4aSElliott Hughes </glyph> 636*e1fe3e4aSElliott Hughes """ 637*e1fe3e4aSElliott Hughes py = """ 638*e1fe3e4aSElliott Hughes glyph.name = "a" 639*e1fe3e4aSElliott Hughes glyph.image = {"color" : "1,1,1,1", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} 640*e1fe3e4aSElliott Hughes """ 641*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 642*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 643*e1fe3e4aSElliott Hughes 644*e1fe3e4aSElliott Hughes def testImage_bogus_transformation(self): 645*e1fe3e4aSElliott Hughes # bogus transformation 646*e1fe3e4aSElliott Hughes glif = """ 647*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 648*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 649*e1fe3e4aSElliott Hughes <outline> 650*e1fe3e4aSElliott Hughes </outline> 651*e1fe3e4aSElliott Hughes </glyph> 652*e1fe3e4aSElliott Hughes """ 653*e1fe3e4aSElliott Hughes py = """ 654*e1fe3e4aSElliott Hughes glyph.name = "a" 655*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : "a", "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} 656*e1fe3e4aSElliott Hughes """ 657*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 658*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 659*e1fe3e4aSElliott Hughes glif = """ 660*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 661*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="a" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 662*e1fe3e4aSElliott Hughes <outline> 663*e1fe3e4aSElliott Hughes </outline> 664*e1fe3e4aSElliott Hughes </glyph> 665*e1fe3e4aSElliott Hughes """ 666*e1fe3e4aSElliott Hughes py = """ 667*e1fe3e4aSElliott Hughes glyph.name = "a" 668*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : "a", "yOffset" : 4, "yScale" : 5, "yxScale" : 6} 669*e1fe3e4aSElliott Hughes """ 670*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 671*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 672*e1fe3e4aSElliott Hughes glif = """ 673*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 674*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="3" yxScale="a" yScale="5" xOffset="1" yOffset="4"/> 675*e1fe3e4aSElliott Hughes <outline> 676*e1fe3e4aSElliott Hughes </outline> 677*e1fe3e4aSElliott Hughes </glyph> 678*e1fe3e4aSElliott Hughes """ 679*e1fe3e4aSElliott Hughes py = """ 680*e1fe3e4aSElliott Hughes glyph.name = "a" 681*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : "a"} 682*e1fe3e4aSElliott Hughes """ 683*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 684*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 685*e1fe3e4aSElliott Hughes glif = """ 686*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 687*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="a" xOffset="1" yOffset="4"/> 688*e1fe3e4aSElliott Hughes <outline> 689*e1fe3e4aSElliott Hughes </outline> 690*e1fe3e4aSElliott Hughes </glyph> 691*e1fe3e4aSElliott Hughes """ 692*e1fe3e4aSElliott Hughes py = """ 693*e1fe3e4aSElliott Hughes glyph.name = "a" 694*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : "a", "yxScale" : 6} 695*e1fe3e4aSElliott Hughes """ 696*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 697*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 698*e1fe3e4aSElliott Hughes glif = """ 699*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 700*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="a" yOffset="4"/> 701*e1fe3e4aSElliott Hughes <outline> 702*e1fe3e4aSElliott Hughes </outline> 703*e1fe3e4aSElliott Hughes </glyph> 704*e1fe3e4aSElliott Hughes """ 705*e1fe3e4aSElliott Hughes py = """ 706*e1fe3e4aSElliott Hughes glyph.name = "a" 707*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : "a", "xScale" : 2, "xyScale" : 3, "yOffset" : 4, "yScale" : 5, "yxScale" : 6} 708*e1fe3e4aSElliott Hughes """ 709*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 710*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 711*e1fe3e4aSElliott Hughes glif = """ 712*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 713*e1fe3e4aSElliott Hughes <image fileName="test.png" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="a"/> 714*e1fe3e4aSElliott Hughes <outline> 715*e1fe3e4aSElliott Hughes </outline> 716*e1fe3e4aSElliott Hughes </glyph> 717*e1fe3e4aSElliott Hughes """ 718*e1fe3e4aSElliott Hughes py = """ 719*e1fe3e4aSElliott Hughes glyph.name = "a" 720*e1fe3e4aSElliott Hughes glyph.image = {"fileName" : "test.png", "xOffset" : 1, "xScale" : 2, "xyScale" : 3, "yOffset" : "a", "yScale" : 5, "yxScale" : 6} 721*e1fe3e4aSElliott Hughes """ 722*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 723*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 724*e1fe3e4aSElliott Hughes 725*e1fe3e4aSElliott Hughes def testImage_bogus_color(self): 726*e1fe3e4aSElliott Hughes # bogus color 727*e1fe3e4aSElliott Hughes glif = """ 728*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 729*e1fe3e4aSElliott Hughes <image fileName="test.png" color="1,1,1,x"/> 730*e1fe3e4aSElliott Hughes <outline> 731*e1fe3e4aSElliott Hughes </outline> 732*e1fe3e4aSElliott Hughes </glyph> 733*e1fe3e4aSElliott Hughes """ 734*e1fe3e4aSElliott Hughes py = """ 735*e1fe3e4aSElliott Hughes glyph.name = "a" 736*e1fe3e4aSElliott Hughes glyph.image = {"color" : "1,1,1,x"} 737*e1fe3e4aSElliott Hughes """ 738*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 739*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 740*e1fe3e4aSElliott Hughes 741*e1fe3e4aSElliott Hughes def testOutline_unknown_element(self): 742*e1fe3e4aSElliott Hughes # unknown element 743*e1fe3e4aSElliott Hughes glif = """ 744*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 745*e1fe3e4aSElliott Hughes <outline> 746*e1fe3e4aSElliott Hughes <unknown/> 747*e1fe3e4aSElliott Hughes </outline> 748*e1fe3e4aSElliott Hughes </glyph> 749*e1fe3e4aSElliott Hughes """ 750*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 751*e1fe3e4aSElliott Hughes 752*e1fe3e4aSElliott Hughes def testOutline_content(self): 753*e1fe3e4aSElliott Hughes # content 754*e1fe3e4aSElliott Hughes glif = """ 755*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 756*e1fe3e4aSElliott Hughes <outline> 757*e1fe3e4aSElliott Hughes hello 758*e1fe3e4aSElliott Hughes </outline> 759*e1fe3e4aSElliott Hughes </glyph> 760*e1fe3e4aSElliott Hughes """ 761*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 762*e1fe3e4aSElliott Hughes 763*e1fe3e4aSElliott Hughes def testComponent_legal(self): 764*e1fe3e4aSElliott Hughes # legal 765*e1fe3e4aSElliott Hughes glif = """ 766*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 767*e1fe3e4aSElliott Hughes <outline> 768*e1fe3e4aSElliott Hughes <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 769*e1fe3e4aSElliott Hughes </outline> 770*e1fe3e4aSElliott Hughes </glyph> 771*e1fe3e4aSElliott Hughes """ 772*e1fe3e4aSElliott Hughes py = """ 773*e1fe3e4aSElliott Hughes glyph.name = "a" 774*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, 3, 6, 5, 1, 4)]) 775*e1fe3e4aSElliott Hughes """ 776*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 777*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 778*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 779*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 780*e1fe3e4aSElliott Hughes 781*e1fe3e4aSElliott Hughes def testComponent_illegal_no_base(self): 782*e1fe3e4aSElliott Hughes # no base 783*e1fe3e4aSElliott Hughes glif = """ 784*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 785*e1fe3e4aSElliott Hughes <outline> 786*e1fe3e4aSElliott Hughes <component xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 787*e1fe3e4aSElliott Hughes </outline> 788*e1fe3e4aSElliott Hughes </glyph> 789*e1fe3e4aSElliott Hughes """ 790*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 791*e1fe3e4aSElliott Hughes 792*e1fe3e4aSElliott Hughes def testComponent_illegal_bogus_transformation(self): 793*e1fe3e4aSElliott Hughes # bogus values in transformation 794*e1fe3e4aSElliott Hughes glif = """ 795*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 796*e1fe3e4aSElliott Hughes <outline> 797*e1fe3e4aSElliott Hughes <component base="x" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 798*e1fe3e4aSElliott Hughes </outline> 799*e1fe3e4aSElliott Hughes </glyph> 800*e1fe3e4aSElliott Hughes """ 801*e1fe3e4aSElliott Hughes py = """ 802*e1fe3e4aSElliott Hughes glyph.name = "a" 803*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", ("a", 3, 6, 5, 1, 4)]) 804*e1fe3e4aSElliott Hughes """ 805*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 806*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 807*e1fe3e4aSElliott Hughes glif = """ 808*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 809*e1fe3e4aSElliott Hughes <outline> 810*e1fe3e4aSElliott Hughes <component base="x" xScale="a" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="4"/> 811*e1fe3e4aSElliott Hughes </outline> 812*e1fe3e4aSElliott Hughes </glyph> 813*e1fe3e4aSElliott Hughes """ 814*e1fe3e4aSElliott Hughes py = """ 815*e1fe3e4aSElliott Hughes glyph.name = "a" 816*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, "a", 6, 5, 1, 4)]) 817*e1fe3e4aSElliott Hughes """ 818*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 819*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 820*e1fe3e4aSElliott Hughes glif = """ 821*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 822*e1fe3e4aSElliott Hughes <outline> 823*e1fe3e4aSElliott Hughes <component base="x" xScale="2" xyScale="3" yxScale="a" yScale="5" xOffset="1" yOffset="4"/> 824*e1fe3e4aSElliott Hughes </outline> 825*e1fe3e4aSElliott Hughes </glyph> 826*e1fe3e4aSElliott Hughes """ 827*e1fe3e4aSElliott Hughes py = """ 828*e1fe3e4aSElliott Hughes glyph.name = "a" 829*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, 3, "a", 5, 1, 4)]) 830*e1fe3e4aSElliott Hughes """ 831*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 832*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 833*e1fe3e4aSElliott Hughes glif = """ 834*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 835*e1fe3e4aSElliott Hughes <outline> 836*e1fe3e4aSElliott Hughes <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="a" xOffset="1" yOffset="4"/> 837*e1fe3e4aSElliott Hughes </outline> 838*e1fe3e4aSElliott Hughes </glyph> 839*e1fe3e4aSElliott Hughes """ 840*e1fe3e4aSElliott Hughes py = """ 841*e1fe3e4aSElliott Hughes glyph.name = "a" 842*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, 3, 6, "a", 1, 4)]) 843*e1fe3e4aSElliott Hughes """ 844*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 845*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 846*e1fe3e4aSElliott Hughes glif = """ 847*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 848*e1fe3e4aSElliott Hughes <outline> 849*e1fe3e4aSElliott Hughes <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="a" yOffset="4"/> 850*e1fe3e4aSElliott Hughes </outline> 851*e1fe3e4aSElliott Hughes </glyph> 852*e1fe3e4aSElliott Hughes """ 853*e1fe3e4aSElliott Hughes py = """ 854*e1fe3e4aSElliott Hughes glyph.name = "a" 855*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, 3, 6, 5, "a", 4)]) 856*e1fe3e4aSElliott Hughes """ 857*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 858*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 859*e1fe3e4aSElliott Hughes glif = """ 860*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 861*e1fe3e4aSElliott Hughes <outline> 862*e1fe3e4aSElliott Hughes <component base="x" xScale="2" xyScale="3" yxScale="6" yScale="5" xOffset="1" yOffset="a"/> 863*e1fe3e4aSElliott Hughes </outline> 864*e1fe3e4aSElliott Hughes </glyph> 865*e1fe3e4aSElliott Hughes """ 866*e1fe3e4aSElliott Hughes py = """ 867*e1fe3e4aSElliott Hughes glyph.name = "a" 868*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (2, 3, 6, 5, 1, "a")]) 869*e1fe3e4aSElliott Hughes """ 870*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 871*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 872*e1fe3e4aSElliott Hughes 873*e1fe3e4aSElliott Hughes def testContour_legal_one_contour(self): 874*e1fe3e4aSElliott Hughes # legal: one contour 875*e1fe3e4aSElliott Hughes glif = """ 876*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 877*e1fe3e4aSElliott Hughes <outline> 878*e1fe3e4aSElliott Hughes <contour> 879*e1fe3e4aSElliott Hughes </contour> 880*e1fe3e4aSElliott Hughes </outline> 881*e1fe3e4aSElliott Hughes </glyph> 882*e1fe3e4aSElliott Hughes """ 883*e1fe3e4aSElliott Hughes py = """ 884*e1fe3e4aSElliott Hughes glyph.name = "a" 885*e1fe3e4aSElliott Hughes pointPen.beginPath() 886*e1fe3e4aSElliott Hughes pointPen.endPath() 887*e1fe3e4aSElliott Hughes """ 888*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 889*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 890*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 891*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 892*e1fe3e4aSElliott Hughes 893*e1fe3e4aSElliott Hughes def testContour_legal_two_contours(self): 894*e1fe3e4aSElliott Hughes # legal: two contours 895*e1fe3e4aSElliott Hughes glif = """ 896*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 897*e1fe3e4aSElliott Hughes <outline> 898*e1fe3e4aSElliott Hughes <contour> 899*e1fe3e4aSElliott Hughes <point x="1" y="2" type="move"/> 900*e1fe3e4aSElliott Hughes </contour> 901*e1fe3e4aSElliott Hughes <contour> 902*e1fe3e4aSElliott Hughes <point x="1" y="2" type="move"/> 903*e1fe3e4aSElliott Hughes <point x="10" y="20" type="line"/> 904*e1fe3e4aSElliott Hughes </contour> 905*e1fe3e4aSElliott Hughes </outline> 906*e1fe3e4aSElliott Hughes </glyph> 907*e1fe3e4aSElliott Hughes """ 908*e1fe3e4aSElliott Hughes py = """ 909*e1fe3e4aSElliott Hughes glyph.name = "a" 910*e1fe3e4aSElliott Hughes pointPen.beginPath() 911*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) 912*e1fe3e4aSElliott Hughes pointPen.endPath() 913*e1fe3e4aSElliott Hughes pointPen.beginPath() 914*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) 915*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(10, 20)], **{"segmentType" : "line", "smooth" : False}) 916*e1fe3e4aSElliott Hughes pointPen.endPath() 917*e1fe3e4aSElliott Hughes """ 918*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 919*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 920*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 921*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 922*e1fe3e4aSElliott Hughes 923*e1fe3e4aSElliott Hughes def testContour_illegal_unkonwn_element(self): 924*e1fe3e4aSElliott Hughes # unknown element 925*e1fe3e4aSElliott Hughes glif = """ 926*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 927*e1fe3e4aSElliott Hughes <outline> 928*e1fe3e4aSElliott Hughes <contour> 929*e1fe3e4aSElliott Hughes <unknown/> 930*e1fe3e4aSElliott Hughes </contour> 931*e1fe3e4aSElliott Hughes </outline> 932*e1fe3e4aSElliott Hughes </glyph> 933*e1fe3e4aSElliott Hughes """ 934*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 935*e1fe3e4aSElliott Hughes 936*e1fe3e4aSElliott Hughes def testContourIdentifier(self): 937*e1fe3e4aSElliott Hughes glif = """ 938*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 939*e1fe3e4aSElliott Hughes <outline> 940*e1fe3e4aSElliott Hughes <contour identifier="foo"> 941*e1fe3e4aSElliott Hughes </contour> 942*e1fe3e4aSElliott Hughes </outline> 943*e1fe3e4aSElliott Hughes </glyph> 944*e1fe3e4aSElliott Hughes """ 945*e1fe3e4aSElliott Hughes py = """ 946*e1fe3e4aSElliott Hughes glyph.name = "a" 947*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "foo"}) 948*e1fe3e4aSElliott Hughes pointPen.endPath() 949*e1fe3e4aSElliott Hughes """ 950*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 951*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 952*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 953*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 954*e1fe3e4aSElliott Hughes 955*e1fe3e4aSElliott Hughes def testPointCoordinates_legal_int(self): 956*e1fe3e4aSElliott Hughes # legal: int 957*e1fe3e4aSElliott Hughes glif = """ 958*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 959*e1fe3e4aSElliott Hughes <outline> 960*e1fe3e4aSElliott Hughes <contour> 961*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move"/> 962*e1fe3e4aSElliott Hughes </contour> 963*e1fe3e4aSElliott Hughes </outline> 964*e1fe3e4aSElliott Hughes </glyph> 965*e1fe3e4aSElliott Hughes """ 966*e1fe3e4aSElliott Hughes py = """ 967*e1fe3e4aSElliott Hughes glyph.name = "a" 968*e1fe3e4aSElliott Hughes pointPen.beginPath() 969*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) 970*e1fe3e4aSElliott Hughes pointPen.endPath() 971*e1fe3e4aSElliott Hughes """ 972*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 973*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 974*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 975*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 976*e1fe3e4aSElliott Hughes 977*e1fe3e4aSElliott Hughes def testPointCoordinates_legal_float(self): 978*e1fe3e4aSElliott Hughes # legal: float 979*e1fe3e4aSElliott Hughes glif = """ 980*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 981*e1fe3e4aSElliott Hughes <outline> 982*e1fe3e4aSElliott Hughes <contour> 983*e1fe3e4aSElliott Hughes <point x="1.1" y="-2.2" type="move"/> 984*e1fe3e4aSElliott Hughes </contour> 985*e1fe3e4aSElliott Hughes </outline> 986*e1fe3e4aSElliott Hughes </glyph> 987*e1fe3e4aSElliott Hughes """ 988*e1fe3e4aSElliott Hughes py = """ 989*e1fe3e4aSElliott Hughes glyph.name = "a" 990*e1fe3e4aSElliott Hughes pointPen.beginPath() 991*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1.1, -2.2)], **{"segmentType" : "move", "smooth" : False}) 992*e1fe3e4aSElliott Hughes pointPen.endPath() 993*e1fe3e4aSElliott Hughes """ 994*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 995*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 996*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 997*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 998*e1fe3e4aSElliott Hughes 999*e1fe3e4aSElliott Hughes def testPointCoordinates_illegal_x(self): 1000*e1fe3e4aSElliott Hughes # illegal: x as string 1001*e1fe3e4aSElliott Hughes glif = """ 1002*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1003*e1fe3e4aSElliott Hughes <outline> 1004*e1fe3e4aSElliott Hughes <contour> 1005*e1fe3e4aSElliott Hughes <point x="a" y="2" type="move"/> 1006*e1fe3e4aSElliott Hughes </contour> 1007*e1fe3e4aSElliott Hughes </outline> 1008*e1fe3e4aSElliott Hughes </glyph> 1009*e1fe3e4aSElliott Hughes """ 1010*e1fe3e4aSElliott Hughes py = """ 1011*e1fe3e4aSElliott Hughes glyph.name = "a" 1012*e1fe3e4aSElliott Hughes pointPen.beginPath() 1013*e1fe3e4aSElliott Hughes pointPen.addPoint(*[("a", 2)], **{"segmentType" : "move", "smooth" : False}) 1014*e1fe3e4aSElliott Hughes pointPen.endPath() 1015*e1fe3e4aSElliott Hughes """ 1016*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1017*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1018*e1fe3e4aSElliott Hughes 1019*e1fe3e4aSElliott Hughes def testPointCoordinates_illegal_y(self): 1020*e1fe3e4aSElliott Hughes # illegal: y as string 1021*e1fe3e4aSElliott Hughes glif = """ 1022*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1023*e1fe3e4aSElliott Hughes <outline> 1024*e1fe3e4aSElliott Hughes <contour> 1025*e1fe3e4aSElliott Hughes <point x="1" y="a" type="move"/> 1026*e1fe3e4aSElliott Hughes </contour> 1027*e1fe3e4aSElliott Hughes </outline> 1028*e1fe3e4aSElliott Hughes </glyph> 1029*e1fe3e4aSElliott Hughes """ 1030*e1fe3e4aSElliott Hughes py = """ 1031*e1fe3e4aSElliott Hughes glyph.name = "a" 1032*e1fe3e4aSElliott Hughes pointPen.beginPath() 1033*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, "a")], **{"segmentType" : "move", "smooth" : False}) 1034*e1fe3e4aSElliott Hughes pointPen.endPath() 1035*e1fe3e4aSElliott Hughes """ 1036*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1037*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1038*e1fe3e4aSElliott Hughes 1039*e1fe3e4aSElliott Hughes def testPointTypeMove_legal(self): 1040*e1fe3e4aSElliott Hughes # legal 1041*e1fe3e4aSElliott Hughes glif = """ 1042*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1043*e1fe3e4aSElliott Hughes <outline> 1044*e1fe3e4aSElliott Hughes <contour> 1045*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move"/> 1046*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line"/> 1047*e1fe3e4aSElliott Hughes </contour> 1048*e1fe3e4aSElliott Hughes </outline> 1049*e1fe3e4aSElliott Hughes </glyph> 1050*e1fe3e4aSElliott Hughes """ 1051*e1fe3e4aSElliott Hughes py = """ 1052*e1fe3e4aSElliott Hughes glyph.name = "a" 1053*e1fe3e4aSElliott Hughes pointPen.beginPath() 1054*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) 1055*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) 1056*e1fe3e4aSElliott Hughes pointPen.endPath() 1057*e1fe3e4aSElliott Hughes """ 1058*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1059*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1060*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1061*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1062*e1fe3e4aSElliott Hughes 1063*e1fe3e4aSElliott Hughes def testPointTypeMove_legal_smooth(self): 1064*e1fe3e4aSElliott Hughes # legal: smooth=True 1065*e1fe3e4aSElliott Hughes glif = """ 1066*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1067*e1fe3e4aSElliott Hughes <outline> 1068*e1fe3e4aSElliott Hughes <contour> 1069*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" smooth="yes"/> 1070*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line"/> 1071*e1fe3e4aSElliott Hughes </contour> 1072*e1fe3e4aSElliott Hughes </outline> 1073*e1fe3e4aSElliott Hughes </glyph> 1074*e1fe3e4aSElliott Hughes """ 1075*e1fe3e4aSElliott Hughes py = """ 1076*e1fe3e4aSElliott Hughes glyph.name = "a" 1077*e1fe3e4aSElliott Hughes pointPen.beginPath() 1078*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : True}) 1079*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) 1080*e1fe3e4aSElliott Hughes pointPen.endPath() 1081*e1fe3e4aSElliott Hughes """ 1082*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1083*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1084*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1085*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1086*e1fe3e4aSElliott Hughes 1087*e1fe3e4aSElliott Hughes def testPointTypeMove_illegal_not_at_start(self): 1088*e1fe3e4aSElliott Hughes # illegal: not at start 1089*e1fe3e4aSElliott Hughes glif = """ 1090*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1091*e1fe3e4aSElliott Hughes <outline> 1092*e1fe3e4aSElliott Hughes <contour> 1093*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line"/> 1094*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move"/> 1095*e1fe3e4aSElliott Hughes </contour> 1096*e1fe3e4aSElliott Hughes </outline> 1097*e1fe3e4aSElliott Hughes </glyph> 1098*e1fe3e4aSElliott Hughes """ 1099*e1fe3e4aSElliott Hughes py = """ 1100*e1fe3e4aSElliott Hughes glyph.name = "a" 1101*e1fe3e4aSElliott Hughes pointPen.beginPath() 1102*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) 1103*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) 1104*e1fe3e4aSElliott Hughes pointPen.endPath() 1105*e1fe3e4aSElliott Hughes """ 1106*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1107*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1108*e1fe3e4aSElliott Hughes 1109*e1fe3e4aSElliott Hughes def testPointTypeLine_legal(self): 1110*e1fe3e4aSElliott Hughes # legal 1111*e1fe3e4aSElliott Hughes glif = """ 1112*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1113*e1fe3e4aSElliott Hughes <outline> 1114*e1fe3e4aSElliott Hughes <contour> 1115*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move"/> 1116*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line"/> 1117*e1fe3e4aSElliott Hughes </contour> 1118*e1fe3e4aSElliott Hughes </outline> 1119*e1fe3e4aSElliott Hughes </glyph> 1120*e1fe3e4aSElliott Hughes """ 1121*e1fe3e4aSElliott Hughes py = """ 1122*e1fe3e4aSElliott Hughes glyph.name = "a" 1123*e1fe3e4aSElliott Hughes pointPen.beginPath() 1124*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) 1125*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) 1126*e1fe3e4aSElliott Hughes pointPen.endPath() 1127*e1fe3e4aSElliott Hughes """ 1128*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1129*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1130*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1131*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1132*e1fe3e4aSElliott Hughes 1133*e1fe3e4aSElliott Hughes def testPointTypeLine_legal_start_of_contour(self): 1134*e1fe3e4aSElliott Hughes # legal: start of contour 1135*e1fe3e4aSElliott Hughes glif = """ 1136*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1137*e1fe3e4aSElliott Hughes <outline> 1138*e1fe3e4aSElliott Hughes <contour> 1139*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line"/> 1140*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line"/> 1141*e1fe3e4aSElliott Hughes </contour> 1142*e1fe3e4aSElliott Hughes </outline> 1143*e1fe3e4aSElliott Hughes </glyph> 1144*e1fe3e4aSElliott Hughes """ 1145*e1fe3e4aSElliott Hughes py = """ 1146*e1fe3e4aSElliott Hughes glyph.name = "a" 1147*e1fe3e4aSElliott Hughes pointPen.beginPath() 1148*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "line", "smooth" : False}) 1149*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : False}) 1150*e1fe3e4aSElliott Hughes pointPen.endPath() 1151*e1fe3e4aSElliott Hughes """ 1152*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1153*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1154*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1155*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1156*e1fe3e4aSElliott Hughes 1157*e1fe3e4aSElliott Hughes def testPointTypeLine_legal_smooth(self): 1158*e1fe3e4aSElliott Hughes # legal: smooth=True 1159*e1fe3e4aSElliott Hughes glif = """ 1160*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1161*e1fe3e4aSElliott Hughes <outline> 1162*e1fe3e4aSElliott Hughes <contour> 1163*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move"/> 1164*e1fe3e4aSElliott Hughes <point x="3" y="-4" type="line" smooth="yes"/> 1165*e1fe3e4aSElliott Hughes </contour> 1166*e1fe3e4aSElliott Hughes </outline> 1167*e1fe3e4aSElliott Hughes </glyph> 1168*e1fe3e4aSElliott Hughes """ 1169*e1fe3e4aSElliott Hughes py = """ 1170*e1fe3e4aSElliott Hughes glyph.name = "a" 1171*e1fe3e4aSElliott Hughes pointPen.beginPath() 1172*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"segmentType" : "move", "smooth" : False}) 1173*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(3, -4)], **{"segmentType" : "line", "smooth" : True}) 1174*e1fe3e4aSElliott Hughes pointPen.endPath() 1175*e1fe3e4aSElliott Hughes """ 1176*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1177*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1178*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1179*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1180*e1fe3e4aSElliott Hughes 1181*e1fe3e4aSElliott Hughes def testPointTypeCurve_legal(self): 1182*e1fe3e4aSElliott Hughes # legal 1183*e1fe3e4aSElliott Hughes glif = """ 1184*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1185*e1fe3e4aSElliott Hughes <outline> 1186*e1fe3e4aSElliott Hughes <contour> 1187*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1188*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1189*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1190*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1191*e1fe3e4aSElliott Hughes </contour> 1192*e1fe3e4aSElliott Hughes </outline> 1193*e1fe3e4aSElliott Hughes </glyph> 1194*e1fe3e4aSElliott Hughes """ 1195*e1fe3e4aSElliott Hughes py = """ 1196*e1fe3e4aSElliott Hughes glyph.name = "a" 1197*e1fe3e4aSElliott Hughes pointPen.beginPath() 1198*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1199*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1200*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1201*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1202*e1fe3e4aSElliott Hughes pointPen.endPath() 1203*e1fe3e4aSElliott Hughes """ 1204*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1205*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1206*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1207*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1208*e1fe3e4aSElliott Hughes 1209*e1fe3e4aSElliott Hughes def testPointTypeCurve_legal_start_of_contour(self): 1210*e1fe3e4aSElliott Hughes # legal: start of contour 1211*e1fe3e4aSElliott Hughes glif = """ 1212*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1213*e1fe3e4aSElliott Hughes <outline> 1214*e1fe3e4aSElliott Hughes <contour> 1215*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1216*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1217*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1218*e1fe3e4aSElliott Hughes </contour> 1219*e1fe3e4aSElliott Hughes </outline> 1220*e1fe3e4aSElliott Hughes </glyph> 1221*e1fe3e4aSElliott Hughes """ 1222*e1fe3e4aSElliott Hughes py = """ 1223*e1fe3e4aSElliott Hughes glyph.name = "a" 1224*e1fe3e4aSElliott Hughes pointPen.beginPath() 1225*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1226*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1227*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1228*e1fe3e4aSElliott Hughes pointPen.endPath() 1229*e1fe3e4aSElliott Hughes """ 1230*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1231*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1232*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1233*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1234*e1fe3e4aSElliott Hughes 1235*e1fe3e4aSElliott Hughes def testPointTypeCurve_legal_smooth(self): 1236*e1fe3e4aSElliott Hughes # legal: smooth=True 1237*e1fe3e4aSElliott Hughes glif = """ 1238*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1239*e1fe3e4aSElliott Hughes <outline> 1240*e1fe3e4aSElliott Hughes <contour> 1241*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1242*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1243*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1244*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve" smooth="yes"/> 1245*e1fe3e4aSElliott Hughes </contour> 1246*e1fe3e4aSElliott Hughes </outline> 1247*e1fe3e4aSElliott Hughes </glyph> 1248*e1fe3e4aSElliott Hughes """ 1249*e1fe3e4aSElliott Hughes py = """ 1250*e1fe3e4aSElliott Hughes glyph.name = "a" 1251*e1fe3e4aSElliott Hughes pointPen.beginPath() 1252*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1253*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1254*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1255*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : True}) 1256*e1fe3e4aSElliott Hughes pointPen.endPath() 1257*e1fe3e4aSElliott Hughes """ 1258*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1259*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1260*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1261*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1262*e1fe3e4aSElliott Hughes 1263*e1fe3e4aSElliott Hughes def testPointTypeCurve_legal_no_off_curves(self): 1264*e1fe3e4aSElliott Hughes # legal: no off-curves 1265*e1fe3e4aSElliott Hughes glif = """ 1266*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1267*e1fe3e4aSElliott Hughes <outline> 1268*e1fe3e4aSElliott Hughes <contour> 1269*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1270*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1271*e1fe3e4aSElliott Hughes </contour> 1272*e1fe3e4aSElliott Hughes </outline> 1273*e1fe3e4aSElliott Hughes </glyph> 1274*e1fe3e4aSElliott Hughes """ 1275*e1fe3e4aSElliott Hughes py = """ 1276*e1fe3e4aSElliott Hughes glyph.name = "a" 1277*e1fe3e4aSElliott Hughes pointPen.beginPath() 1278*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1279*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1280*e1fe3e4aSElliott Hughes pointPen.endPath() 1281*e1fe3e4aSElliott Hughes """ 1282*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1283*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1284*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1285*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1286*e1fe3e4aSElliott Hughes 1287*e1fe3e4aSElliott Hughes def testPointTypeCurve_legal_1_off_curve(self): 1288*e1fe3e4aSElliott Hughes # legal: 1 off-curve 1289*e1fe3e4aSElliott Hughes glif = """ 1290*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1291*e1fe3e4aSElliott Hughes <outline> 1292*e1fe3e4aSElliott Hughes <contour> 1293*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1294*e1fe3e4aSElliott Hughes <point x="50" y="100"/> 1295*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1296*e1fe3e4aSElliott Hughes </contour> 1297*e1fe3e4aSElliott Hughes </outline> 1298*e1fe3e4aSElliott Hughes </glyph> 1299*e1fe3e4aSElliott Hughes """ 1300*e1fe3e4aSElliott Hughes py = """ 1301*e1fe3e4aSElliott Hughes glyph.name = "a" 1302*e1fe3e4aSElliott Hughes pointPen.beginPath() 1303*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1304*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(50, 100)], **{"smooth" : False}) 1305*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1306*e1fe3e4aSElliott Hughes pointPen.endPath() 1307*e1fe3e4aSElliott Hughes """ 1308*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1309*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1310*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1311*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1312*e1fe3e4aSElliott Hughes 1313*e1fe3e4aSElliott Hughes def testPointTypeCurve_illegal_3_off_curves(self): 1314*e1fe3e4aSElliott Hughes # illegal: 3 off-curves 1315*e1fe3e4aSElliott Hughes glif = """ 1316*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1317*e1fe3e4aSElliott Hughes <outline> 1318*e1fe3e4aSElliott Hughes <contour> 1319*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1320*e1fe3e4aSElliott Hughes <point x="0" y="100"/> 1321*e1fe3e4aSElliott Hughes <point x="35" y="125"/> 1322*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1323*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1324*e1fe3e4aSElliott Hughes </contour> 1325*e1fe3e4aSElliott Hughes </outline> 1326*e1fe3e4aSElliott Hughes </glyph> 1327*e1fe3e4aSElliott Hughes """ 1328*e1fe3e4aSElliott Hughes py = """ 1329*e1fe3e4aSElliott Hughes glyph.name = "a" 1330*e1fe3e4aSElliott Hughes pointPen.beginPath() 1331*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1332*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 100)], **{"smooth" : False}) 1333*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(35, 125)], **{"smooth" : False}) 1334*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1335*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1336*e1fe3e4aSElliott Hughes pointPen.endPath() 1337*e1fe3e4aSElliott Hughes """ 1338*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1339*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1340*e1fe3e4aSElliott Hughes 1341*e1fe3e4aSElliott Hughes def testPointQCurve_legal(self): 1342*e1fe3e4aSElliott Hughes # legal 1343*e1fe3e4aSElliott Hughes glif = """ 1344*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1345*e1fe3e4aSElliott Hughes <outline> 1346*e1fe3e4aSElliott Hughes <contour> 1347*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1348*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1349*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1350*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve"/> 1351*e1fe3e4aSElliott Hughes </contour> 1352*e1fe3e4aSElliott Hughes </outline> 1353*e1fe3e4aSElliott Hughes </glyph> 1354*e1fe3e4aSElliott Hughes """ 1355*e1fe3e4aSElliott Hughes py = """ 1356*e1fe3e4aSElliott Hughes glyph.name = "a" 1357*e1fe3e4aSElliott Hughes pointPen.beginPath() 1358*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1359*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1360*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1361*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) 1362*e1fe3e4aSElliott Hughes pointPen.endPath() 1363*e1fe3e4aSElliott Hughes """ 1364*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1365*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1366*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1367*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1368*e1fe3e4aSElliott Hughes 1369*e1fe3e4aSElliott Hughes def testPointQCurve_legal_start_of_contour(self): 1370*e1fe3e4aSElliott Hughes # legal: start of contour 1371*e1fe3e4aSElliott Hughes glif = """ 1372*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1373*e1fe3e4aSElliott Hughes <outline> 1374*e1fe3e4aSElliott Hughes <contour> 1375*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve"/> 1376*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1377*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1378*e1fe3e4aSElliott Hughes </contour> 1379*e1fe3e4aSElliott Hughes </outline> 1380*e1fe3e4aSElliott Hughes </glyph> 1381*e1fe3e4aSElliott Hughes """ 1382*e1fe3e4aSElliott Hughes py = """ 1383*e1fe3e4aSElliott Hughes glyph.name = "a" 1384*e1fe3e4aSElliott Hughes pointPen.beginPath() 1385*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) 1386*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1387*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1388*e1fe3e4aSElliott Hughes pointPen.endPath() 1389*e1fe3e4aSElliott Hughes """ 1390*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1391*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1392*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1393*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1394*e1fe3e4aSElliott Hughes 1395*e1fe3e4aSElliott Hughes def testPointQCurve_legal_smooth(self): 1396*e1fe3e4aSElliott Hughes # legal: smooth=True 1397*e1fe3e4aSElliott Hughes glif = """ 1398*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1399*e1fe3e4aSElliott Hughes <outline> 1400*e1fe3e4aSElliott Hughes <contour> 1401*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1402*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1403*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1404*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve" smooth="yes"/> 1405*e1fe3e4aSElliott Hughes </contour> 1406*e1fe3e4aSElliott Hughes </outline> 1407*e1fe3e4aSElliott Hughes </glyph> 1408*e1fe3e4aSElliott Hughes """ 1409*e1fe3e4aSElliott Hughes py = """ 1410*e1fe3e4aSElliott Hughes glyph.name = "a" 1411*e1fe3e4aSElliott Hughes pointPen.beginPath() 1412*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1413*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1414*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1415*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : True}) 1416*e1fe3e4aSElliott Hughes pointPen.endPath() 1417*e1fe3e4aSElliott Hughes """ 1418*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1419*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1420*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1421*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1422*e1fe3e4aSElliott Hughes 1423*e1fe3e4aSElliott Hughes def testPointQCurve_legal_no_off_curves(self): 1424*e1fe3e4aSElliott Hughes # legal: no off-curves 1425*e1fe3e4aSElliott Hughes glif = """ 1426*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1427*e1fe3e4aSElliott Hughes <outline> 1428*e1fe3e4aSElliott Hughes <contour> 1429*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1430*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve"/> 1431*e1fe3e4aSElliott Hughes </contour> 1432*e1fe3e4aSElliott Hughes </outline> 1433*e1fe3e4aSElliott Hughes </glyph> 1434*e1fe3e4aSElliott Hughes """ 1435*e1fe3e4aSElliott Hughes py = """ 1436*e1fe3e4aSElliott Hughes glyph.name = "a" 1437*e1fe3e4aSElliott Hughes pointPen.beginPath() 1438*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1439*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) 1440*e1fe3e4aSElliott Hughes pointPen.endPath() 1441*e1fe3e4aSElliott Hughes """ 1442*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1443*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1444*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1445*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1446*e1fe3e4aSElliott Hughes 1447*e1fe3e4aSElliott Hughes def testPointQCurve_legal_one_off_curve(self): 1448*e1fe3e4aSElliott Hughes # legal: 1 off-curve 1449*e1fe3e4aSElliott Hughes glif = """ 1450*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1451*e1fe3e4aSElliott Hughes <outline> 1452*e1fe3e4aSElliott Hughes <contour> 1453*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1454*e1fe3e4aSElliott Hughes <point x="50" y="100"/> 1455*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve"/> 1456*e1fe3e4aSElliott Hughes </contour> 1457*e1fe3e4aSElliott Hughes </outline> 1458*e1fe3e4aSElliott Hughes </glyph> 1459*e1fe3e4aSElliott Hughes """ 1460*e1fe3e4aSElliott Hughes py = """ 1461*e1fe3e4aSElliott Hughes glyph.name = "a" 1462*e1fe3e4aSElliott Hughes pointPen.beginPath() 1463*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1464*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(50, 100)], **{"smooth" : False}) 1465*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) 1466*e1fe3e4aSElliott Hughes pointPen.endPath() 1467*e1fe3e4aSElliott Hughes """ 1468*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1469*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1470*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1471*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1472*e1fe3e4aSElliott Hughes 1473*e1fe3e4aSElliott Hughes def testPointQCurve_legal_3_off_curves(self): 1474*e1fe3e4aSElliott Hughes # legal: 3 off-curves 1475*e1fe3e4aSElliott Hughes glif = """ 1476*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1477*e1fe3e4aSElliott Hughes <outline> 1478*e1fe3e4aSElliott Hughes <contour> 1479*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1480*e1fe3e4aSElliott Hughes <point x="0" y="100"/> 1481*e1fe3e4aSElliott Hughes <point x="35" y="125"/> 1482*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1483*e1fe3e4aSElliott Hughes <point x="100" y="200" type="qcurve"/> 1484*e1fe3e4aSElliott Hughes </contour> 1485*e1fe3e4aSElliott Hughes </outline> 1486*e1fe3e4aSElliott Hughes </glyph> 1487*e1fe3e4aSElliott Hughes """ 1488*e1fe3e4aSElliott Hughes py = """ 1489*e1fe3e4aSElliott Hughes glyph.name = "a" 1490*e1fe3e4aSElliott Hughes pointPen.beginPath() 1491*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1492*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 100)], **{"smooth" : False}) 1493*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(35, 125)], **{"smooth" : False}) 1494*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1495*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "qcurve", "smooth" : False}) 1496*e1fe3e4aSElliott Hughes pointPen.endPath() 1497*e1fe3e4aSElliott Hughes """ 1498*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1499*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1500*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1501*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1502*e1fe3e4aSElliott Hughes 1503*e1fe3e4aSElliott Hughes def testSpecialCaseQCurve_legal_no_on_curve(self): 1504*e1fe3e4aSElliott Hughes # contour with no on curve 1505*e1fe3e4aSElliott Hughes glif = """ 1506*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1507*e1fe3e4aSElliott Hughes <outline> 1508*e1fe3e4aSElliott Hughes <contour> 1509*e1fe3e4aSElliott Hughes <point x="0" y="0"/> 1510*e1fe3e4aSElliott Hughes <point x="0" y="100"/> 1511*e1fe3e4aSElliott Hughes <point x="100" y="100"/> 1512*e1fe3e4aSElliott Hughes <point x="100" y="0"/> 1513*e1fe3e4aSElliott Hughes </contour> 1514*e1fe3e4aSElliott Hughes </outline> 1515*e1fe3e4aSElliott Hughes </glyph> 1516*e1fe3e4aSElliott Hughes """ 1517*e1fe3e4aSElliott Hughes py = """ 1518*e1fe3e4aSElliott Hughes glyph.name = "a" 1519*e1fe3e4aSElliott Hughes pointPen.beginPath() 1520*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"smooth" : False}) 1521*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 100)], **{"smooth" : False}) 1522*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 100)], **{"smooth" : False}) 1523*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 0)], **{"smooth" : False}) 1524*e1fe3e4aSElliott Hughes pointPen.endPath() 1525*e1fe3e4aSElliott Hughes """ 1526*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1527*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1528*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1529*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1530*e1fe3e4aSElliott Hughes 1531*e1fe3e4aSElliott Hughes def testPointTypeOffCurve_legal(self): 1532*e1fe3e4aSElliott Hughes # legal 1533*e1fe3e4aSElliott Hughes glif = """ 1534*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1535*e1fe3e4aSElliott Hughes <outline> 1536*e1fe3e4aSElliott Hughes <contour> 1537*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1538*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1539*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1540*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1541*e1fe3e4aSElliott Hughes </contour> 1542*e1fe3e4aSElliott Hughes </outline> 1543*e1fe3e4aSElliott Hughes </glyph> 1544*e1fe3e4aSElliott Hughes """ 1545*e1fe3e4aSElliott Hughes py = """ 1546*e1fe3e4aSElliott Hughes glyph.name = "a" 1547*e1fe3e4aSElliott Hughes pointPen.beginPath() 1548*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1549*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1550*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1551*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1552*e1fe3e4aSElliott Hughes pointPen.endPath() 1553*e1fe3e4aSElliott Hughes """ 1554*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1555*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1556*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1557*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1558*e1fe3e4aSElliott Hughes 1559*e1fe3e4aSElliott Hughes def testPointTypeOffCurve_legal_start_of_contour(self): 1560*e1fe3e4aSElliott Hughes # legal: start of contour 1561*e1fe3e4aSElliott Hughes glif = """ 1562*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1563*e1fe3e4aSElliott Hughes <outline> 1564*e1fe3e4aSElliott Hughes <contour> 1565*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1566*e1fe3e4aSElliott Hughes <point x="65" y="200"/> 1567*e1fe3e4aSElliott Hughes <point x="100" y="200" type="curve"/> 1568*e1fe3e4aSElliott Hughes </contour> 1569*e1fe3e4aSElliott Hughes </outline> 1570*e1fe3e4aSElliott Hughes </glyph> 1571*e1fe3e4aSElliott Hughes """ 1572*e1fe3e4aSElliott Hughes py = """ 1573*e1fe3e4aSElliott Hughes glyph.name = "a" 1574*e1fe3e4aSElliott Hughes pointPen.beginPath() 1575*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1576*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(65, 200)], **{"smooth" : False}) 1577*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(100, 200)], **{"segmentType" : "curve", "smooth" : False}) 1578*e1fe3e4aSElliott Hughes pointPen.endPath() 1579*e1fe3e4aSElliott Hughes """ 1580*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1581*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1582*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1583*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1584*e1fe3e4aSElliott Hughes 1585*e1fe3e4aSElliott Hughes def testPointTypeOffCurve_illegal_before_move(self): 1586*e1fe3e4aSElliott Hughes # before move 1587*e1fe3e4aSElliott Hughes glif = """ 1588*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1589*e1fe3e4aSElliott Hughes <outline> 1590*e1fe3e4aSElliott Hughes <contour> 1591*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1592*e1fe3e4aSElliott Hughes <point x="0" y="0" type="move"/> 1593*e1fe3e4aSElliott Hughes </contour> 1594*e1fe3e4aSElliott Hughes </outline> 1595*e1fe3e4aSElliott Hughes </glyph> 1596*e1fe3e4aSElliott Hughes """ 1597*e1fe3e4aSElliott Hughes py = """ 1598*e1fe3e4aSElliott Hughes glyph.name = "a" 1599*e1fe3e4aSElliott Hughes pointPen.beginPath() 1600*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1601*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "move", "smooth" : False}) 1602*e1fe3e4aSElliott Hughes pointPen.endPath() 1603*e1fe3e4aSElliott Hughes """ 1604*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1605*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1606*e1fe3e4aSElliott Hughes 1607*e1fe3e4aSElliott Hughes def testPointTypeOffCurve_illegal_before_line(self): 1608*e1fe3e4aSElliott Hughes # before line 1609*e1fe3e4aSElliott Hughes glif = """ 1610*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1611*e1fe3e4aSElliott Hughes <outline> 1612*e1fe3e4aSElliott Hughes <contour> 1613*e1fe3e4aSElliott Hughes <point x="0" y="65"/> 1614*e1fe3e4aSElliott Hughes <point x="0" y="0" type="line"/> 1615*e1fe3e4aSElliott Hughes </contour> 1616*e1fe3e4aSElliott Hughes </outline> 1617*e1fe3e4aSElliott Hughes </glyph> 1618*e1fe3e4aSElliott Hughes """ 1619*e1fe3e4aSElliott Hughes py = """ 1620*e1fe3e4aSElliott Hughes glyph.name = "a" 1621*e1fe3e4aSElliott Hughes pointPen.beginPath() 1622*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : False}) 1623*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "line", "smooth" : False}) 1624*e1fe3e4aSElliott Hughes pointPen.endPath() 1625*e1fe3e4aSElliott Hughes """ 1626*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1627*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1628*e1fe3e4aSElliott Hughes 1629*e1fe3e4aSElliott Hughes def testPointTypeOffCurve_illegal_smooth(self): 1630*e1fe3e4aSElliott Hughes # smooth=True 1631*e1fe3e4aSElliott Hughes glif = """ 1632*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1633*e1fe3e4aSElliott Hughes <outline> 1634*e1fe3e4aSElliott Hughes <contour> 1635*e1fe3e4aSElliott Hughes <point x="0" y="65" smooth="yess"/> 1636*e1fe3e4aSElliott Hughes <point x="0" y="0" type="curve"/> 1637*e1fe3e4aSElliott Hughes </contour> 1638*e1fe3e4aSElliott Hughes </outline> 1639*e1fe3e4aSElliott Hughes </glyph> 1640*e1fe3e4aSElliott Hughes """ 1641*e1fe3e4aSElliott Hughes py = """ 1642*e1fe3e4aSElliott Hughes glyph.name = "a" 1643*e1fe3e4aSElliott Hughes pointPen.beginPath() 1644*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 65)], **{"smooth" : True}) 1645*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(0, 0)], **{"segmentType" : "curve", "smooth" : False}) 1646*e1fe3e4aSElliott Hughes pointPen.endPath() 1647*e1fe3e4aSElliott Hughes """ 1648*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1649*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1650*e1fe3e4aSElliott Hughes 1651*e1fe3e4aSElliott Hughes def testOpenContourLooseOffCurves(self): 1652*e1fe3e4aSElliott Hughes glif = """ 1653*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1654*e1fe3e4aSElliott Hughes <outline> 1655*e1fe3e4aSElliott Hughes <contour> 1656*e1fe3e4aSElliott Hughes <point x="1" y="2" type="move"/> 1657*e1fe3e4aSElliott Hughes <point x="1" y="2"/> 1658*e1fe3e4aSElliott Hughes <point x="1" y="2"/> 1659*e1fe3e4aSElliott Hughes <point x="1" y="2" type="curve"/> 1660*e1fe3e4aSElliott Hughes <point x="1" y="2"/> 1661*e1fe3e4aSElliott Hughes </contour> 1662*e1fe3e4aSElliott Hughes </outline> 1663*e1fe3e4aSElliott Hughes </glyph> 1664*e1fe3e4aSElliott Hughes """ 1665*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1666*e1fe3e4aSElliott Hughes py = """ 1667*e1fe3e4aSElliott Hughes glyph.name = "a" 1668*e1fe3e4aSElliott Hughes pointPen.beginPath() 1669*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"segmentType" : "move", "smooth" : False}) 1670*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"smooth" : False}) 1671*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"smooth" : False}) 1672*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"segmentType" : "curve", "smooth" : False}) 1673*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, 2)], **{"smooth" : False}) 1674*e1fe3e4aSElliott Hughes pointPen.endPath() 1675*e1fe3e4aSElliott Hughes """ 1676*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1677*e1fe3e4aSElliott Hughes 1678*e1fe3e4aSElliott Hughes def testPointIdentifier(self): 1679*e1fe3e4aSElliott Hughes glif = """ 1680*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1681*e1fe3e4aSElliott Hughes <outline> 1682*e1fe3e4aSElliott Hughes <contour> 1683*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="1"/> 1684*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="2"/> 1685*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="3"/> 1686*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="4"/> 1687*e1fe3e4aSElliott Hughes </contour> 1688*e1fe3e4aSElliott Hughes </outline> 1689*e1fe3e4aSElliott Hughes </glyph> 1690*e1fe3e4aSElliott Hughes """ 1691*e1fe3e4aSElliott Hughes py = """ 1692*e1fe3e4aSElliott Hughes glyph.name = "a" 1693*e1fe3e4aSElliott Hughes pointPen.beginPath() 1694*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "1", "segmentType" : "move", "smooth" : False}) 1695*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "2", "segmentType" : "line", "smooth" : False}) 1696*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "3", "segmentType" : "curve", "smooth" : False}) 1697*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "4", "segmentType" : "qcurve", "smooth" : False}) 1698*e1fe3e4aSElliott Hughes pointPen.endPath() 1699*e1fe3e4aSElliott Hughes """ 1700*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1701*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1702*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1703*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1704*e1fe3e4aSElliott Hughes 1705*e1fe3e4aSElliott Hughes def testIdentifierConflict_legal_no_conflict(self): 1706*e1fe3e4aSElliott Hughes glif = """ 1707*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1708*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1709*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1710*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1711*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1712*e1fe3e4aSElliott Hughes <outline> 1713*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1714*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 1715*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1716*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1717*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1718*e1fe3e4aSElliott Hughes </contour> 1719*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1720*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1721*e1fe3e4aSElliott Hughes </contour> 1722*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1723*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1724*e1fe3e4aSElliott Hughes </outline> 1725*e1fe3e4aSElliott Hughes </glyph> 1726*e1fe3e4aSElliott Hughes """ 1727*e1fe3e4aSElliott Hughes py = """ 1728*e1fe3e4aSElliott Hughes glyph.name = "a" 1729*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1730*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1731*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1732*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 1733*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1734*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1735*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1736*e1fe3e4aSElliott Hughes pointPen.endPath() 1737*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1738*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1739*e1fe3e4aSElliott Hughes pointPen.endPath() 1740*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1741*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1742*e1fe3e4aSElliott Hughes """ 1743*e1fe3e4aSElliott Hughes resultGlif = self.pyToGLIF(py) 1744*e1fe3e4aSElliott Hughes resultPy = self.glifToPy(glif) 1745*e1fe3e4aSElliott Hughes self.assertEqual(glif, resultGlif) 1746*e1fe3e4aSElliott Hughes self.assertEqual(py, resultPy) 1747*e1fe3e4aSElliott Hughes 1748*e1fe3e4aSElliott Hughes def testIdentifierConflict_point_point(self): 1749*e1fe3e4aSElliott Hughes # point - point 1750*e1fe3e4aSElliott Hughes glif = """ 1751*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1752*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1753*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1754*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1755*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1756*e1fe3e4aSElliott Hughes <outline> 1757*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1758*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 1759*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point1"/> 1760*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1761*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1762*e1fe3e4aSElliott Hughes </contour> 1763*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1764*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1765*e1fe3e4aSElliott Hughes </contour> 1766*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1767*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1768*e1fe3e4aSElliott Hughes </outline> 1769*e1fe3e4aSElliott Hughes </glyph> 1770*e1fe3e4aSElliott Hughes """ 1771*e1fe3e4aSElliott Hughes py = """ 1772*e1fe3e4aSElliott Hughes glyph.name = "a" 1773*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1774*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1775*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1776*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 1777*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "line", "smooth" : False}) 1778*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1779*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1780*e1fe3e4aSElliott Hughes pointPen.endPath() 1781*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1782*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1783*e1fe3e4aSElliott Hughes pointPen.endPath() 1784*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1785*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1786*e1fe3e4aSElliott Hughes """ 1787*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1788*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1789*e1fe3e4aSElliott Hughes 1790*e1fe3e4aSElliott Hughes def testIdentifierConflict_point_contour(self): 1791*e1fe3e4aSElliott Hughes # point - contour 1792*e1fe3e4aSElliott Hughes glif = """ 1793*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1794*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1795*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1796*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1797*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1798*e1fe3e4aSElliott Hughes <outline> 1799*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1800*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="contour1"/> 1801*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1802*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1803*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1804*e1fe3e4aSElliott Hughes </contour> 1805*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1806*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1807*e1fe3e4aSElliott Hughes </contour> 1808*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1809*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1810*e1fe3e4aSElliott Hughes </outline> 1811*e1fe3e4aSElliott Hughes </glyph> 1812*e1fe3e4aSElliott Hughes """ 1813*e1fe3e4aSElliott Hughes py = """ 1814*e1fe3e4aSElliott Hughes glyph.name = "a" 1815*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1816*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1817*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1818*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "contour1", "segmentType" : "move", "smooth" : False}) 1819*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1820*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1821*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1822*e1fe3e4aSElliott Hughes pointPen.endPath() 1823*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1824*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1825*e1fe3e4aSElliott Hughes pointPen.endPath() 1826*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1827*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1828*e1fe3e4aSElliott Hughes """ 1829*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1830*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1831*e1fe3e4aSElliott Hughes 1832*e1fe3e4aSElliott Hughes def testIdentifierConflict_point_component(self): 1833*e1fe3e4aSElliott Hughes # point - component 1834*e1fe3e4aSElliott Hughes glif = """ 1835*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1836*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1837*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1838*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1839*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1840*e1fe3e4aSElliott Hughes <outline> 1841*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1842*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="component1"/> 1843*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1844*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1845*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1846*e1fe3e4aSElliott Hughes </contour> 1847*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1848*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1849*e1fe3e4aSElliott Hughes </contour> 1850*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1851*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1852*e1fe3e4aSElliott Hughes </outline> 1853*e1fe3e4aSElliott Hughes </glyph> 1854*e1fe3e4aSElliott Hughes """ 1855*e1fe3e4aSElliott Hughes py = """ 1856*e1fe3e4aSElliott Hughes glyph.name = "a" 1857*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1858*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1859*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1860*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "component1", "segmentType" : "move", "smooth" : False}) 1861*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1862*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1863*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1864*e1fe3e4aSElliott Hughes pointPen.endPath() 1865*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1866*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1867*e1fe3e4aSElliott Hughes pointPen.endPath() 1868*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1869*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1870*e1fe3e4aSElliott Hughes """ 1871*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1872*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1873*e1fe3e4aSElliott Hughes 1874*e1fe3e4aSElliott Hughes def testIdentifierConflict_point_guideline(self): 1875*e1fe3e4aSElliott Hughes # point - guideline 1876*e1fe3e4aSElliott Hughes glif = """ 1877*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1878*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1879*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1880*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1881*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1882*e1fe3e4aSElliott Hughes <outline> 1883*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1884*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="guideline1"/> 1885*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1886*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1887*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1888*e1fe3e4aSElliott Hughes </contour> 1889*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1890*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1891*e1fe3e4aSElliott Hughes </contour> 1892*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1893*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1894*e1fe3e4aSElliott Hughes </outline> 1895*e1fe3e4aSElliott Hughes </glyph> 1896*e1fe3e4aSElliott Hughes """ 1897*e1fe3e4aSElliott Hughes py = """ 1898*e1fe3e4aSElliott Hughes glyph.name = "a" 1899*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1900*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1901*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1902*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "guideline1", "segmentType" : "move", "smooth" : False}) 1903*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1904*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1905*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1906*e1fe3e4aSElliott Hughes pointPen.endPath() 1907*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1908*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1909*e1fe3e4aSElliott Hughes pointPen.endPath() 1910*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1911*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1912*e1fe3e4aSElliott Hughes """ 1913*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1914*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1915*e1fe3e4aSElliott Hughes 1916*e1fe3e4aSElliott Hughes def testIdentifierConflict_point_anchor(self): 1917*e1fe3e4aSElliott Hughes # point - anchor 1918*e1fe3e4aSElliott Hughes glif = """ 1919*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1920*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1921*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1922*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1923*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1924*e1fe3e4aSElliott Hughes <outline> 1925*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1926*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="anchor1"/> 1927*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1928*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1929*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1930*e1fe3e4aSElliott Hughes </contour> 1931*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 1932*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1933*e1fe3e4aSElliott Hughes </contour> 1934*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1935*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1936*e1fe3e4aSElliott Hughes </outline> 1937*e1fe3e4aSElliott Hughes </glyph> 1938*e1fe3e4aSElliott Hughes """ 1939*e1fe3e4aSElliott Hughes py = """ 1940*e1fe3e4aSElliott Hughes glyph.name = "a" 1941*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1942*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1943*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1944*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "anchor1", "segmentType" : "move", "smooth" : False}) 1945*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1946*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1947*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1948*e1fe3e4aSElliott Hughes pointPen.endPath() 1949*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 1950*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1951*e1fe3e4aSElliott Hughes pointPen.endPath() 1952*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1953*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1954*e1fe3e4aSElliott Hughes """ 1955*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1956*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1957*e1fe3e4aSElliott Hughes 1958*e1fe3e4aSElliott Hughes def testIdentifierConflict_contour_contour(self): 1959*e1fe3e4aSElliott Hughes # contour - contour 1960*e1fe3e4aSElliott Hughes glif = """ 1961*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 1962*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 1963*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 1964*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 1965*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 1966*e1fe3e4aSElliott Hughes <outline> 1967*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1968*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 1969*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 1970*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 1971*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 1972*e1fe3e4aSElliott Hughes </contour> 1973*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 1974*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 1975*e1fe3e4aSElliott Hughes </contour> 1976*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 1977*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 1978*e1fe3e4aSElliott Hughes </outline> 1979*e1fe3e4aSElliott Hughes </glyph> 1980*e1fe3e4aSElliott Hughes """ 1981*e1fe3e4aSElliott Hughes py = """ 1982*e1fe3e4aSElliott Hughes glyph.name = "a" 1983*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 1984*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 1985*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1986*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 1987*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 1988*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 1989*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 1990*e1fe3e4aSElliott Hughes pointPen.endPath() 1991*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 1992*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 1993*e1fe3e4aSElliott Hughes pointPen.endPath() 1994*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 1995*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 1996*e1fe3e4aSElliott Hughes """ 1997*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 1998*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 1999*e1fe3e4aSElliott Hughes 2000*e1fe3e4aSElliott Hughes def testIdentifierConflict_contour_component(self): 2001*e1fe3e4aSElliott Hughes # contour - component 2002*e1fe3e4aSElliott Hughes glif = """ 2003*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2004*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2005*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2006*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2007*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2008*e1fe3e4aSElliott Hughes <outline> 2009*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2010*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2011*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2012*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2013*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2014*e1fe3e4aSElliott Hughes </contour> 2015*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2016*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2017*e1fe3e4aSElliott Hughes </contour> 2018*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="contour1"/> 2019*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2020*e1fe3e4aSElliott Hughes </outline> 2021*e1fe3e4aSElliott Hughes </glyph> 2022*e1fe3e4aSElliott Hughes """ 2023*e1fe3e4aSElliott Hughes py = """ 2024*e1fe3e4aSElliott Hughes glyph.name = "a" 2025*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2026*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2027*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2028*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2029*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2030*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2031*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2032*e1fe3e4aSElliott Hughes pointPen.endPath() 2033*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2034*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2035*e1fe3e4aSElliott Hughes pointPen.endPath() 2036*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "contour1"}) 2037*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2038*e1fe3e4aSElliott Hughes """ 2039*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2040*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2041*e1fe3e4aSElliott Hughes 2042*e1fe3e4aSElliott Hughes def testIdentifierConflict_contour_guideline(self): 2043*e1fe3e4aSElliott Hughes # contour - guideline 2044*e1fe3e4aSElliott Hughes glif = """ 2045*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2046*e1fe3e4aSElliott Hughes <guideline x="0" identifier="contour1"/> 2047*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2048*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2049*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2050*e1fe3e4aSElliott Hughes <outline> 2051*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2052*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2053*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2054*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2055*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2056*e1fe3e4aSElliott Hughes </contour> 2057*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2058*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2059*e1fe3e4aSElliott Hughes </contour> 2060*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2061*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2062*e1fe3e4aSElliott Hughes </outline> 2063*e1fe3e4aSElliott Hughes </glyph> 2064*e1fe3e4aSElliott Hughes """ 2065*e1fe3e4aSElliott Hughes py = """ 2066*e1fe3e4aSElliott Hughes glyph.name = "a" 2067*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "contour1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2068*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2069*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2070*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2071*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2072*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2073*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2074*e1fe3e4aSElliott Hughes pointPen.endPath() 2075*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2076*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2077*e1fe3e4aSElliott Hughes pointPen.endPath() 2078*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2079*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2080*e1fe3e4aSElliott Hughes """ 2081*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2082*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2083*e1fe3e4aSElliott Hughes 2084*e1fe3e4aSElliott Hughes def testIdentifierConflict_contour_anchor(self): 2085*e1fe3e4aSElliott Hughes # contour - anchor 2086*e1fe3e4aSElliott Hughes glif = """ 2087*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2088*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2089*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2090*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2091*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2092*e1fe3e4aSElliott Hughes <outline> 2093*e1fe3e4aSElliott Hughes <contour identifier="anchor1"> 2094*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2095*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2096*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2097*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2098*e1fe3e4aSElliott Hughes </contour> 2099*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2100*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2101*e1fe3e4aSElliott Hughes </contour> 2102*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2103*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2104*e1fe3e4aSElliott Hughes </outline> 2105*e1fe3e4aSElliott Hughes </glyph> 2106*e1fe3e4aSElliott Hughes """ 2107*e1fe3e4aSElliott Hughes py = """ 2108*e1fe3e4aSElliott Hughes glyph.name = "a" 2109*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2110*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2111*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "anchor1"}) 2112*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2113*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2114*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2115*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2116*e1fe3e4aSElliott Hughes pointPen.endPath() 2117*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2118*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2119*e1fe3e4aSElliott Hughes pointPen.endPath() 2120*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2121*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2122*e1fe3e4aSElliott Hughes """ 2123*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2124*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2125*e1fe3e4aSElliott Hughes 2126*e1fe3e4aSElliott Hughes def testIdentifierConflict_component_component(self): 2127*e1fe3e4aSElliott Hughes # component - component 2128*e1fe3e4aSElliott Hughes glif = """ 2129*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2130*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2131*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2132*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2133*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2134*e1fe3e4aSElliott Hughes <outline> 2135*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2136*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2137*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2138*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2139*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2140*e1fe3e4aSElliott Hughes </contour> 2141*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2142*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2143*e1fe3e4aSElliott Hughes </contour> 2144*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2145*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2146*e1fe3e4aSElliott Hughes </outline> 2147*e1fe3e4aSElliott Hughes </glyph> 2148*e1fe3e4aSElliott Hughes """ 2149*e1fe3e4aSElliott Hughes py = """ 2150*e1fe3e4aSElliott Hughes glyph.name = "a" 2151*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2152*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2153*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2154*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2155*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2156*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2157*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2158*e1fe3e4aSElliott Hughes pointPen.endPath() 2159*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2160*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2161*e1fe3e4aSElliott Hughes pointPen.endPath() 2162*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2163*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2164*e1fe3e4aSElliott Hughes """ 2165*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2166*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2167*e1fe3e4aSElliott Hughes 2168*e1fe3e4aSElliott Hughes def testIdentifierConflict_component_guideline(self): 2169*e1fe3e4aSElliott Hughes # component - guideline 2170*e1fe3e4aSElliott Hughes glif = """ 2171*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2172*e1fe3e4aSElliott Hughes <guideline x="0" identifier="component1"/> 2173*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2174*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2175*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2176*e1fe3e4aSElliott Hughes <outline> 2177*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2178*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2179*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2180*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2181*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2182*e1fe3e4aSElliott Hughes </contour> 2183*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2184*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2185*e1fe3e4aSElliott Hughes </contour> 2186*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2187*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2188*e1fe3e4aSElliott Hughes </outline> 2189*e1fe3e4aSElliott Hughes </glyph> 2190*e1fe3e4aSElliott Hughes """ 2191*e1fe3e4aSElliott Hughes py = """ 2192*e1fe3e4aSElliott Hughes glyph.name = "a" 2193*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "component1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2194*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2195*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2196*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2197*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2198*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2199*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2200*e1fe3e4aSElliott Hughes pointPen.endPath() 2201*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2202*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2203*e1fe3e4aSElliott Hughes pointPen.endPath() 2204*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2205*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2206*e1fe3e4aSElliott Hughes """ 2207*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2208*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2209*e1fe3e4aSElliott Hughes 2210*e1fe3e4aSElliott Hughes def testIdentifierConflict_component_anchor(self): 2211*e1fe3e4aSElliott Hughes # component - anchor 2212*e1fe3e4aSElliott Hughes glif = """ 2213*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2214*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2215*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2216*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2217*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2218*e1fe3e4aSElliott Hughes <outline> 2219*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2220*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2221*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2222*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2223*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2224*e1fe3e4aSElliott Hughes </contour> 2225*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2226*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2227*e1fe3e4aSElliott Hughes </contour> 2228*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="anchor1"/> 2229*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2230*e1fe3e4aSElliott Hughes </outline> 2231*e1fe3e4aSElliott Hughes </glyph> 2232*e1fe3e4aSElliott Hughes """ 2233*e1fe3e4aSElliott Hughes py = """ 2234*e1fe3e4aSElliott Hughes glyph.name = "a" 2235*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2236*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2237*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2238*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2239*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2240*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2241*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2242*e1fe3e4aSElliott Hughes pointPen.endPath() 2243*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2244*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2245*e1fe3e4aSElliott Hughes pointPen.endPath() 2246*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "anchor1"}) 2247*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2248*e1fe3e4aSElliott Hughes """ 2249*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2250*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2251*e1fe3e4aSElliott Hughes 2252*e1fe3e4aSElliott Hughes def testIdentifierConflict_guideline_guideline(self): 2253*e1fe3e4aSElliott Hughes # guideline - guideline 2254*e1fe3e4aSElliott Hughes glif = """ 2255*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2256*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2257*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2258*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2259*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2260*e1fe3e4aSElliott Hughes <outline> 2261*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2262*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2263*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2264*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2265*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2266*e1fe3e4aSElliott Hughes </contour> 2267*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2268*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2269*e1fe3e4aSElliott Hughes </contour> 2270*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2271*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2272*e1fe3e4aSElliott Hughes </outline> 2273*e1fe3e4aSElliott Hughes </glyph> 2274*e1fe3e4aSElliott Hughes """ 2275*e1fe3e4aSElliott Hughes py = """ 2276*e1fe3e4aSElliott Hughes glyph.name = "a" 2277*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline1", "x" : 0}] 2278*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2279*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2280*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2281*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2282*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2283*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2284*e1fe3e4aSElliott Hughes pointPen.endPath() 2285*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2286*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2287*e1fe3e4aSElliott Hughes pointPen.endPath() 2288*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2289*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2290*e1fe3e4aSElliott Hughes """ 2291*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2292*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2293*e1fe3e4aSElliott Hughes 2294*e1fe3e4aSElliott Hughes def testIdentifierConflict_guideline_anchor(self): 2295*e1fe3e4aSElliott Hughes # guideline - anchor 2296*e1fe3e4aSElliott Hughes glif = """ 2297*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2298*e1fe3e4aSElliott Hughes <guideline x="0" identifier="anchor1"/> 2299*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2300*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2301*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor2"/> 2302*e1fe3e4aSElliott Hughes <outline> 2303*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2304*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2305*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2306*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2307*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2308*e1fe3e4aSElliott Hughes </contour> 2309*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2310*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2311*e1fe3e4aSElliott Hughes </contour> 2312*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2313*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2314*e1fe3e4aSElliott Hughes </outline> 2315*e1fe3e4aSElliott Hughes </glyph> 2316*e1fe3e4aSElliott Hughes """ 2317*e1fe3e4aSElliott Hughes py = """ 2318*e1fe3e4aSElliott Hughes glyph.name = "a" 2319*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "anchor1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2320*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor2", "x" : 0, "y" : 0}] 2321*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2322*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2323*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2324*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2325*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2326*e1fe3e4aSElliott Hughes pointPen.endPath() 2327*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2328*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2329*e1fe3e4aSElliott Hughes pointPen.endPath() 2330*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2331*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2332*e1fe3e4aSElliott Hughes """ 2333*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2334*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2335*e1fe3e4aSElliott Hughes 2336*e1fe3e4aSElliott Hughes def testIdentifierConflict_anchor_anchor(self): 2337*e1fe3e4aSElliott Hughes # anchor - anchor 2338*e1fe3e4aSElliott Hughes glif = """ 2339*e1fe3e4aSElliott Hughes <glyph name="a" format="2"> 2340*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline1"/> 2341*e1fe3e4aSElliott Hughes <guideline x="0" identifier="guideline2"/> 2342*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2343*e1fe3e4aSElliott Hughes <anchor x="0" y="0" identifier="anchor1"/> 2344*e1fe3e4aSElliott Hughes <outline> 2345*e1fe3e4aSElliott Hughes <contour identifier="contour1"> 2346*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point1"/> 2347*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="line" identifier="point2"/> 2348*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="curve" identifier="point3"/> 2349*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="qcurve" identifier="point4"/> 2350*e1fe3e4aSElliott Hughes </contour> 2351*e1fe3e4aSElliott Hughes <contour identifier="contour2"> 2352*e1fe3e4aSElliott Hughes <point x="1" y="-2" type="move" identifier="point5"/> 2353*e1fe3e4aSElliott Hughes </contour> 2354*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component1"/> 2355*e1fe3e4aSElliott Hughes <component base="x" xyScale="1" yxScale="1" xOffset="1" yOffset="1" identifier="component2"/> 2356*e1fe3e4aSElliott Hughes </outline> 2357*e1fe3e4aSElliott Hughes </glyph> 2358*e1fe3e4aSElliott Hughes """ 2359*e1fe3e4aSElliott Hughes py = """ 2360*e1fe3e4aSElliott Hughes glyph.name = "a" 2361*e1fe3e4aSElliott Hughes glyph.guidelines = [{"identifier" : "guideline1", "x" : 0}, {"identifier" : "guideline2", "x" : 0}] 2362*e1fe3e4aSElliott Hughes glyph.anchors = [{"identifier" : "anchor1", "x" : 0, "y" : 0}, {"identifier" : "anchor1", "x" : 0, "y" : 0}] 2363*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour1"}) 2364*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point1", "segmentType" : "move", "smooth" : False}) 2365*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point2", "segmentType" : "line", "smooth" : False}) 2366*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point3", "segmentType" : "curve", "smooth" : False}) 2367*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point4", "segmentType" : "qcurve", "smooth" : False}) 2368*e1fe3e4aSElliott Hughes pointPen.endPath() 2369*e1fe3e4aSElliott Hughes pointPen.beginPath(**{"identifier" : "contour2"}) 2370*e1fe3e4aSElliott Hughes pointPen.addPoint(*[(1, -2)], **{"identifier" : "point5", "segmentType" : "move", "smooth" : False}) 2371*e1fe3e4aSElliott Hughes pointPen.endPath() 2372*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component1"}) 2373*e1fe3e4aSElliott Hughes pointPen.addComponent(*["x", (1, 1, 1, 1, 1, 1)], **{"identifier" : "component2"}) 2374*e1fe3e4aSElliott Hughes """ 2375*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.pyToGLIF, py) 2376*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, self.glifToPy, glif) 2377