1*e1fe3e4aSElliott Hughesimport os 2*e1fe3e4aSElliott Hughesimport shutil 3*e1fe3e4aSElliott Hughesimport unittest 4*e1fe3e4aSElliott Hughesimport tempfile 5*e1fe3e4aSElliott Hughesfrom io import open 6*e1fe3e4aSElliott Hughesfrom fontTools.ufoLib import UFOReader, UFOWriter, UFOLibError 7*e1fe3e4aSElliott Hughesfrom fontTools.ufoLib.glifLib import GlifLibError 8*e1fe3e4aSElliott Hughesfrom fontTools.misc import plistlib 9*e1fe3e4aSElliott Hughesfrom .testSupport import fontInfoVersion3 10*e1fe3e4aSElliott Hughes 11*e1fe3e4aSElliott Hughes 12*e1fe3e4aSElliott Hughesclass TestInfoObject: 13*e1fe3e4aSElliott Hughes pass 14*e1fe3e4aSElliott Hughes 15*e1fe3e4aSElliott Hughes 16*e1fe3e4aSElliott Hughes# -------------- 17*e1fe3e4aSElliott Hughes# fontinfo.plist 18*e1fe3e4aSElliott Hughes# -------------- 19*e1fe3e4aSElliott Hughes 20*e1fe3e4aSElliott Hughes 21*e1fe3e4aSElliott Hughesclass ReadFontInfoVersion3TestCase(unittest.TestCase): 22*e1fe3e4aSElliott Hughes def setUp(self): 23*e1fe3e4aSElliott Hughes self.dstDir = tempfile.mktemp() 24*e1fe3e4aSElliott Hughes os.mkdir(self.dstDir) 25*e1fe3e4aSElliott Hughes metaInfo = {"creator": "test", "formatVersion": 3} 26*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, "metainfo.plist") 27*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 28*e1fe3e4aSElliott Hughes plistlib.dump(metaInfo, f) 29*e1fe3e4aSElliott Hughes 30*e1fe3e4aSElliott Hughes def tearDown(self): 31*e1fe3e4aSElliott Hughes shutil.rmtree(self.dstDir) 32*e1fe3e4aSElliott Hughes 33*e1fe3e4aSElliott Hughes def _writeInfoToPlist(self, info): 34*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, "fontinfo.plist") 35*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 36*e1fe3e4aSElliott Hughes plistlib.dump(info, f) 37*e1fe3e4aSElliott Hughes 38*e1fe3e4aSElliott Hughes def testRead(self): 39*e1fe3e4aSElliott Hughes originalData = dict(fontInfoVersion3) 40*e1fe3e4aSElliott Hughes self._writeInfoToPlist(originalData) 41*e1fe3e4aSElliott Hughes infoObject = TestInfoObject() 42*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 43*e1fe3e4aSElliott Hughes reader.readInfo(infoObject) 44*e1fe3e4aSElliott Hughes readData = {} 45*e1fe3e4aSElliott Hughes for attr in list(fontInfoVersion3.keys()): 46*e1fe3e4aSElliott Hughes readData[attr] = getattr(infoObject, attr) 47*e1fe3e4aSElliott Hughes self.assertEqual(originalData, readData) 48*e1fe3e4aSElliott Hughes 49*e1fe3e4aSElliott Hughes def testGenericRead(self): 50*e1fe3e4aSElliott Hughes # familyName 51*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 52*e1fe3e4aSElliott Hughes info["familyName"] = 123 53*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 54*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 55*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 56*e1fe3e4aSElliott Hughes # styleName 57*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 58*e1fe3e4aSElliott Hughes info["styleName"] = 123 59*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 60*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 61*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 62*e1fe3e4aSElliott Hughes # styleMapFamilyName 63*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 64*e1fe3e4aSElliott Hughes info["styleMapFamilyName"] = 123 65*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 66*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 67*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 68*e1fe3e4aSElliott Hughes # styleMapStyleName 69*e1fe3e4aSElliott Hughes ## not a string 70*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 71*e1fe3e4aSElliott Hughes info["styleMapStyleName"] = 123 72*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 73*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 74*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 75*e1fe3e4aSElliott Hughes ## out of range 76*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 77*e1fe3e4aSElliott Hughes info["styleMapStyleName"] = "REGULAR" 78*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 79*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 80*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 81*e1fe3e4aSElliott Hughes # versionMajor 82*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 83*e1fe3e4aSElliott Hughes info["versionMajor"] = "1" 84*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 85*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 86*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 87*e1fe3e4aSElliott Hughes # versionMinor 88*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 89*e1fe3e4aSElliott Hughes info["versionMinor"] = "0" 90*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 91*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 92*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 93*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 94*e1fe3e4aSElliott Hughes info["versionMinor"] = -1 95*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 96*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 97*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 98*e1fe3e4aSElliott Hughes # copyright 99*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 100*e1fe3e4aSElliott Hughes info["copyright"] = 123 101*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 102*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 103*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 104*e1fe3e4aSElliott Hughes # trademark 105*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 106*e1fe3e4aSElliott Hughes info["trademark"] = 123 107*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 108*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 109*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 110*e1fe3e4aSElliott Hughes # unitsPerEm 111*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 112*e1fe3e4aSElliott Hughes info["unitsPerEm"] = "abc" 113*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 114*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 115*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 116*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 117*e1fe3e4aSElliott Hughes info["unitsPerEm"] = -1 118*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 119*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 120*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 121*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 122*e1fe3e4aSElliott Hughes info["unitsPerEm"] = -1.0 123*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 124*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 125*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 126*e1fe3e4aSElliott Hughes # descender 127*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 128*e1fe3e4aSElliott Hughes info["descender"] = "abc" 129*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 130*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 131*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 132*e1fe3e4aSElliott Hughes # xHeight 133*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 134*e1fe3e4aSElliott Hughes info["xHeight"] = "abc" 135*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 136*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 137*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 138*e1fe3e4aSElliott Hughes # capHeight 139*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 140*e1fe3e4aSElliott Hughes info["capHeight"] = "abc" 141*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 142*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 143*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 144*e1fe3e4aSElliott Hughes # ascender 145*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 146*e1fe3e4aSElliott Hughes info["ascender"] = "abc" 147*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 148*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 149*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 150*e1fe3e4aSElliott Hughes # italicAngle 151*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 152*e1fe3e4aSElliott Hughes info["italicAngle"] = "abc" 153*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 154*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 155*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 156*e1fe3e4aSElliott Hughes 157*e1fe3e4aSElliott Hughes def testGaspRead(self): 158*e1fe3e4aSElliott Hughes # not a list 159*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 160*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = "abc" 161*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 162*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 163*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 164*e1fe3e4aSElliott Hughes # empty list 165*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 166*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [] 167*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 168*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 169*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 170*e1fe3e4aSElliott Hughes # not a dict 171*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 172*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = ["abc"] 173*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 174*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 175*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 176*e1fe3e4aSElliott Hughes # dict not properly formatted 177*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 178*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [dict(rangeMaxPPEM=0xFFFF, notTheRightKey=1)] 179*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 180*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 181*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 182*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 183*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 184*e1fe3e4aSElliott Hughes dict(notTheRightKey=1, rangeGaspBehavior=[0]) 185*e1fe3e4aSElliott Hughes ] 186*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 187*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 188*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 189*e1fe3e4aSElliott Hughes # not an int for ppem 190*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 191*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 192*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM="abc", rangeGaspBehavior=[0]), 193*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 194*e1fe3e4aSElliott Hughes ] 195*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 196*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 197*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 198*e1fe3e4aSElliott Hughes # not a list for behavior 199*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 200*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 201*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior="abc"), 202*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 203*e1fe3e4aSElliott Hughes ] 204*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 205*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 206*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 207*e1fe3e4aSElliott Hughes # invalid behavior value 208*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 209*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 210*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[-1]), 211*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 212*e1fe3e4aSElliott Hughes ] 213*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 214*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 215*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 216*e1fe3e4aSElliott Hughes # not sorted 217*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 218*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 219*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 220*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), 221*e1fe3e4aSElliott Hughes ] 222*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 223*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 224*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 225*e1fe3e4aSElliott Hughes # no 0xFFFF 226*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 227*e1fe3e4aSElliott Hughes info["openTypeGaspRangeRecords"] = [ 228*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), 229*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=20, rangeGaspBehavior=[0]), 230*e1fe3e4aSElliott Hughes ] 231*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 232*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 233*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 234*e1fe3e4aSElliott Hughes 235*e1fe3e4aSElliott Hughes def testHeadRead(self): 236*e1fe3e4aSElliott Hughes # openTypeHeadCreated 237*e1fe3e4aSElliott Hughes ## not a string 238*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 239*e1fe3e4aSElliott Hughes info["openTypeHeadCreated"] = 123 240*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 241*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 242*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 243*e1fe3e4aSElliott Hughes ## invalid format 244*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 245*e1fe3e4aSElliott Hughes info["openTypeHeadCreated"] = "2000-Jan-01 00:00:00" 246*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 247*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 248*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 249*e1fe3e4aSElliott Hughes # openTypeHeadLowestRecPPEM 250*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 251*e1fe3e4aSElliott Hughes info["openTypeHeadLowestRecPPEM"] = "abc" 252*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 253*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 254*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 255*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 256*e1fe3e4aSElliott Hughes info["openTypeHeadLowestRecPPEM"] = -1 257*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 258*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 259*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 260*e1fe3e4aSElliott Hughes # openTypeHeadFlags 261*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 262*e1fe3e4aSElliott Hughes info["openTypeHeadFlags"] = [-1] 263*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 264*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 265*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 266*e1fe3e4aSElliott Hughes 267*e1fe3e4aSElliott Hughes def testHheaRead(self): 268*e1fe3e4aSElliott Hughes # openTypeHheaAscender 269*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 270*e1fe3e4aSElliott Hughes info["openTypeHheaAscender"] = "abc" 271*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 272*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 273*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 274*e1fe3e4aSElliott Hughes # openTypeHheaDescender 275*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 276*e1fe3e4aSElliott Hughes info["openTypeHheaDescender"] = "abc" 277*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 278*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 279*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 280*e1fe3e4aSElliott Hughes # openTypeHheaLineGap 281*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 282*e1fe3e4aSElliott Hughes info["openTypeHheaLineGap"] = "abc" 283*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 284*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 285*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 286*e1fe3e4aSElliott Hughes # openTypeHheaCaretSlopeRise 287*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 288*e1fe3e4aSElliott Hughes info["openTypeHheaCaretSlopeRise"] = "abc" 289*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 290*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 291*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 292*e1fe3e4aSElliott Hughes # openTypeHheaCaretSlopeRun 293*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 294*e1fe3e4aSElliott Hughes info["openTypeHheaCaretSlopeRun"] = "abc" 295*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 296*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 297*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 298*e1fe3e4aSElliott Hughes # openTypeHheaCaretOffset 299*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 300*e1fe3e4aSElliott Hughes info["openTypeHheaCaretOffset"] = "abc" 301*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 302*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 303*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 304*e1fe3e4aSElliott Hughes 305*e1fe3e4aSElliott Hughes def testNameRead(self): 306*e1fe3e4aSElliott Hughes # openTypeNameDesigner 307*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 308*e1fe3e4aSElliott Hughes info["openTypeNameDesigner"] = 123 309*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 310*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 311*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 312*e1fe3e4aSElliott Hughes # openTypeNameDesignerURL 313*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 314*e1fe3e4aSElliott Hughes info["openTypeNameDesignerURL"] = 123 315*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 316*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 317*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 318*e1fe3e4aSElliott Hughes # openTypeNameManufacturer 319*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 320*e1fe3e4aSElliott Hughes info["openTypeNameManufacturer"] = 123 321*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 322*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 323*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 324*e1fe3e4aSElliott Hughes # openTypeNameManufacturerURL 325*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 326*e1fe3e4aSElliott Hughes info["openTypeNameManufacturerURL"] = 123 327*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 328*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 329*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 330*e1fe3e4aSElliott Hughes # openTypeNameLicense 331*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 332*e1fe3e4aSElliott Hughes info["openTypeNameLicense"] = 123 333*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 334*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 335*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 336*e1fe3e4aSElliott Hughes # openTypeNameLicenseURL 337*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 338*e1fe3e4aSElliott Hughes info["openTypeNameLicenseURL"] = 123 339*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 340*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 341*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 342*e1fe3e4aSElliott Hughes # openTypeNameVersion 343*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 344*e1fe3e4aSElliott Hughes info["openTypeNameVersion"] = 123 345*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 346*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 347*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 348*e1fe3e4aSElliott Hughes # openTypeNameUniqueID 349*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 350*e1fe3e4aSElliott Hughes info["openTypeNameUniqueID"] = 123 351*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 352*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 353*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 354*e1fe3e4aSElliott Hughes # openTypeNameDescription 355*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 356*e1fe3e4aSElliott Hughes info["openTypeNameDescription"] = 123 357*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 358*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 359*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 360*e1fe3e4aSElliott Hughes # openTypeNamePreferredFamilyName 361*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 362*e1fe3e4aSElliott Hughes info["openTypeNamePreferredFamilyName"] = 123 363*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 364*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 365*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 366*e1fe3e4aSElliott Hughes # openTypeNamePreferredSubfamilyName 367*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 368*e1fe3e4aSElliott Hughes info["openTypeNamePreferredSubfamilyName"] = 123 369*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 370*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 371*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 372*e1fe3e4aSElliott Hughes # openTypeNameCompatibleFullName 373*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 374*e1fe3e4aSElliott Hughes info["openTypeNameCompatibleFullName"] = 123 375*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 376*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 377*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 378*e1fe3e4aSElliott Hughes # openTypeNameSampleText 379*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 380*e1fe3e4aSElliott Hughes info["openTypeNameSampleText"] = 123 381*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 382*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 383*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 384*e1fe3e4aSElliott Hughes # openTypeNameWWSFamilyName 385*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 386*e1fe3e4aSElliott Hughes info["openTypeNameWWSFamilyName"] = 123 387*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 388*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 389*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 390*e1fe3e4aSElliott Hughes # openTypeNameWWSSubfamilyName 391*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 392*e1fe3e4aSElliott Hughes info["openTypeNameWWSSubfamilyName"] = 123 393*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 394*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 395*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 396*e1fe3e4aSElliott Hughes # openTypeNameRecords 397*e1fe3e4aSElliott Hughes ## not a list 398*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 399*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = "abc" 400*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 401*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 402*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 403*e1fe3e4aSElliott Hughes ## not a dict 404*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 405*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = ["abc"] 406*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 407*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 408*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 409*e1fe3e4aSElliott Hughes ## invalid dict structure 410*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 411*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [dict(foo="bar")] 412*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 413*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 414*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 415*e1fe3e4aSElliott Hughes ## incorrect keys 416*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 417*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 418*e1fe3e4aSElliott Hughes dict( 419*e1fe3e4aSElliott Hughes nameID=1, 420*e1fe3e4aSElliott Hughes platformID=1, 421*e1fe3e4aSElliott Hughes encodingID=1, 422*e1fe3e4aSElliott Hughes languageID=1, 423*e1fe3e4aSElliott Hughes string="Name Record.", 424*e1fe3e4aSElliott Hughes foo="bar", 425*e1fe3e4aSElliott Hughes ) 426*e1fe3e4aSElliott Hughes ] 427*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 428*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 429*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 430*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 431*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 432*e1fe3e4aSElliott Hughes dict(platformID=1, encodingID=1, languageID=1, string="Name Record.") 433*e1fe3e4aSElliott Hughes ] 434*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 435*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 436*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 437*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 438*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 439*e1fe3e4aSElliott Hughes dict(nameID=1, encodingID=1, languageID=1, string="Name Record.") 440*e1fe3e4aSElliott Hughes ] 441*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 442*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 443*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 444*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 445*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 446*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, languageID=1, string="Name Record.") 447*e1fe3e4aSElliott Hughes ] 448*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 449*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 450*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 451*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 452*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 453*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, string="Name Record.") 454*e1fe3e4aSElliott Hughes ] 455*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 456*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 457*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 458*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 459*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 460*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, languageID=1) 461*e1fe3e4aSElliott Hughes ] 462*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 463*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 464*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 465*e1fe3e4aSElliott Hughes ## invalid values 466*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 467*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 468*e1fe3e4aSElliott Hughes dict( 469*e1fe3e4aSElliott Hughes nameID="1", 470*e1fe3e4aSElliott Hughes platformID=1, 471*e1fe3e4aSElliott Hughes encodingID=1, 472*e1fe3e4aSElliott Hughes languageID=1, 473*e1fe3e4aSElliott Hughes string="Name Record.", 474*e1fe3e4aSElliott Hughes ) 475*e1fe3e4aSElliott Hughes ] 476*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 477*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 478*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 479*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 480*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 481*e1fe3e4aSElliott Hughes dict( 482*e1fe3e4aSElliott Hughes nameID=1, 483*e1fe3e4aSElliott Hughes platformID="1", 484*e1fe3e4aSElliott Hughes encodingID=1, 485*e1fe3e4aSElliott Hughes languageID=1, 486*e1fe3e4aSElliott Hughes string="Name Record.", 487*e1fe3e4aSElliott Hughes ) 488*e1fe3e4aSElliott Hughes ] 489*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 490*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 491*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 492*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 493*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 494*e1fe3e4aSElliott Hughes dict( 495*e1fe3e4aSElliott Hughes nameID=1, 496*e1fe3e4aSElliott Hughes platformID=1, 497*e1fe3e4aSElliott Hughes encodingID="1", 498*e1fe3e4aSElliott Hughes languageID=1, 499*e1fe3e4aSElliott Hughes string="Name Record.", 500*e1fe3e4aSElliott Hughes ) 501*e1fe3e4aSElliott Hughes ] 502*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 503*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 504*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 505*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 506*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 507*e1fe3e4aSElliott Hughes dict( 508*e1fe3e4aSElliott Hughes nameID=1, 509*e1fe3e4aSElliott Hughes platformID=1, 510*e1fe3e4aSElliott Hughes encodingID=1, 511*e1fe3e4aSElliott Hughes languageID="1", 512*e1fe3e4aSElliott Hughes string="Name Record.", 513*e1fe3e4aSElliott Hughes ) 514*e1fe3e4aSElliott Hughes ] 515*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 516*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 517*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 518*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 519*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 520*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, languageID=1, string=1) 521*e1fe3e4aSElliott Hughes ] 522*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 523*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 524*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 525*e1fe3e4aSElliott Hughes ## duplicate 526*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 527*e1fe3e4aSElliott Hughes info["openTypeNameRecords"] = [ 528*e1fe3e4aSElliott Hughes dict( 529*e1fe3e4aSElliott Hughes nameID=1, 530*e1fe3e4aSElliott Hughes platformID=1, 531*e1fe3e4aSElliott Hughes encodingID=1, 532*e1fe3e4aSElliott Hughes languageID=1, 533*e1fe3e4aSElliott Hughes string="Name Record.", 534*e1fe3e4aSElliott Hughes ), 535*e1fe3e4aSElliott Hughes dict( 536*e1fe3e4aSElliott Hughes nameID=1, 537*e1fe3e4aSElliott Hughes platformID=1, 538*e1fe3e4aSElliott Hughes encodingID=1, 539*e1fe3e4aSElliott Hughes languageID=1, 540*e1fe3e4aSElliott Hughes string="Name Record.", 541*e1fe3e4aSElliott Hughes ), 542*e1fe3e4aSElliott Hughes ] 543*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 544*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 545*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 546*e1fe3e4aSElliott Hughes 547*e1fe3e4aSElliott Hughes def testOS2Read(self): 548*e1fe3e4aSElliott Hughes # openTypeOS2WidthClass 549*e1fe3e4aSElliott Hughes ## not an int 550*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 551*e1fe3e4aSElliott Hughes info["openTypeOS2WidthClass"] = "abc" 552*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 553*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 554*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 555*e1fe3e4aSElliott Hughes ## out or range 556*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 557*e1fe3e4aSElliott Hughes info["openTypeOS2WidthClass"] = 15 558*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 559*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 560*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 561*e1fe3e4aSElliott Hughes # openTypeOS2WeightClass 562*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 563*e1fe3e4aSElliott Hughes ## not an int 564*e1fe3e4aSElliott Hughes info["openTypeOS2WeightClass"] = "abc" 565*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 566*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 567*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 568*e1fe3e4aSElliott Hughes ## out of range 569*e1fe3e4aSElliott Hughes info["openTypeOS2WeightClass"] = -50 570*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 571*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 572*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 573*e1fe3e4aSElliott Hughes # openTypeOS2Selection 574*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 575*e1fe3e4aSElliott Hughes info["openTypeOS2Selection"] = [-1] 576*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 577*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 578*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 579*e1fe3e4aSElliott Hughes # openTypeOS2VendorID 580*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 581*e1fe3e4aSElliott Hughes info["openTypeOS2VendorID"] = 1234 582*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 583*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 584*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 585*e1fe3e4aSElliott Hughes # openTypeOS2Panose 586*e1fe3e4aSElliott Hughes ## not an int 587*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 588*e1fe3e4aSElliott Hughes info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, str(9)] 589*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 590*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 591*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 592*e1fe3e4aSElliott Hughes ## negative 593*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 594*e1fe3e4aSElliott Hughes info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, -9] 595*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 596*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 597*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 598*e1fe3e4aSElliott Hughes ## too few values 599*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 600*e1fe3e4aSElliott Hughes info["openTypeOS2Panose"] = [0, 1, 2, 3] 601*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 602*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 603*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 604*e1fe3e4aSElliott Hughes ## too many values 605*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 606*e1fe3e4aSElliott Hughes info["openTypeOS2Panose"] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 607*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 608*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 609*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 610*e1fe3e4aSElliott Hughes # openTypeOS2FamilyClass 611*e1fe3e4aSElliott Hughes ## not an int 612*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 613*e1fe3e4aSElliott Hughes info["openTypeOS2FamilyClass"] = [1, str(1)] 614*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 615*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 616*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 617*e1fe3e4aSElliott Hughes ## too few values 618*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 619*e1fe3e4aSElliott Hughes info["openTypeOS2FamilyClass"] = [1] 620*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 621*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 622*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 623*e1fe3e4aSElliott Hughes ## too many values 624*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 625*e1fe3e4aSElliott Hughes info["openTypeOS2FamilyClass"] = [1, 1, 1] 626*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 627*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 628*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 629*e1fe3e4aSElliott Hughes ## out of range 630*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 631*e1fe3e4aSElliott Hughes info["openTypeOS2FamilyClass"] = [1, 201] 632*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 633*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 634*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 635*e1fe3e4aSElliott Hughes # openTypeOS2UnicodeRanges 636*e1fe3e4aSElliott Hughes ## not an int 637*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 638*e1fe3e4aSElliott Hughes info["openTypeOS2UnicodeRanges"] = ["0"] 639*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 640*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 641*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 642*e1fe3e4aSElliott Hughes ## out of range 643*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 644*e1fe3e4aSElliott Hughes info["openTypeOS2UnicodeRanges"] = [-1] 645*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 646*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 647*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 648*e1fe3e4aSElliott Hughes # openTypeOS2CodePageRanges 649*e1fe3e4aSElliott Hughes ## not an int 650*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 651*e1fe3e4aSElliott Hughes info["openTypeOS2CodePageRanges"] = ["0"] 652*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 653*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 654*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 655*e1fe3e4aSElliott Hughes ## out of range 656*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 657*e1fe3e4aSElliott Hughes info["openTypeOS2CodePageRanges"] = [-1] 658*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 659*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 660*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 661*e1fe3e4aSElliott Hughes # openTypeOS2TypoAscender 662*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 663*e1fe3e4aSElliott Hughes info["openTypeOS2TypoAscender"] = "abc" 664*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 665*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 666*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 667*e1fe3e4aSElliott Hughes # openTypeOS2TypoDescender 668*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 669*e1fe3e4aSElliott Hughes info["openTypeOS2TypoDescender"] = "abc" 670*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 671*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 672*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 673*e1fe3e4aSElliott Hughes # openTypeOS2TypoLineGap 674*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 675*e1fe3e4aSElliott Hughes info["openTypeOS2TypoLineGap"] = "abc" 676*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 677*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 678*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 679*e1fe3e4aSElliott Hughes # openTypeOS2WinAscent 680*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 681*e1fe3e4aSElliott Hughes info["openTypeOS2WinAscent"] = "abc" 682*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 683*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 684*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 685*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 686*e1fe3e4aSElliott Hughes info["openTypeOS2WinAscent"] = -1 687*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 688*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 689*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 690*e1fe3e4aSElliott Hughes # openTypeOS2WinDescent 691*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 692*e1fe3e4aSElliott Hughes info["openTypeOS2WinDescent"] = "abc" 693*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 694*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 695*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 696*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 697*e1fe3e4aSElliott Hughes info["openTypeOS2WinDescent"] = -1 698*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 699*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 700*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 701*e1fe3e4aSElliott Hughes # openTypeOS2Type 702*e1fe3e4aSElliott Hughes ## not an int 703*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 704*e1fe3e4aSElliott Hughes info["openTypeOS2Type"] = ["1"] 705*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 706*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 707*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 708*e1fe3e4aSElliott Hughes ## out of range 709*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 710*e1fe3e4aSElliott Hughes info["openTypeOS2Type"] = [-1] 711*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 712*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 713*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 714*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptXSize 715*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 716*e1fe3e4aSElliott Hughes info["openTypeOS2SubscriptXSize"] = "abc" 717*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 718*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 719*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 720*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptYSize 721*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 722*e1fe3e4aSElliott Hughes info["openTypeOS2SubscriptYSize"] = "abc" 723*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 724*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 725*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 726*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptXOffset 727*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 728*e1fe3e4aSElliott Hughes info["openTypeOS2SubscriptXOffset"] = "abc" 729*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 730*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 731*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 732*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptYOffset 733*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 734*e1fe3e4aSElliott Hughes info["openTypeOS2SubscriptYOffset"] = "abc" 735*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 736*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 737*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 738*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptXSize 739*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 740*e1fe3e4aSElliott Hughes info["openTypeOS2SuperscriptXSize"] = "abc" 741*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 742*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 743*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 744*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptYSize 745*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 746*e1fe3e4aSElliott Hughes info["openTypeOS2SuperscriptYSize"] = "abc" 747*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 748*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 749*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 750*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptXOffset 751*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 752*e1fe3e4aSElliott Hughes info["openTypeOS2SuperscriptXOffset"] = "abc" 753*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 754*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 755*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 756*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptYOffset 757*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 758*e1fe3e4aSElliott Hughes info["openTypeOS2SuperscriptYOffset"] = "abc" 759*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 760*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 761*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 762*e1fe3e4aSElliott Hughes # openTypeOS2StrikeoutSize 763*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 764*e1fe3e4aSElliott Hughes info["openTypeOS2StrikeoutSize"] = "abc" 765*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 766*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 767*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 768*e1fe3e4aSElliott Hughes # openTypeOS2StrikeoutPosition 769*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 770*e1fe3e4aSElliott Hughes info["openTypeOS2StrikeoutPosition"] = "abc" 771*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 772*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 773*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 774*e1fe3e4aSElliott Hughes 775*e1fe3e4aSElliott Hughes def testVheaRead(self): 776*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoAscender 777*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 778*e1fe3e4aSElliott Hughes info["openTypeVheaVertTypoAscender"] = "abc" 779*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 780*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 781*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 782*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoDescender 783*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 784*e1fe3e4aSElliott Hughes info["openTypeVheaVertTypoDescender"] = "abc" 785*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 786*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 787*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 788*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoLineGap 789*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 790*e1fe3e4aSElliott Hughes info["openTypeVheaVertTypoLineGap"] = "abc" 791*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 792*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 793*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 794*e1fe3e4aSElliott Hughes # openTypeVheaCaretSlopeRise 795*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 796*e1fe3e4aSElliott Hughes info["openTypeVheaCaretSlopeRise"] = "abc" 797*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 798*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 799*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 800*e1fe3e4aSElliott Hughes # openTypeVheaCaretSlopeRun 801*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 802*e1fe3e4aSElliott Hughes info["openTypeVheaCaretSlopeRun"] = "abc" 803*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 804*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 805*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 806*e1fe3e4aSElliott Hughes # openTypeVheaCaretOffset 807*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 808*e1fe3e4aSElliott Hughes info["openTypeVheaCaretOffset"] = "abc" 809*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 810*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 811*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 812*e1fe3e4aSElliott Hughes 813*e1fe3e4aSElliott Hughes def testFONDRead(self): 814*e1fe3e4aSElliott Hughes # macintoshFONDFamilyID 815*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 816*e1fe3e4aSElliott Hughes info["macintoshFONDFamilyID"] = "abc" 817*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 818*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 819*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 820*e1fe3e4aSElliott Hughes # macintoshFONDName 821*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 822*e1fe3e4aSElliott Hughes info["macintoshFONDName"] = 123 823*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 824*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 825*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 826*e1fe3e4aSElliott Hughes 827*e1fe3e4aSElliott Hughes def testPostscriptRead(self): 828*e1fe3e4aSElliott Hughes # postscriptFontName 829*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 830*e1fe3e4aSElliott Hughes info["postscriptFontName"] = 123 831*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 832*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 833*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 834*e1fe3e4aSElliott Hughes # postscriptFullName 835*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 836*e1fe3e4aSElliott Hughes info["postscriptFullName"] = 123 837*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 838*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 839*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 840*e1fe3e4aSElliott Hughes # postscriptSlantAngle 841*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 842*e1fe3e4aSElliott Hughes info["postscriptSlantAngle"] = "abc" 843*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 844*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 845*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, info=TestInfoObject()) 846*e1fe3e4aSElliott Hughes # postscriptUniqueID 847*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 848*e1fe3e4aSElliott Hughes info["postscriptUniqueID"] = "abc" 849*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 850*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 851*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 852*e1fe3e4aSElliott Hughes # postscriptUnderlineThickness 853*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 854*e1fe3e4aSElliott Hughes info["postscriptUnderlineThickness"] = "abc" 855*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 856*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 857*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 858*e1fe3e4aSElliott Hughes # postscriptUnderlinePosition 859*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 860*e1fe3e4aSElliott Hughes info["postscriptUnderlinePosition"] = "abc" 861*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 862*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 863*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 864*e1fe3e4aSElliott Hughes # postscriptIsFixedPitch 865*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 866*e1fe3e4aSElliott Hughes info["postscriptIsFixedPitch"] = 2 867*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 868*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 869*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 870*e1fe3e4aSElliott Hughes # postscriptBlueValues 871*e1fe3e4aSElliott Hughes ## not a list 872*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 873*e1fe3e4aSElliott Hughes info["postscriptBlueValues"] = "abc" 874*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 875*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 876*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 877*e1fe3e4aSElliott Hughes ## uneven value count 878*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 879*e1fe3e4aSElliott Hughes info["postscriptBlueValues"] = [500] 880*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 881*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 882*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 883*e1fe3e4aSElliott Hughes ## too many values 884*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 885*e1fe3e4aSElliott Hughes info["postscriptBlueValues"] = [ 886*e1fe3e4aSElliott Hughes 10, 887*e1fe3e4aSElliott Hughes 20, 888*e1fe3e4aSElliott Hughes 30, 889*e1fe3e4aSElliott Hughes 40, 890*e1fe3e4aSElliott Hughes 50, 891*e1fe3e4aSElliott Hughes 60, 892*e1fe3e4aSElliott Hughes 70, 893*e1fe3e4aSElliott Hughes 80, 894*e1fe3e4aSElliott Hughes 90, 895*e1fe3e4aSElliott Hughes 100, 896*e1fe3e4aSElliott Hughes 110, 897*e1fe3e4aSElliott Hughes 120, 898*e1fe3e4aSElliott Hughes 130, 899*e1fe3e4aSElliott Hughes 140, 900*e1fe3e4aSElliott Hughes 150, 901*e1fe3e4aSElliott Hughes 160, 902*e1fe3e4aSElliott Hughes ] 903*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 904*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 905*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 906*e1fe3e4aSElliott Hughes # postscriptOtherBlues 907*e1fe3e4aSElliott Hughes ## not a list 908*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 909*e1fe3e4aSElliott Hughes info["postscriptOtherBlues"] = "abc" 910*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 911*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 912*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 913*e1fe3e4aSElliott Hughes ## uneven value count 914*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 915*e1fe3e4aSElliott Hughes info["postscriptOtherBlues"] = [500] 916*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 917*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 918*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 919*e1fe3e4aSElliott Hughes ## too many values 920*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 921*e1fe3e4aSElliott Hughes info["postscriptOtherBlues"] = [ 922*e1fe3e4aSElliott Hughes 10, 923*e1fe3e4aSElliott Hughes 20, 924*e1fe3e4aSElliott Hughes 30, 925*e1fe3e4aSElliott Hughes 40, 926*e1fe3e4aSElliott Hughes 50, 927*e1fe3e4aSElliott Hughes 60, 928*e1fe3e4aSElliott Hughes 70, 929*e1fe3e4aSElliott Hughes 80, 930*e1fe3e4aSElliott Hughes 90, 931*e1fe3e4aSElliott Hughes 100, 932*e1fe3e4aSElliott Hughes 110, 933*e1fe3e4aSElliott Hughes 120, 934*e1fe3e4aSElliott Hughes 130, 935*e1fe3e4aSElliott Hughes 140, 936*e1fe3e4aSElliott Hughes 150, 937*e1fe3e4aSElliott Hughes 160, 938*e1fe3e4aSElliott Hughes ] 939*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 940*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 941*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 942*e1fe3e4aSElliott Hughes # postscriptFamilyBlues 943*e1fe3e4aSElliott Hughes ## not a list 944*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 945*e1fe3e4aSElliott Hughes info["postscriptFamilyBlues"] = "abc" 946*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 947*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 948*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 949*e1fe3e4aSElliott Hughes ## uneven value count 950*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 951*e1fe3e4aSElliott Hughes info["postscriptFamilyBlues"] = [500] 952*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 953*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 954*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 955*e1fe3e4aSElliott Hughes ## too many values 956*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 957*e1fe3e4aSElliott Hughes info["postscriptFamilyBlues"] = [ 958*e1fe3e4aSElliott Hughes 10, 959*e1fe3e4aSElliott Hughes 20, 960*e1fe3e4aSElliott Hughes 30, 961*e1fe3e4aSElliott Hughes 40, 962*e1fe3e4aSElliott Hughes 50, 963*e1fe3e4aSElliott Hughes 60, 964*e1fe3e4aSElliott Hughes 70, 965*e1fe3e4aSElliott Hughes 80, 966*e1fe3e4aSElliott Hughes 90, 967*e1fe3e4aSElliott Hughes 100, 968*e1fe3e4aSElliott Hughes 110, 969*e1fe3e4aSElliott Hughes 120, 970*e1fe3e4aSElliott Hughes 130, 971*e1fe3e4aSElliott Hughes 140, 972*e1fe3e4aSElliott Hughes 150, 973*e1fe3e4aSElliott Hughes 160, 974*e1fe3e4aSElliott Hughes ] 975*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 976*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 977*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 978*e1fe3e4aSElliott Hughes # postscriptFamilyOtherBlues 979*e1fe3e4aSElliott Hughes ## not a list 980*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 981*e1fe3e4aSElliott Hughes info["postscriptFamilyOtherBlues"] = "abc" 982*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 983*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 984*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 985*e1fe3e4aSElliott Hughes ## uneven value count 986*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 987*e1fe3e4aSElliott Hughes info["postscriptFamilyOtherBlues"] = [500] 988*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 989*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 990*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 991*e1fe3e4aSElliott Hughes ## too many values 992*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 993*e1fe3e4aSElliott Hughes info["postscriptFamilyOtherBlues"] = [ 994*e1fe3e4aSElliott Hughes 10, 995*e1fe3e4aSElliott Hughes 20, 996*e1fe3e4aSElliott Hughes 30, 997*e1fe3e4aSElliott Hughes 40, 998*e1fe3e4aSElliott Hughes 50, 999*e1fe3e4aSElliott Hughes 60, 1000*e1fe3e4aSElliott Hughes 70, 1001*e1fe3e4aSElliott Hughes 80, 1002*e1fe3e4aSElliott Hughes 90, 1003*e1fe3e4aSElliott Hughes 100, 1004*e1fe3e4aSElliott Hughes 110, 1005*e1fe3e4aSElliott Hughes 120, 1006*e1fe3e4aSElliott Hughes 130, 1007*e1fe3e4aSElliott Hughes 140, 1008*e1fe3e4aSElliott Hughes 150, 1009*e1fe3e4aSElliott Hughes 160, 1010*e1fe3e4aSElliott Hughes ] 1011*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1012*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1013*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1014*e1fe3e4aSElliott Hughes # postscriptStemSnapH 1015*e1fe3e4aSElliott Hughes ## not list 1016*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1017*e1fe3e4aSElliott Hughes info["postscriptStemSnapH"] = "abc" 1018*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1019*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1020*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1021*e1fe3e4aSElliott Hughes ## too many values 1022*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1023*e1fe3e4aSElliott Hughes info["postscriptStemSnapH"] = [ 1024*e1fe3e4aSElliott Hughes 10, 1025*e1fe3e4aSElliott Hughes 20, 1026*e1fe3e4aSElliott Hughes 30, 1027*e1fe3e4aSElliott Hughes 40, 1028*e1fe3e4aSElliott Hughes 50, 1029*e1fe3e4aSElliott Hughes 60, 1030*e1fe3e4aSElliott Hughes 70, 1031*e1fe3e4aSElliott Hughes 80, 1032*e1fe3e4aSElliott Hughes 90, 1033*e1fe3e4aSElliott Hughes 100, 1034*e1fe3e4aSElliott Hughes 110, 1035*e1fe3e4aSElliott Hughes 120, 1036*e1fe3e4aSElliott Hughes 130, 1037*e1fe3e4aSElliott Hughes 140, 1038*e1fe3e4aSElliott Hughes 150, 1039*e1fe3e4aSElliott Hughes 160, 1040*e1fe3e4aSElliott Hughes ] 1041*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1042*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1043*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1044*e1fe3e4aSElliott Hughes # postscriptStemSnapV 1045*e1fe3e4aSElliott Hughes ## not list 1046*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1047*e1fe3e4aSElliott Hughes info["postscriptStemSnapV"] = "abc" 1048*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1049*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1050*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1051*e1fe3e4aSElliott Hughes ## too many values 1052*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1053*e1fe3e4aSElliott Hughes info["postscriptStemSnapV"] = [ 1054*e1fe3e4aSElliott Hughes 10, 1055*e1fe3e4aSElliott Hughes 20, 1056*e1fe3e4aSElliott Hughes 30, 1057*e1fe3e4aSElliott Hughes 40, 1058*e1fe3e4aSElliott Hughes 50, 1059*e1fe3e4aSElliott Hughes 60, 1060*e1fe3e4aSElliott Hughes 70, 1061*e1fe3e4aSElliott Hughes 80, 1062*e1fe3e4aSElliott Hughes 90, 1063*e1fe3e4aSElliott Hughes 100, 1064*e1fe3e4aSElliott Hughes 110, 1065*e1fe3e4aSElliott Hughes 120, 1066*e1fe3e4aSElliott Hughes 130, 1067*e1fe3e4aSElliott Hughes 140, 1068*e1fe3e4aSElliott Hughes 150, 1069*e1fe3e4aSElliott Hughes 160, 1070*e1fe3e4aSElliott Hughes ] 1071*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1072*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1073*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1074*e1fe3e4aSElliott Hughes # postscriptBlueFuzz 1075*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1076*e1fe3e4aSElliott Hughes info["postscriptBlueFuzz"] = "abc" 1077*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1078*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1079*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1080*e1fe3e4aSElliott Hughes # postscriptBlueShift 1081*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1082*e1fe3e4aSElliott Hughes info["postscriptBlueShift"] = "abc" 1083*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1084*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1085*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1086*e1fe3e4aSElliott Hughes # postscriptBlueScale 1087*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1088*e1fe3e4aSElliott Hughes info["postscriptBlueScale"] = "abc" 1089*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1090*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1091*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1092*e1fe3e4aSElliott Hughes # postscriptForceBold 1093*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1094*e1fe3e4aSElliott Hughes info["postscriptForceBold"] = "abc" 1095*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1096*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1097*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1098*e1fe3e4aSElliott Hughes # postscriptDefaultWidthX 1099*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1100*e1fe3e4aSElliott Hughes info["postscriptDefaultWidthX"] = "abc" 1101*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1102*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1103*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1104*e1fe3e4aSElliott Hughes # postscriptNominalWidthX 1105*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1106*e1fe3e4aSElliott Hughes info["postscriptNominalWidthX"] = "abc" 1107*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1108*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1109*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1110*e1fe3e4aSElliott Hughes # postscriptWeightName 1111*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1112*e1fe3e4aSElliott Hughes info["postscriptWeightName"] = 123 1113*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1114*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1115*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1116*e1fe3e4aSElliott Hughes # postscriptDefaultCharacter 1117*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1118*e1fe3e4aSElliott Hughes info["postscriptDefaultCharacter"] = 123 1119*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1120*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1121*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1122*e1fe3e4aSElliott Hughes # postscriptWindowsCharacterSet 1123*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1124*e1fe3e4aSElliott Hughes info["postscriptWindowsCharacterSet"] = -1 1125*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1126*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1127*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1128*e1fe3e4aSElliott Hughes # macintoshFONDFamilyID 1129*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1130*e1fe3e4aSElliott Hughes info["macintoshFONDFamilyID"] = "abc" 1131*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1132*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1133*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1134*e1fe3e4aSElliott Hughes # macintoshFONDName 1135*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1136*e1fe3e4aSElliott Hughes info["macintoshFONDName"] = 123 1137*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1138*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1139*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1140*e1fe3e4aSElliott Hughes 1141*e1fe3e4aSElliott Hughes def testWOFFRead(self): 1142*e1fe3e4aSElliott Hughes # woffMajorVersion 1143*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1144*e1fe3e4aSElliott Hughes info["woffMajorVersion"] = 1.0 1145*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1146*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1147*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1148*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1149*e1fe3e4aSElliott Hughes info["woffMajorVersion"] = "abc" 1150*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1151*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1152*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1153*e1fe3e4aSElliott Hughes # woffMinorVersion 1154*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1155*e1fe3e4aSElliott Hughes info["woffMinorVersion"] = 1.0 1156*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1157*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1158*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1159*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1160*e1fe3e4aSElliott Hughes info["woffMinorVersion"] = "abc" 1161*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1162*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1163*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1164*e1fe3e4aSElliott Hughes # woffMetadataUniqueID 1165*e1fe3e4aSElliott Hughes ## none 1166*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1167*e1fe3e4aSElliott Hughes del info["woffMetadataUniqueID"] 1168*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1169*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1170*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1171*e1fe3e4aSElliott Hughes ## not a dict 1172*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1173*e1fe3e4aSElliott Hughes info["woffMetadataUniqueID"] = 1 1174*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1175*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1176*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1177*e1fe3e4aSElliott Hughes ## unknown key 1178*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1179*e1fe3e4aSElliott Hughes info["woffMetadataUniqueID"] = dict(id="foo", notTheRightKey=1) 1180*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1181*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1182*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1183*e1fe3e4aSElliott Hughes ## no id 1184*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1185*e1fe3e4aSElliott Hughes info["woffMetadataUniqueID"] = dict() 1186*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1187*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1188*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1189*e1fe3e4aSElliott Hughes ## not a string for id 1190*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1191*e1fe3e4aSElliott Hughes info["woffMetadataUniqueID"] = dict(id=1) 1192*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1193*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1194*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1195*e1fe3e4aSElliott Hughes ## empty string 1196*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1197*e1fe3e4aSElliott Hughes info["woffMetadataUniqueID"] = dict(id="") 1198*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1199*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1200*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1201*e1fe3e4aSElliott Hughes # woffMetadataVendor 1202*e1fe3e4aSElliott Hughes ## no name 1203*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1204*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(url="foo") 1205*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1206*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1207*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1208*e1fe3e4aSElliott Hughes ## name not a string 1209*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1210*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name=1, url="foo") 1211*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1212*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1213*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1214*e1fe3e4aSElliott Hughes ## name an empty string 1215*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1216*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="", url="foo") 1217*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1218*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1219*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1220*e1fe3e4aSElliott Hughes ## no URL 1221*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1222*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo") 1223*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1224*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1225*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1226*e1fe3e4aSElliott Hughes ## url not a string 1227*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1228*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url=1) 1229*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1230*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1231*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1232*e1fe3e4aSElliott Hughes ## url empty string 1233*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1234*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url="") 1235*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1236*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1237*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1238*e1fe3e4aSElliott Hughes ## have dir 1239*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1240*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="ltr") 1241*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1242*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1243*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1244*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1245*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="rtl") 1246*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1247*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1248*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1249*e1fe3e4aSElliott Hughes ## dir not a string 1250*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1251*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url="bar", dir=1) 1252*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1253*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1254*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1255*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1256*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1257*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = dict(name="foo", url="bar", dir="utd") 1258*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1259*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1260*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1261*e1fe3e4aSElliott Hughes ## have class 1262*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1263*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = {"name": "foo", "url": "bar", "class": "hello"} 1264*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1265*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1266*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1267*e1fe3e4aSElliott Hughes ## class not a string 1268*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1269*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = {"name": "foo", "url": "bar", "class": 1} 1270*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1271*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1272*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1273*e1fe3e4aSElliott Hughes ## class empty string 1274*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1275*e1fe3e4aSElliott Hughes info["woffMetadataVendor"] = {"name": "foo", "url": "bar", "class": ""} 1276*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1277*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1278*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1279*e1fe3e4aSElliott Hughes # woffMetadataCredits 1280*e1fe3e4aSElliott Hughes ## no credits attribute 1281*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1282*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = {} 1283*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1284*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1285*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1286*e1fe3e4aSElliott Hughes ## unknown attribute 1287*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1288*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo")], notTheRightKey=1) 1289*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1290*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1291*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1292*e1fe3e4aSElliott Hughes ## not a list 1293*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1294*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits="abc") 1295*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1296*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1297*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1298*e1fe3e4aSElliott Hughes ## no elements in credits 1299*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1300*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[]) 1301*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1302*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1303*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1304*e1fe3e4aSElliott Hughes ## credit not a dict 1305*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1306*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=["abc"]) 1307*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1308*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1309*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1310*e1fe3e4aSElliott Hughes ## unknown key 1311*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1312*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo", notTheRightKey=1)]) 1313*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1314*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1315*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1316*e1fe3e4aSElliott Hughes ## no name 1317*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1318*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(url="foo")]) 1319*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1320*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1321*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1322*e1fe3e4aSElliott Hughes ## name not a string 1323*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1324*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name=1)]) 1325*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1326*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1327*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1328*e1fe3e4aSElliott Hughes ## url not a string 1329*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1330*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo", url=1)]) 1331*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1332*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1333*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1334*e1fe3e4aSElliott Hughes ## role not a string 1335*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1336*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo", role=1)]) 1337*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1338*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1339*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1340*e1fe3e4aSElliott Hughes ## dir not a string 1341*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1342*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo", dir=1)]) 1343*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1344*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1345*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1346*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1347*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1348*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[dict(name="foo", dir="utd")]) 1349*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1350*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1351*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1352*e1fe3e4aSElliott Hughes ## class not a string 1353*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1354*e1fe3e4aSElliott Hughes info["woffMetadataCredits"] = dict(credits=[{"name": "foo", "class": 1}]) 1355*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1356*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1357*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1358*e1fe3e4aSElliott Hughes # woffMetadataDescription 1359*e1fe3e4aSElliott Hughes ## no url 1360*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1361*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text="foo")]) 1362*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1363*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1364*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1365*e1fe3e4aSElliott Hughes ## url not a string 1366*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1367*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text="foo")], url=1) 1368*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1369*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1370*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1371*e1fe3e4aSElliott Hughes ## no text 1372*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1373*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(url="foo") 1374*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1375*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1376*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1377*e1fe3e4aSElliott Hughes ## text not a list 1378*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1379*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text="abc") 1380*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1381*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1382*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1383*e1fe3e4aSElliott Hughes ## text item not a dict 1384*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1385*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=["abc"]) 1386*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1387*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1388*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1389*e1fe3e4aSElliott Hughes ## text item unknown key 1390*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1391*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict( 1392*e1fe3e4aSElliott Hughes text=[dict(text="foo", notTheRightKey=1)] 1393*e1fe3e4aSElliott Hughes ) 1394*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1395*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1396*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1397*e1fe3e4aSElliott Hughes ## text item missing text 1398*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1399*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(language="foo")]) 1400*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1401*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1402*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1403*e1fe3e4aSElliott Hughes ## text not a string 1404*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1405*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text=1)]) 1406*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1407*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1408*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1409*e1fe3e4aSElliott Hughes ## url not a string 1410*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1411*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text="foo", url=1)]) 1412*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1413*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1414*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1415*e1fe3e4aSElliott Hughes ## language not a string 1416*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1417*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text="foo", language=1)]) 1418*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1419*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1420*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1421*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1422*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1423*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[dict(text="foo", dir="utd")]) 1424*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1425*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1426*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1427*e1fe3e4aSElliott Hughes ## class not a string 1428*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1429*e1fe3e4aSElliott Hughes info["woffMetadataDescription"] = dict(text=[{"text": "foo", "class": 1}]) 1430*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1431*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1432*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1433*e1fe3e4aSElliott Hughes # woffMetadataLicense 1434*e1fe3e4aSElliott Hughes ## no url 1435*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1436*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo")]) 1437*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1438*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1439*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1440*e1fe3e4aSElliott Hughes ## url not a string 1441*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1442*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo")], url=1) 1443*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1444*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1445*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1446*e1fe3e4aSElliott Hughes ## id not a string 1447*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1448*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo")], id=1) 1449*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1450*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1451*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1452*e1fe3e4aSElliott Hughes ## no text 1453*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1454*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(url="foo") 1455*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1456*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1457*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1458*e1fe3e4aSElliott Hughes ## text not a list 1459*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1460*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text="abc") 1461*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1462*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1463*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1464*e1fe3e4aSElliott Hughes ## text item not a dict 1465*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1466*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=["abc"]) 1467*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1468*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1469*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1470*e1fe3e4aSElliott Hughes ## text item unknown key 1471*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1472*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo", notTheRightKey=1)]) 1473*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1474*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1475*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1476*e1fe3e4aSElliott Hughes ## text item missing text 1477*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1478*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(language="foo")]) 1479*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1480*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1481*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1482*e1fe3e4aSElliott Hughes ## text not a string 1483*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1484*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text=1)]) 1485*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1486*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1487*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1488*e1fe3e4aSElliott Hughes ## url not a string 1489*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1490*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo", url=1)]) 1491*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1492*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1493*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1494*e1fe3e4aSElliott Hughes ## language not a string 1495*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1496*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo", language=1)]) 1497*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1498*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1499*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1500*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1501*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1502*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[dict(text="foo", dir="utd")]) 1503*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1504*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1505*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1506*e1fe3e4aSElliott Hughes ## class not a string 1507*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1508*e1fe3e4aSElliott Hughes info["woffMetadataLicense"] = dict(text=[{"text": "foo", "class": 1}]) 1509*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1510*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1511*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1512*e1fe3e4aSElliott Hughes # woffMetadataCopyright 1513*e1fe3e4aSElliott Hughes ## unknown attribute 1514*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1515*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text="foo")], notTheRightKey=1) 1516*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1517*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1518*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1519*e1fe3e4aSElliott Hughes ## no text 1520*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1521*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict() 1522*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1523*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1524*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1525*e1fe3e4aSElliott Hughes ## text not a list 1526*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1527*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text="abc") 1528*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1529*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1530*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1531*e1fe3e4aSElliott Hughes ## text item not a dict 1532*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1533*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=["abc"]) 1534*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1535*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1536*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1537*e1fe3e4aSElliott Hughes ## text item unknown key 1538*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1539*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text="foo", notTheRightKey=1)]) 1540*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1541*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1542*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1543*e1fe3e4aSElliott Hughes ## text item missing text 1544*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1545*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(language="foo")]) 1546*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1547*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1548*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1549*e1fe3e4aSElliott Hughes ## text not a string 1550*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1551*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text=1)]) 1552*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1553*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1554*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1555*e1fe3e4aSElliott Hughes ## url not a string 1556*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1557*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text="foo", url=1)]) 1558*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1559*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1560*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1561*e1fe3e4aSElliott Hughes ## language not a string 1562*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1563*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text="foo", language=1)]) 1564*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1565*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1566*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1567*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1568*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1569*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[dict(text="foo", dir="utd")]) 1570*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1571*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1572*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1573*e1fe3e4aSElliott Hughes ## class not a string 1574*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1575*e1fe3e4aSElliott Hughes info["woffMetadataCopyright"] = dict(text=[{"text": "foo", "class": 1}]) 1576*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1577*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1578*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1579*e1fe3e4aSElliott Hughes # woffMetadataTrademark 1580*e1fe3e4aSElliott Hughes ## unknown attribute 1581*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1582*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text="foo")], notTheRightKey=1) 1583*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1584*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1585*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1586*e1fe3e4aSElliott Hughes ## no text 1587*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1588*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict() 1589*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1590*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1591*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1592*e1fe3e4aSElliott Hughes ## text not a list 1593*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1594*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text="abc") 1595*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1596*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1597*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1598*e1fe3e4aSElliott Hughes ## text item not a dict 1599*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1600*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=["abc"]) 1601*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1602*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1603*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1604*e1fe3e4aSElliott Hughes ## text item unknown key 1605*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1606*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text="foo", notTheRightKey=1)]) 1607*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1608*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1609*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1610*e1fe3e4aSElliott Hughes ## text item missing text 1611*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1612*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(language="foo")]) 1613*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1614*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1615*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1616*e1fe3e4aSElliott Hughes ## text not a string 1617*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1618*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text=1)]) 1619*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1620*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1621*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1622*e1fe3e4aSElliott Hughes ## url not a string 1623*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1624*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text="foo", url=1)]) 1625*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1626*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1627*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1628*e1fe3e4aSElliott Hughes ## language not a string 1629*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1630*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text="foo", language=1)]) 1631*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1632*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1633*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1634*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1635*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1636*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[dict(text="foo", dir="utd")]) 1637*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1638*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1639*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1640*e1fe3e4aSElliott Hughes ## class not a string 1641*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1642*e1fe3e4aSElliott Hughes info["woffMetadataTrademark"] = dict(text=[{"text": "foo", "class": 1}]) 1643*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1644*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1645*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1646*e1fe3e4aSElliott Hughes # woffMetadataLicensee 1647*e1fe3e4aSElliott Hughes ## no name 1648*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1649*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict() 1650*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1651*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1652*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1653*e1fe3e4aSElliott Hughes ## unknown attribute 1654*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1655*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict(name="foo", notTheRightKey=1) 1656*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1657*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1658*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1659*e1fe3e4aSElliott Hughes ## name not a string 1660*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1661*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict(name=1) 1662*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1663*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1664*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1665*e1fe3e4aSElliott Hughes ## dir options 1666*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1667*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict(name="foo", dir="ltr") 1668*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1669*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1670*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1671*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1672*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict(name="foo", dir="rtl") 1673*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1674*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1675*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1676*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 1677*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1678*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = dict(name="foo", dir="utd") 1679*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1680*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1681*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1682*e1fe3e4aSElliott Hughes ## have class 1683*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1684*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = {"name": "foo", "class": "hello"} 1685*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1686*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1687*e1fe3e4aSElliott Hughes reader.readInfo(TestInfoObject()) 1688*e1fe3e4aSElliott Hughes ## class not a string 1689*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1690*e1fe3e4aSElliott Hughes info["woffMetadataLicensee"] = {"name": "foo", "class": 1} 1691*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1692*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1693*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1694*e1fe3e4aSElliott Hughes 1695*e1fe3e4aSElliott Hughes def testGuidelinesRead(self): 1696*e1fe3e4aSElliott Hughes # x 1697*e1fe3e4aSElliott Hughes ## not an int or float 1698*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1699*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x="1")] 1700*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1701*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1702*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1703*e1fe3e4aSElliott Hughes # y 1704*e1fe3e4aSElliott Hughes ## not an int or float 1705*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1706*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(y="1")] 1707*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1708*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1709*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1710*e1fe3e4aSElliott Hughes # angle 1711*e1fe3e4aSElliott Hughes ## < 0 1712*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1713*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, y=0, angle=-1)] 1714*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1715*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1716*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1717*e1fe3e4aSElliott Hughes ## > 360 1718*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1719*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, y=0, angle=361)] 1720*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1721*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1722*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1723*e1fe3e4aSElliott Hughes # name 1724*e1fe3e4aSElliott Hughes ## not a string 1725*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1726*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, name=1)] 1727*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1728*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1729*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1730*e1fe3e4aSElliott Hughes # color 1731*e1fe3e4aSElliott Hughes ## not a string 1732*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1733*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color=1)] 1734*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1735*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1736*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1737*e1fe3e4aSElliott Hughes ## not enough commas 1738*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1739*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1 0, 0, 0")] 1740*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1741*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1742*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1743*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1744*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1 0 0, 0")] 1745*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1746*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1747*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1748*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1749*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1 0 0 0")] 1750*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1751*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1752*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1753*e1fe3e4aSElliott Hughes ## not enough parts 1754*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1755*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color=", 0, 0, 0")] 1756*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1757*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1758*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1759*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1760*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, , 0, 0")] 1761*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1762*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1763*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1764*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1765*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, 0, , 0")] 1766*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1767*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1768*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1769*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1770*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, 0, 0, ")] 1771*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1772*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1773*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1774*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1775*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color=", , , ")] 1776*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1777*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1778*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1779*e1fe3e4aSElliott Hughes ## not a number in all positions 1780*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1781*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="r, 1, 1, 1")] 1782*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1783*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1784*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1785*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1786*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, g, 1, 1")] 1787*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1788*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1789*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1790*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1791*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, 1, b, 1")] 1792*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1793*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1794*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1795*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1796*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, 1, 1, a")] 1797*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1798*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1799*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1800*e1fe3e4aSElliott Hughes ## too many parts 1801*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1802*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="1, 0, 0, 0, 0")] 1803*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1804*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1805*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1806*e1fe3e4aSElliott Hughes ## < 0 in each position 1807*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1808*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="-1, 0, 0, 0")] 1809*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1810*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1811*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1812*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1813*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, -1, 0, 0")] 1814*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1815*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1816*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1817*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1818*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, 0, -1, 0")] 1819*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1820*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1821*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1822*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1823*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, 0, 0, -1")] 1824*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1825*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1826*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1827*e1fe3e4aSElliott Hughes ## > 1 in each position 1828*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1829*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="2, 0, 0, 0")] 1830*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1831*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1832*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1833*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1834*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, 2, 0, 0")] 1835*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1836*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1837*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1838*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1839*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, 0, 2, 0")] 1840*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1841*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1842*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1843*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1844*e1fe3e4aSElliott Hughes info["guidelines"] = [dict(x=0, color="0, 0, 0, 2")] 1845*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1846*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1847*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1848*e1fe3e4aSElliott Hughes # identifier 1849*e1fe3e4aSElliott Hughes ## duplicate 1850*e1fe3e4aSElliott Hughes info = dict(fontInfoVersion3) 1851*e1fe3e4aSElliott Hughes info["guidelines"] = [ 1852*e1fe3e4aSElliott Hughes dict(x=0, identifier="guide1"), 1853*e1fe3e4aSElliott Hughes dict(y=0, identifier="guide1"), 1854*e1fe3e4aSElliott Hughes ] 1855*e1fe3e4aSElliott Hughes self._writeInfoToPlist(info) 1856*e1fe3e4aSElliott Hughes reader = UFOReader(self.dstDir, validate=True) 1857*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.readInfo, TestInfoObject()) 1858*e1fe3e4aSElliott Hughes 1859*e1fe3e4aSElliott Hughes 1860*e1fe3e4aSElliott Hughesclass WriteFontInfoVersion3TestCase(unittest.TestCase): 1861*e1fe3e4aSElliott Hughes def setUp(self): 1862*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 1863*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 1864*e1fe3e4aSElliott Hughes self.dstDir = os.path.join(self.tempDir, "test.ufo") 1865*e1fe3e4aSElliott Hughes 1866*e1fe3e4aSElliott Hughes def tearDown(self): 1867*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 1868*e1fe3e4aSElliott Hughes 1869*e1fe3e4aSElliott Hughes def tearDownUFO(self): 1870*e1fe3e4aSElliott Hughes if os.path.exists(self.dstDir): 1871*e1fe3e4aSElliott Hughes shutil.rmtree(self.dstDir) 1872*e1fe3e4aSElliott Hughes 1873*e1fe3e4aSElliott Hughes def makeInfoObject(self): 1874*e1fe3e4aSElliott Hughes infoObject = TestInfoObject() 1875*e1fe3e4aSElliott Hughes for attr, value in list(fontInfoVersion3.items()): 1876*e1fe3e4aSElliott Hughes setattr(infoObject, attr, value) 1877*e1fe3e4aSElliott Hughes return infoObject 1878*e1fe3e4aSElliott Hughes 1879*e1fe3e4aSElliott Hughes def readPlist(self): 1880*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, "fontinfo.plist") 1881*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 1882*e1fe3e4aSElliott Hughes plist = plistlib.load(f) 1883*e1fe3e4aSElliott Hughes return plist 1884*e1fe3e4aSElliott Hughes 1885*e1fe3e4aSElliott Hughes def testWrite(self): 1886*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1887*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1888*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 1889*e1fe3e4aSElliott Hughes writtenData = self.readPlist() 1890*e1fe3e4aSElliott Hughes for attr, originalValue in list(fontInfoVersion3.items()): 1891*e1fe3e4aSElliott Hughes newValue = writtenData[attr] 1892*e1fe3e4aSElliott Hughes self.assertEqual(newValue, originalValue) 1893*e1fe3e4aSElliott Hughes self.tearDownUFO() 1894*e1fe3e4aSElliott Hughes 1895*e1fe3e4aSElliott Hughes def testGenericWrite(self): 1896*e1fe3e4aSElliott Hughes # familyName 1897*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1898*e1fe3e4aSElliott Hughes infoObject.familyName = 123 1899*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1900*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1901*e1fe3e4aSElliott Hughes self.tearDownUFO() 1902*e1fe3e4aSElliott Hughes # styleName 1903*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1904*e1fe3e4aSElliott Hughes infoObject.styleName = 123 1905*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1906*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1907*e1fe3e4aSElliott Hughes self.tearDownUFO() 1908*e1fe3e4aSElliott Hughes # styleMapFamilyName 1909*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1910*e1fe3e4aSElliott Hughes infoObject.styleMapFamilyName = 123 1911*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1912*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1913*e1fe3e4aSElliott Hughes self.tearDownUFO() 1914*e1fe3e4aSElliott Hughes # styleMapStyleName 1915*e1fe3e4aSElliott Hughes ## not a string 1916*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1917*e1fe3e4aSElliott Hughes infoObject.styleMapStyleName = 123 1918*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1919*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1920*e1fe3e4aSElliott Hughes self.tearDownUFO() 1921*e1fe3e4aSElliott Hughes ## out of range 1922*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1923*e1fe3e4aSElliott Hughes infoObject.styleMapStyleName = "REGULAR" 1924*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1925*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1926*e1fe3e4aSElliott Hughes self.tearDownUFO() 1927*e1fe3e4aSElliott Hughes # versionMajor 1928*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1929*e1fe3e4aSElliott Hughes infoObject.versionMajor = "1" 1930*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1931*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1932*e1fe3e4aSElliott Hughes self.tearDownUFO() 1933*e1fe3e4aSElliott Hughes # versionMinor 1934*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1935*e1fe3e4aSElliott Hughes infoObject.versionMinor = "0" 1936*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1937*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1938*e1fe3e4aSElliott Hughes self.tearDownUFO() 1939*e1fe3e4aSElliott Hughes # copyright 1940*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1941*e1fe3e4aSElliott Hughes infoObject.copyright = 123 1942*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1943*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1944*e1fe3e4aSElliott Hughes self.tearDownUFO() 1945*e1fe3e4aSElliott Hughes # trademark 1946*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1947*e1fe3e4aSElliott Hughes infoObject.trademark = 123 1948*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1949*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1950*e1fe3e4aSElliott Hughes self.tearDownUFO() 1951*e1fe3e4aSElliott Hughes # unitsPerEm 1952*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1953*e1fe3e4aSElliott Hughes infoObject.unitsPerEm = "abc" 1954*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1955*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1956*e1fe3e4aSElliott Hughes self.tearDownUFO() 1957*e1fe3e4aSElliott Hughes # descender 1958*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1959*e1fe3e4aSElliott Hughes infoObject.descender = "abc" 1960*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1961*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1962*e1fe3e4aSElliott Hughes self.tearDownUFO() 1963*e1fe3e4aSElliott Hughes # xHeight 1964*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1965*e1fe3e4aSElliott Hughes infoObject.xHeight = "abc" 1966*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1967*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1968*e1fe3e4aSElliott Hughes self.tearDownUFO() 1969*e1fe3e4aSElliott Hughes # capHeight 1970*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1971*e1fe3e4aSElliott Hughes infoObject.capHeight = "abc" 1972*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1973*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1974*e1fe3e4aSElliott Hughes self.tearDownUFO() 1975*e1fe3e4aSElliott Hughes # ascender 1976*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1977*e1fe3e4aSElliott Hughes infoObject.ascender = "abc" 1978*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1979*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1980*e1fe3e4aSElliott Hughes self.tearDownUFO() 1981*e1fe3e4aSElliott Hughes # italicAngle 1982*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1983*e1fe3e4aSElliott Hughes infoObject.italicAngle = "abc" 1984*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1985*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1986*e1fe3e4aSElliott Hughes self.tearDownUFO() 1987*e1fe3e4aSElliott Hughes 1988*e1fe3e4aSElliott Hughes def testGaspWrite(self): 1989*e1fe3e4aSElliott Hughes # not a list 1990*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1991*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = "abc" 1992*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1993*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 1994*e1fe3e4aSElliott Hughes self.tearDownUFO() 1995*e1fe3e4aSElliott Hughes # empty list 1996*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 1997*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [] 1998*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 1999*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 2000*e1fe3e4aSElliott Hughes self.tearDownUFO() 2001*e1fe3e4aSElliott Hughes # not a dict 2002*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2003*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = ["abc"] 2004*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2005*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2006*e1fe3e4aSElliott Hughes self.tearDownUFO() 2007*e1fe3e4aSElliott Hughes # dict not properly formatted 2008*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2009*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2010*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, notTheRightKey=1) 2011*e1fe3e4aSElliott Hughes ] 2012*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2013*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2014*e1fe3e4aSElliott Hughes self.tearDownUFO() 2015*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2016*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2017*e1fe3e4aSElliott Hughes dict(notTheRightKey=1, rangeGaspBehavior=[0]) 2018*e1fe3e4aSElliott Hughes ] 2019*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2020*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2021*e1fe3e4aSElliott Hughes self.tearDownUFO() 2022*e1fe3e4aSElliott Hughes # not an int for ppem 2023*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2024*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2025*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM="abc", rangeGaspBehavior=[0]), 2026*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 2027*e1fe3e4aSElliott Hughes ] 2028*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2029*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2030*e1fe3e4aSElliott Hughes self.tearDownUFO() 2031*e1fe3e4aSElliott Hughes # not a list for behavior 2032*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2033*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2034*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior="abc"), 2035*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 2036*e1fe3e4aSElliott Hughes ] 2037*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2038*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2039*e1fe3e4aSElliott Hughes self.tearDownUFO() 2040*e1fe3e4aSElliott Hughes # invalid behavior value 2041*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2042*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2043*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[-1]), 2044*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 2045*e1fe3e4aSElliott Hughes ] 2046*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2047*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2048*e1fe3e4aSElliott Hughes self.tearDownUFO() 2049*e1fe3e4aSElliott Hughes # not sorted 2050*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2051*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2052*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=0xFFFF, rangeGaspBehavior=[0]), 2053*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), 2054*e1fe3e4aSElliott Hughes ] 2055*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2056*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2057*e1fe3e4aSElliott Hughes self.tearDownUFO() 2058*e1fe3e4aSElliott Hughes # no 0xFFFF 2059*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2060*e1fe3e4aSElliott Hughes infoObject.openTypeGaspRangeRecords = [ 2061*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=10, rangeGaspBehavior=[0]), 2062*e1fe3e4aSElliott Hughes dict(rangeMaxPPEM=20, rangeGaspBehavior=[0]), 2063*e1fe3e4aSElliott Hughes ] 2064*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2065*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 2066*e1fe3e4aSElliott Hughes self.tearDownUFO() 2067*e1fe3e4aSElliott Hughes 2068*e1fe3e4aSElliott Hughes def testHeadWrite(self): 2069*e1fe3e4aSElliott Hughes # openTypeHeadCreated 2070*e1fe3e4aSElliott Hughes ## not a string 2071*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2072*e1fe3e4aSElliott Hughes infoObject.openTypeHeadCreated = 123 2073*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2074*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2075*e1fe3e4aSElliott Hughes self.tearDownUFO() 2076*e1fe3e4aSElliott Hughes ## invalid format 2077*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2078*e1fe3e4aSElliott Hughes infoObject.openTypeHeadCreated = "2000-Jan-01 00:00:00" 2079*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2080*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2081*e1fe3e4aSElliott Hughes self.tearDownUFO() 2082*e1fe3e4aSElliott Hughes # openTypeHeadLowestRecPPEM 2083*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2084*e1fe3e4aSElliott Hughes infoObject.openTypeHeadLowestRecPPEM = "abc" 2085*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2086*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2087*e1fe3e4aSElliott Hughes self.tearDownUFO() 2088*e1fe3e4aSElliott Hughes # openTypeHeadFlags 2089*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2090*e1fe3e4aSElliott Hughes infoObject.openTypeHeadFlags = [-1] 2091*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2092*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2093*e1fe3e4aSElliott Hughes self.tearDownUFO() 2094*e1fe3e4aSElliott Hughes 2095*e1fe3e4aSElliott Hughes def testHheaWrite(self): 2096*e1fe3e4aSElliott Hughes # openTypeHheaAscender 2097*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2098*e1fe3e4aSElliott Hughes infoObject.openTypeHheaAscender = "abc" 2099*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2100*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2101*e1fe3e4aSElliott Hughes self.tearDownUFO() 2102*e1fe3e4aSElliott Hughes # openTypeHheaDescender 2103*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2104*e1fe3e4aSElliott Hughes infoObject.openTypeHheaDescender = "abc" 2105*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2106*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2107*e1fe3e4aSElliott Hughes self.tearDownUFO() 2108*e1fe3e4aSElliott Hughes # openTypeHheaLineGap 2109*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2110*e1fe3e4aSElliott Hughes infoObject.openTypeHheaLineGap = "abc" 2111*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2112*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2113*e1fe3e4aSElliott Hughes self.tearDownUFO() 2114*e1fe3e4aSElliott Hughes # openTypeHheaCaretSlopeRise 2115*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2116*e1fe3e4aSElliott Hughes infoObject.openTypeHheaCaretSlopeRise = "abc" 2117*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2118*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2119*e1fe3e4aSElliott Hughes self.tearDownUFO() 2120*e1fe3e4aSElliott Hughes # openTypeHheaCaretSlopeRun 2121*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2122*e1fe3e4aSElliott Hughes infoObject.openTypeHheaCaretSlopeRun = "abc" 2123*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2124*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2125*e1fe3e4aSElliott Hughes self.tearDownUFO() 2126*e1fe3e4aSElliott Hughes # openTypeHheaCaretOffset 2127*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2128*e1fe3e4aSElliott Hughes infoObject.openTypeHheaCaretOffset = "abc" 2129*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2130*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2131*e1fe3e4aSElliott Hughes self.tearDownUFO() 2132*e1fe3e4aSElliott Hughes 2133*e1fe3e4aSElliott Hughes def testNameWrite(self): 2134*e1fe3e4aSElliott Hughes # openTypeNameDesigner 2135*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2136*e1fe3e4aSElliott Hughes infoObject.openTypeNameDesigner = 123 2137*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2138*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2139*e1fe3e4aSElliott Hughes self.tearDownUFO() 2140*e1fe3e4aSElliott Hughes # openTypeNameDesignerURL 2141*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2142*e1fe3e4aSElliott Hughes infoObject.openTypeNameDesignerURL = 123 2143*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2144*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2145*e1fe3e4aSElliott Hughes self.tearDownUFO() 2146*e1fe3e4aSElliott Hughes # openTypeNameManufacturer 2147*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2148*e1fe3e4aSElliott Hughes infoObject.openTypeNameManufacturer = 123 2149*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2150*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2151*e1fe3e4aSElliott Hughes self.tearDownUFO() 2152*e1fe3e4aSElliott Hughes # openTypeNameManufacturerURL 2153*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2154*e1fe3e4aSElliott Hughes infoObject.openTypeNameManufacturerURL = 123 2155*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2156*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2157*e1fe3e4aSElliott Hughes self.tearDownUFO() 2158*e1fe3e4aSElliott Hughes # openTypeNameLicense 2159*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2160*e1fe3e4aSElliott Hughes infoObject.openTypeNameLicense = 123 2161*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2162*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2163*e1fe3e4aSElliott Hughes self.tearDownUFO() 2164*e1fe3e4aSElliott Hughes # openTypeNameLicenseURL 2165*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2166*e1fe3e4aSElliott Hughes infoObject.openTypeNameLicenseURL = 123 2167*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2168*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2169*e1fe3e4aSElliott Hughes self.tearDownUFO() 2170*e1fe3e4aSElliott Hughes # openTypeNameVersion 2171*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2172*e1fe3e4aSElliott Hughes infoObject.openTypeNameVersion = 123 2173*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2174*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2175*e1fe3e4aSElliott Hughes self.tearDownUFO() 2176*e1fe3e4aSElliott Hughes # openTypeNameUniqueID 2177*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2178*e1fe3e4aSElliott Hughes infoObject.openTypeNameUniqueID = 123 2179*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2180*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2181*e1fe3e4aSElliott Hughes self.tearDownUFO() 2182*e1fe3e4aSElliott Hughes # openTypeNameDescription 2183*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2184*e1fe3e4aSElliott Hughes infoObject.openTypeNameDescription = 123 2185*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2186*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2187*e1fe3e4aSElliott Hughes self.tearDownUFO() 2188*e1fe3e4aSElliott Hughes # openTypeNamePreferredFamilyName 2189*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2190*e1fe3e4aSElliott Hughes infoObject.openTypeNamePreferredFamilyName = 123 2191*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2192*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2193*e1fe3e4aSElliott Hughes self.tearDownUFO() 2194*e1fe3e4aSElliott Hughes # openTypeNamePreferredSubfamilyName 2195*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2196*e1fe3e4aSElliott Hughes infoObject.openTypeNamePreferredSubfamilyName = 123 2197*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2198*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2199*e1fe3e4aSElliott Hughes self.tearDownUFO() 2200*e1fe3e4aSElliott Hughes # openTypeNameCompatibleFullName 2201*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2202*e1fe3e4aSElliott Hughes infoObject.openTypeNameCompatibleFullName = 123 2203*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2204*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2205*e1fe3e4aSElliott Hughes self.tearDownUFO() 2206*e1fe3e4aSElliott Hughes # openTypeNameSampleText 2207*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2208*e1fe3e4aSElliott Hughes infoObject.openTypeNameSampleText = 123 2209*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2210*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2211*e1fe3e4aSElliott Hughes self.tearDownUFO() 2212*e1fe3e4aSElliott Hughes # openTypeNameWWSFamilyName 2213*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2214*e1fe3e4aSElliott Hughes infoObject.openTypeNameWWSFamilyName = 123 2215*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2216*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2217*e1fe3e4aSElliott Hughes self.tearDownUFO() 2218*e1fe3e4aSElliott Hughes # openTypeNameWWSSubfamilyName 2219*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2220*e1fe3e4aSElliott Hughes infoObject.openTypeNameWWSSubfamilyName = 123 2221*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2222*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2223*e1fe3e4aSElliott Hughes self.tearDownUFO() 2224*e1fe3e4aSElliott Hughes # openTypeNameRecords 2225*e1fe3e4aSElliott Hughes ## not a list 2226*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2227*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = "abc" 2228*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2229*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2230*e1fe3e4aSElliott Hughes self.tearDownUFO() 2231*e1fe3e4aSElliott Hughes ## not a dict 2232*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2233*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = ["abc"] 2234*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2235*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2236*e1fe3e4aSElliott Hughes self.tearDownUFO() 2237*e1fe3e4aSElliott Hughes ## invalid dict structure 2238*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2239*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [dict(foo="bar")] 2240*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2241*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2242*e1fe3e4aSElliott Hughes self.tearDownUFO() 2243*e1fe3e4aSElliott Hughes ## incorrect keys 2244*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2245*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2246*e1fe3e4aSElliott Hughes dict( 2247*e1fe3e4aSElliott Hughes nameID=1, 2248*e1fe3e4aSElliott Hughes platformID=1, 2249*e1fe3e4aSElliott Hughes encodingID=1, 2250*e1fe3e4aSElliott Hughes languageID=1, 2251*e1fe3e4aSElliott Hughes string="Name Record.", 2252*e1fe3e4aSElliott Hughes foo="bar", 2253*e1fe3e4aSElliott Hughes ) 2254*e1fe3e4aSElliott Hughes ] 2255*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2256*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2257*e1fe3e4aSElliott Hughes self.tearDownUFO() 2258*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2259*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2260*e1fe3e4aSElliott Hughes dict(platformID=1, encodingID=1, languageID=1, string="Name Record.") 2261*e1fe3e4aSElliott Hughes ] 2262*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2263*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2264*e1fe3e4aSElliott Hughes self.tearDownUFO() 2265*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2266*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2267*e1fe3e4aSElliott Hughes dict(nameID=1, encodingID=1, languageID=1, string="Name Record.") 2268*e1fe3e4aSElliott Hughes ] 2269*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2270*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2271*e1fe3e4aSElliott Hughes self.tearDownUFO() 2272*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2273*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2274*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, languageID=1, string="Name Record.") 2275*e1fe3e4aSElliott Hughes ] 2276*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2277*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2278*e1fe3e4aSElliott Hughes self.tearDownUFO() 2279*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2280*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2281*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, string="Name Record.") 2282*e1fe3e4aSElliott Hughes ] 2283*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2284*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2285*e1fe3e4aSElliott Hughes self.tearDownUFO() 2286*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2287*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2288*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, languageID=1) 2289*e1fe3e4aSElliott Hughes ] 2290*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2291*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2292*e1fe3e4aSElliott Hughes self.tearDownUFO() 2293*e1fe3e4aSElliott Hughes ## invalid values 2294*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2295*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2296*e1fe3e4aSElliott Hughes dict( 2297*e1fe3e4aSElliott Hughes nameID="1", 2298*e1fe3e4aSElliott Hughes platformID=1, 2299*e1fe3e4aSElliott Hughes encodingID=1, 2300*e1fe3e4aSElliott Hughes languageID=1, 2301*e1fe3e4aSElliott Hughes string="Name Record.", 2302*e1fe3e4aSElliott Hughes ) 2303*e1fe3e4aSElliott Hughes ] 2304*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2305*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2306*e1fe3e4aSElliott Hughes self.tearDownUFO() 2307*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2308*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2309*e1fe3e4aSElliott Hughes dict( 2310*e1fe3e4aSElliott Hughes nameID=1, 2311*e1fe3e4aSElliott Hughes platformID="1", 2312*e1fe3e4aSElliott Hughes encodingID=1, 2313*e1fe3e4aSElliott Hughes languageID=1, 2314*e1fe3e4aSElliott Hughes string="Name Record.", 2315*e1fe3e4aSElliott Hughes ) 2316*e1fe3e4aSElliott Hughes ] 2317*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2318*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2319*e1fe3e4aSElliott Hughes self.tearDownUFO() 2320*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2321*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2322*e1fe3e4aSElliott Hughes dict( 2323*e1fe3e4aSElliott Hughes nameID=1, 2324*e1fe3e4aSElliott Hughes platformID=1, 2325*e1fe3e4aSElliott Hughes encodingID="1", 2326*e1fe3e4aSElliott Hughes languageID=1, 2327*e1fe3e4aSElliott Hughes string="Name Record.", 2328*e1fe3e4aSElliott Hughes ) 2329*e1fe3e4aSElliott Hughes ] 2330*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2331*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2332*e1fe3e4aSElliott Hughes self.tearDownUFO() 2333*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2334*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2335*e1fe3e4aSElliott Hughes dict( 2336*e1fe3e4aSElliott Hughes nameID=1, 2337*e1fe3e4aSElliott Hughes platformID=1, 2338*e1fe3e4aSElliott Hughes encodingID=1, 2339*e1fe3e4aSElliott Hughes languageID="1", 2340*e1fe3e4aSElliott Hughes string="Name Record.", 2341*e1fe3e4aSElliott Hughes ) 2342*e1fe3e4aSElliott Hughes ] 2343*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2344*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2345*e1fe3e4aSElliott Hughes self.tearDownUFO() 2346*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2347*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2348*e1fe3e4aSElliott Hughes dict(nameID=1, platformID=1, encodingID=1, languageID=1, string=1) 2349*e1fe3e4aSElliott Hughes ] 2350*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2351*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2352*e1fe3e4aSElliott Hughes self.tearDownUFO() 2353*e1fe3e4aSElliott Hughes ## duplicate 2354*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2355*e1fe3e4aSElliott Hughes infoObject.openTypeNameRecords = [ 2356*e1fe3e4aSElliott Hughes dict( 2357*e1fe3e4aSElliott Hughes nameID=1, 2358*e1fe3e4aSElliott Hughes platformID=1, 2359*e1fe3e4aSElliott Hughes encodingID=1, 2360*e1fe3e4aSElliott Hughes languageID=1, 2361*e1fe3e4aSElliott Hughes string="Name Record.", 2362*e1fe3e4aSElliott Hughes ), 2363*e1fe3e4aSElliott Hughes dict( 2364*e1fe3e4aSElliott Hughes nameID=1, 2365*e1fe3e4aSElliott Hughes platformID=1, 2366*e1fe3e4aSElliott Hughes encodingID=1, 2367*e1fe3e4aSElliott Hughes languageID=1, 2368*e1fe3e4aSElliott Hughes string="Name Record.", 2369*e1fe3e4aSElliott Hughes ), 2370*e1fe3e4aSElliott Hughes ] 2371*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2372*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 2373*e1fe3e4aSElliott Hughes 2374*e1fe3e4aSElliott Hughes def testOS2Write(self): 2375*e1fe3e4aSElliott Hughes # openTypeOS2WidthClass 2376*e1fe3e4aSElliott Hughes ## not an int 2377*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2378*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WidthClass = "abc" 2379*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2380*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2381*e1fe3e4aSElliott Hughes self.tearDownUFO() 2382*e1fe3e4aSElliott Hughes ## out or range 2383*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2384*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WidthClass = 15 2385*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2386*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2387*e1fe3e4aSElliott Hughes self.tearDownUFO() 2388*e1fe3e4aSElliott Hughes # openTypeOS2WeightClass 2389*e1fe3e4aSElliott Hughes ## not an int 2390*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2391*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WeightClass = "abc" 2392*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2393*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2394*e1fe3e4aSElliott Hughes self.tearDownUFO() 2395*e1fe3e4aSElliott Hughes ## out of range 2396*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2397*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WeightClass = -50 2398*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2399*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2400*e1fe3e4aSElliott Hughes self.tearDownUFO() 2401*e1fe3e4aSElliott Hughes # openTypeOS2Selection 2402*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2403*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Selection = [-1] 2404*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2405*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2406*e1fe3e4aSElliott Hughes self.tearDownUFO() 2407*e1fe3e4aSElliott Hughes # openTypeOS2VendorID 2408*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2409*e1fe3e4aSElliott Hughes infoObject.openTypeOS2VendorID = 1234 2410*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2411*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2412*e1fe3e4aSElliott Hughes self.tearDownUFO() 2413*e1fe3e4aSElliott Hughes # openTypeOS2Panose 2414*e1fe3e4aSElliott Hughes ## not an int 2415*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2416*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Panose = [0, 1, 2, 3, 4, 5, 6, 7, 8, str(9)] 2417*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2418*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2419*e1fe3e4aSElliott Hughes self.tearDownUFO() 2420*e1fe3e4aSElliott Hughes ## too few values 2421*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2422*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Panose = [0, 1, 2, 3] 2423*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2424*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2425*e1fe3e4aSElliott Hughes self.tearDownUFO() 2426*e1fe3e4aSElliott Hughes ## too many values 2427*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2428*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Panose = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] 2429*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2430*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2431*e1fe3e4aSElliott Hughes self.tearDownUFO() 2432*e1fe3e4aSElliott Hughes # openTypeOS2FamilyClass 2433*e1fe3e4aSElliott Hughes ## not an int 2434*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2435*e1fe3e4aSElliott Hughes infoObject.openTypeOS2FamilyClass = [0, str(1)] 2436*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2437*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2438*e1fe3e4aSElliott Hughes self.tearDownUFO() 2439*e1fe3e4aSElliott Hughes ## too few values 2440*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2441*e1fe3e4aSElliott Hughes infoObject.openTypeOS2FamilyClass = [1] 2442*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2443*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2444*e1fe3e4aSElliott Hughes self.tearDownUFO() 2445*e1fe3e4aSElliott Hughes ## too many values 2446*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2447*e1fe3e4aSElliott Hughes infoObject.openTypeOS2FamilyClass = [1, 1, 1] 2448*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2449*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2450*e1fe3e4aSElliott Hughes self.tearDownUFO() 2451*e1fe3e4aSElliott Hughes ## out of range 2452*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2453*e1fe3e4aSElliott Hughes infoObject.openTypeOS2FamilyClass = [1, 20] 2454*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2455*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2456*e1fe3e4aSElliott Hughes self.tearDownUFO() 2457*e1fe3e4aSElliott Hughes # openTypeOS2UnicodeRanges 2458*e1fe3e4aSElliott Hughes ## not an int 2459*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2460*e1fe3e4aSElliott Hughes infoObject.openTypeOS2UnicodeRanges = ["0"] 2461*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2462*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2463*e1fe3e4aSElliott Hughes self.tearDownUFO() 2464*e1fe3e4aSElliott Hughes ## out of range 2465*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2466*e1fe3e4aSElliott Hughes infoObject.openTypeOS2UnicodeRanges = [-1] 2467*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2468*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2469*e1fe3e4aSElliott Hughes self.tearDownUFO() 2470*e1fe3e4aSElliott Hughes # openTypeOS2CodePageRanges 2471*e1fe3e4aSElliott Hughes ## not an int 2472*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2473*e1fe3e4aSElliott Hughes infoObject.openTypeOS2CodePageRanges = ["0"] 2474*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2475*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2476*e1fe3e4aSElliott Hughes self.tearDownUFO() 2477*e1fe3e4aSElliott Hughes ## out of range 2478*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2479*e1fe3e4aSElliott Hughes infoObject.openTypeOS2CodePageRanges = [-1] 2480*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2481*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2482*e1fe3e4aSElliott Hughes self.tearDownUFO() 2483*e1fe3e4aSElliott Hughes # openTypeOS2TypoAscender 2484*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2485*e1fe3e4aSElliott Hughes infoObject.openTypeOS2TypoAscender = "abc" 2486*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2487*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2488*e1fe3e4aSElliott Hughes self.tearDownUFO() 2489*e1fe3e4aSElliott Hughes # openTypeOS2TypoDescender 2490*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2491*e1fe3e4aSElliott Hughes infoObject.openTypeOS2TypoDescender = "abc" 2492*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2493*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2494*e1fe3e4aSElliott Hughes self.tearDownUFO() 2495*e1fe3e4aSElliott Hughes # openTypeOS2TypoLineGap 2496*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2497*e1fe3e4aSElliott Hughes infoObject.openTypeOS2TypoLineGap = "abc" 2498*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2499*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2500*e1fe3e4aSElliott Hughes self.tearDownUFO() 2501*e1fe3e4aSElliott Hughes # openTypeOS2WinAscent 2502*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2503*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WinAscent = "abc" 2504*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2505*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2506*e1fe3e4aSElliott Hughes self.tearDownUFO() 2507*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2508*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WinAscent = -1 2509*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2510*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2511*e1fe3e4aSElliott Hughes self.tearDownUFO() 2512*e1fe3e4aSElliott Hughes # openTypeOS2WinDescent 2513*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2514*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WinDescent = "abc" 2515*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2516*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2517*e1fe3e4aSElliott Hughes self.tearDownUFO() 2518*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2519*e1fe3e4aSElliott Hughes infoObject.openTypeOS2WinDescent = -1 2520*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2521*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2522*e1fe3e4aSElliott Hughes self.tearDownUFO() 2523*e1fe3e4aSElliott Hughes # openTypeOS2Type 2524*e1fe3e4aSElliott Hughes ## not an int 2525*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2526*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Type = ["1"] 2527*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2528*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2529*e1fe3e4aSElliott Hughes self.tearDownUFO() 2530*e1fe3e4aSElliott Hughes ## out of range 2531*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2532*e1fe3e4aSElliott Hughes infoObject.openTypeOS2Type = [-1] 2533*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2534*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2535*e1fe3e4aSElliott Hughes self.tearDownUFO() 2536*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptXSize 2537*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2538*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SubscriptXSize = "abc" 2539*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2540*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2541*e1fe3e4aSElliott Hughes self.tearDownUFO() 2542*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptYSize 2543*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2544*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SubscriptYSize = "abc" 2545*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2546*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2547*e1fe3e4aSElliott Hughes self.tearDownUFO() 2548*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptXOffset 2549*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2550*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SubscriptXOffset = "abc" 2551*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2552*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2553*e1fe3e4aSElliott Hughes self.tearDownUFO() 2554*e1fe3e4aSElliott Hughes # openTypeOS2SubscriptYOffset 2555*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2556*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SubscriptYOffset = "abc" 2557*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2558*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2559*e1fe3e4aSElliott Hughes self.tearDownUFO() 2560*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptXSize 2561*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2562*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SuperscriptXSize = "abc" 2563*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2564*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2565*e1fe3e4aSElliott Hughes self.tearDownUFO() 2566*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptYSize 2567*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2568*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SuperscriptYSize = "abc" 2569*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2570*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2571*e1fe3e4aSElliott Hughes self.tearDownUFO() 2572*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptXOffset 2573*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2574*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SuperscriptXOffset = "abc" 2575*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2576*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2577*e1fe3e4aSElliott Hughes self.tearDownUFO() 2578*e1fe3e4aSElliott Hughes # openTypeOS2SuperscriptYOffset 2579*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2580*e1fe3e4aSElliott Hughes infoObject.openTypeOS2SuperscriptYOffset = "abc" 2581*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2582*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2583*e1fe3e4aSElliott Hughes self.tearDownUFO() 2584*e1fe3e4aSElliott Hughes # openTypeOS2StrikeoutSize 2585*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2586*e1fe3e4aSElliott Hughes infoObject.openTypeOS2StrikeoutSize = "abc" 2587*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2588*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2589*e1fe3e4aSElliott Hughes self.tearDownUFO() 2590*e1fe3e4aSElliott Hughes # openTypeOS2StrikeoutPosition 2591*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2592*e1fe3e4aSElliott Hughes infoObject.openTypeOS2StrikeoutPosition = "abc" 2593*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2594*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2595*e1fe3e4aSElliott Hughes self.tearDownUFO() 2596*e1fe3e4aSElliott Hughes 2597*e1fe3e4aSElliott Hughes def testVheaWrite(self): 2598*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoAscender 2599*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2600*e1fe3e4aSElliott Hughes infoObject.openTypeVheaVertTypoAscender = "abc" 2601*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2602*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2603*e1fe3e4aSElliott Hughes self.tearDownUFO() 2604*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoDescender 2605*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2606*e1fe3e4aSElliott Hughes infoObject.openTypeVheaVertTypoDescender = "abc" 2607*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2608*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2609*e1fe3e4aSElliott Hughes self.tearDownUFO() 2610*e1fe3e4aSElliott Hughes # openTypeVheaVertTypoLineGap 2611*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2612*e1fe3e4aSElliott Hughes infoObject.openTypeVheaVertTypoLineGap = "abc" 2613*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2614*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2615*e1fe3e4aSElliott Hughes self.tearDownUFO() 2616*e1fe3e4aSElliott Hughes # openTypeVheaCaretSlopeRise 2617*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2618*e1fe3e4aSElliott Hughes infoObject.openTypeVheaCaretSlopeRise = "abc" 2619*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2620*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2621*e1fe3e4aSElliott Hughes self.tearDownUFO() 2622*e1fe3e4aSElliott Hughes # openTypeVheaCaretSlopeRun 2623*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2624*e1fe3e4aSElliott Hughes infoObject.openTypeVheaCaretSlopeRun = "abc" 2625*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2626*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2627*e1fe3e4aSElliott Hughes self.tearDownUFO() 2628*e1fe3e4aSElliott Hughes # openTypeVheaCaretOffset 2629*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2630*e1fe3e4aSElliott Hughes infoObject.openTypeVheaCaretOffset = "abc" 2631*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2632*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2633*e1fe3e4aSElliott Hughes self.tearDownUFO() 2634*e1fe3e4aSElliott Hughes 2635*e1fe3e4aSElliott Hughes def testFONDWrite(self): 2636*e1fe3e4aSElliott Hughes # macintoshFONDFamilyID 2637*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2638*e1fe3e4aSElliott Hughes infoObject.macintoshFONDFamilyID = "abc" 2639*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2640*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2641*e1fe3e4aSElliott Hughes self.tearDownUFO() 2642*e1fe3e4aSElliott Hughes # macintoshFONDName 2643*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2644*e1fe3e4aSElliott Hughes infoObject.macintoshFONDName = 123 2645*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2646*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2647*e1fe3e4aSElliott Hughes self.tearDownUFO() 2648*e1fe3e4aSElliott Hughes 2649*e1fe3e4aSElliott Hughes def testPostscriptWrite(self): 2650*e1fe3e4aSElliott Hughes # postscriptFontName 2651*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2652*e1fe3e4aSElliott Hughes infoObject.postscriptFontName = 123 2653*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2654*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2655*e1fe3e4aSElliott Hughes self.tearDownUFO() 2656*e1fe3e4aSElliott Hughes # postscriptFullName 2657*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2658*e1fe3e4aSElliott Hughes infoObject.postscriptFullName = 123 2659*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2660*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2661*e1fe3e4aSElliott Hughes self.tearDownUFO() 2662*e1fe3e4aSElliott Hughes # postscriptSlantAngle 2663*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2664*e1fe3e4aSElliott Hughes infoObject.postscriptSlantAngle = "abc" 2665*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2666*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2667*e1fe3e4aSElliott Hughes self.tearDownUFO() 2668*e1fe3e4aSElliott Hughes # postscriptUniqueID 2669*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2670*e1fe3e4aSElliott Hughes infoObject.postscriptUniqueID = "abc" 2671*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2672*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2673*e1fe3e4aSElliott Hughes self.tearDownUFO() 2674*e1fe3e4aSElliott Hughes # postscriptUnderlineThickness 2675*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2676*e1fe3e4aSElliott Hughes infoObject.postscriptUnderlineThickness = "abc" 2677*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2678*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2679*e1fe3e4aSElliott Hughes self.tearDownUFO() 2680*e1fe3e4aSElliott Hughes # postscriptUnderlinePosition 2681*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2682*e1fe3e4aSElliott Hughes infoObject.postscriptUnderlinePosition = "abc" 2683*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2684*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2685*e1fe3e4aSElliott Hughes self.tearDownUFO() 2686*e1fe3e4aSElliott Hughes # postscriptIsFixedPitch 2687*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2688*e1fe3e4aSElliott Hughes infoObject.postscriptIsFixedPitch = 2 2689*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2690*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2691*e1fe3e4aSElliott Hughes self.tearDownUFO() 2692*e1fe3e4aSElliott Hughes # postscriptBlueValues 2693*e1fe3e4aSElliott Hughes ## not a list 2694*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2695*e1fe3e4aSElliott Hughes infoObject.postscriptBlueValues = "abc" 2696*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2697*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2698*e1fe3e4aSElliott Hughes self.tearDownUFO() 2699*e1fe3e4aSElliott Hughes ## uneven value count 2700*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2701*e1fe3e4aSElliott Hughes infoObject.postscriptBlueValues = [500] 2702*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2703*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2704*e1fe3e4aSElliott Hughes self.tearDownUFO() 2705*e1fe3e4aSElliott Hughes ## too many values 2706*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2707*e1fe3e4aSElliott Hughes infoObject.postscriptBlueValues = [ 2708*e1fe3e4aSElliott Hughes 10, 2709*e1fe3e4aSElliott Hughes 20, 2710*e1fe3e4aSElliott Hughes 30, 2711*e1fe3e4aSElliott Hughes 40, 2712*e1fe3e4aSElliott Hughes 50, 2713*e1fe3e4aSElliott Hughes 60, 2714*e1fe3e4aSElliott Hughes 70, 2715*e1fe3e4aSElliott Hughes 80, 2716*e1fe3e4aSElliott Hughes 90, 2717*e1fe3e4aSElliott Hughes 100, 2718*e1fe3e4aSElliott Hughes 110, 2719*e1fe3e4aSElliott Hughes 120, 2720*e1fe3e4aSElliott Hughes 130, 2721*e1fe3e4aSElliott Hughes 140, 2722*e1fe3e4aSElliott Hughes 150, 2723*e1fe3e4aSElliott Hughes 160, 2724*e1fe3e4aSElliott Hughes ] 2725*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2726*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2727*e1fe3e4aSElliott Hughes self.tearDownUFO() 2728*e1fe3e4aSElliott Hughes # postscriptOtherBlues 2729*e1fe3e4aSElliott Hughes ## not a list 2730*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2731*e1fe3e4aSElliott Hughes infoObject.postscriptOtherBlues = "abc" 2732*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2733*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2734*e1fe3e4aSElliott Hughes self.tearDownUFO() 2735*e1fe3e4aSElliott Hughes ## uneven value count 2736*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2737*e1fe3e4aSElliott Hughes infoObject.postscriptOtherBlues = [500] 2738*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2739*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2740*e1fe3e4aSElliott Hughes self.tearDownUFO() 2741*e1fe3e4aSElliott Hughes ## too many values 2742*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2743*e1fe3e4aSElliott Hughes infoObject.postscriptOtherBlues = [ 2744*e1fe3e4aSElliott Hughes 10, 2745*e1fe3e4aSElliott Hughes 20, 2746*e1fe3e4aSElliott Hughes 30, 2747*e1fe3e4aSElliott Hughes 40, 2748*e1fe3e4aSElliott Hughes 50, 2749*e1fe3e4aSElliott Hughes 60, 2750*e1fe3e4aSElliott Hughes 70, 2751*e1fe3e4aSElliott Hughes 80, 2752*e1fe3e4aSElliott Hughes 90, 2753*e1fe3e4aSElliott Hughes 100, 2754*e1fe3e4aSElliott Hughes 110, 2755*e1fe3e4aSElliott Hughes 120, 2756*e1fe3e4aSElliott Hughes 130, 2757*e1fe3e4aSElliott Hughes 140, 2758*e1fe3e4aSElliott Hughes 150, 2759*e1fe3e4aSElliott Hughes 160, 2760*e1fe3e4aSElliott Hughes ] 2761*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2762*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2763*e1fe3e4aSElliott Hughes self.tearDownUFO() 2764*e1fe3e4aSElliott Hughes # postscriptFamilyBlues 2765*e1fe3e4aSElliott Hughes ## not a list 2766*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2767*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyBlues = "abc" 2768*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2769*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2770*e1fe3e4aSElliott Hughes self.tearDownUFO() 2771*e1fe3e4aSElliott Hughes ## uneven value count 2772*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2773*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyBlues = [500] 2774*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2775*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2776*e1fe3e4aSElliott Hughes self.tearDownUFO() 2777*e1fe3e4aSElliott Hughes ## too many values 2778*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2779*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyBlues = [ 2780*e1fe3e4aSElliott Hughes 10, 2781*e1fe3e4aSElliott Hughes 20, 2782*e1fe3e4aSElliott Hughes 30, 2783*e1fe3e4aSElliott Hughes 40, 2784*e1fe3e4aSElliott Hughes 50, 2785*e1fe3e4aSElliott Hughes 60, 2786*e1fe3e4aSElliott Hughes 70, 2787*e1fe3e4aSElliott Hughes 80, 2788*e1fe3e4aSElliott Hughes 90, 2789*e1fe3e4aSElliott Hughes 100, 2790*e1fe3e4aSElliott Hughes 110, 2791*e1fe3e4aSElliott Hughes 120, 2792*e1fe3e4aSElliott Hughes 130, 2793*e1fe3e4aSElliott Hughes 140, 2794*e1fe3e4aSElliott Hughes 150, 2795*e1fe3e4aSElliott Hughes 160, 2796*e1fe3e4aSElliott Hughes ] 2797*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2798*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2799*e1fe3e4aSElliott Hughes self.tearDownUFO() 2800*e1fe3e4aSElliott Hughes # postscriptFamilyOtherBlues 2801*e1fe3e4aSElliott Hughes ## not a list 2802*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2803*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyOtherBlues = "abc" 2804*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2805*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2806*e1fe3e4aSElliott Hughes self.tearDownUFO() 2807*e1fe3e4aSElliott Hughes ## uneven value count 2808*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2809*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyOtherBlues = [500] 2810*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2811*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2812*e1fe3e4aSElliott Hughes self.tearDownUFO() 2813*e1fe3e4aSElliott Hughes ## too many values 2814*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2815*e1fe3e4aSElliott Hughes infoObject.postscriptFamilyOtherBlues = [ 2816*e1fe3e4aSElliott Hughes 10, 2817*e1fe3e4aSElliott Hughes 20, 2818*e1fe3e4aSElliott Hughes 30, 2819*e1fe3e4aSElliott Hughes 40, 2820*e1fe3e4aSElliott Hughes 50, 2821*e1fe3e4aSElliott Hughes 60, 2822*e1fe3e4aSElliott Hughes 70, 2823*e1fe3e4aSElliott Hughes 80, 2824*e1fe3e4aSElliott Hughes 90, 2825*e1fe3e4aSElliott Hughes 100, 2826*e1fe3e4aSElliott Hughes 110, 2827*e1fe3e4aSElliott Hughes 120, 2828*e1fe3e4aSElliott Hughes 130, 2829*e1fe3e4aSElliott Hughes 140, 2830*e1fe3e4aSElliott Hughes 150, 2831*e1fe3e4aSElliott Hughes 160, 2832*e1fe3e4aSElliott Hughes ] 2833*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2834*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2835*e1fe3e4aSElliott Hughes self.tearDownUFO() 2836*e1fe3e4aSElliott Hughes # postscriptStemSnapH 2837*e1fe3e4aSElliott Hughes ## not list 2838*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2839*e1fe3e4aSElliott Hughes infoObject.postscriptStemSnapH = "abc" 2840*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2841*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2842*e1fe3e4aSElliott Hughes self.tearDownUFO() 2843*e1fe3e4aSElliott Hughes ## too many values 2844*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2845*e1fe3e4aSElliott Hughes infoObject.postscriptStemSnapH = [ 2846*e1fe3e4aSElliott Hughes 10, 2847*e1fe3e4aSElliott Hughes 20, 2848*e1fe3e4aSElliott Hughes 30, 2849*e1fe3e4aSElliott Hughes 40, 2850*e1fe3e4aSElliott Hughes 50, 2851*e1fe3e4aSElliott Hughes 60, 2852*e1fe3e4aSElliott Hughes 70, 2853*e1fe3e4aSElliott Hughes 80, 2854*e1fe3e4aSElliott Hughes 90, 2855*e1fe3e4aSElliott Hughes 100, 2856*e1fe3e4aSElliott Hughes 110, 2857*e1fe3e4aSElliott Hughes 120, 2858*e1fe3e4aSElliott Hughes 130, 2859*e1fe3e4aSElliott Hughes 140, 2860*e1fe3e4aSElliott Hughes 150, 2861*e1fe3e4aSElliott Hughes 160, 2862*e1fe3e4aSElliott Hughes ] 2863*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2864*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2865*e1fe3e4aSElliott Hughes self.tearDownUFO() 2866*e1fe3e4aSElliott Hughes # postscriptStemSnapV 2867*e1fe3e4aSElliott Hughes ## not list 2868*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2869*e1fe3e4aSElliott Hughes infoObject.postscriptStemSnapV = "abc" 2870*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2871*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2872*e1fe3e4aSElliott Hughes self.tearDownUFO() 2873*e1fe3e4aSElliott Hughes ## too many values 2874*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2875*e1fe3e4aSElliott Hughes infoObject.postscriptStemSnapV = [ 2876*e1fe3e4aSElliott Hughes 10, 2877*e1fe3e4aSElliott Hughes 20, 2878*e1fe3e4aSElliott Hughes 30, 2879*e1fe3e4aSElliott Hughes 40, 2880*e1fe3e4aSElliott Hughes 50, 2881*e1fe3e4aSElliott Hughes 60, 2882*e1fe3e4aSElliott Hughes 70, 2883*e1fe3e4aSElliott Hughes 80, 2884*e1fe3e4aSElliott Hughes 90, 2885*e1fe3e4aSElliott Hughes 100, 2886*e1fe3e4aSElliott Hughes 110, 2887*e1fe3e4aSElliott Hughes 120, 2888*e1fe3e4aSElliott Hughes 130, 2889*e1fe3e4aSElliott Hughes 140, 2890*e1fe3e4aSElliott Hughes 150, 2891*e1fe3e4aSElliott Hughes 160, 2892*e1fe3e4aSElliott Hughes ] 2893*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2894*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2895*e1fe3e4aSElliott Hughes self.tearDownUFO() 2896*e1fe3e4aSElliott Hughes # postscriptBlueFuzz 2897*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2898*e1fe3e4aSElliott Hughes infoObject.postscriptBlueFuzz = "abc" 2899*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2900*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2901*e1fe3e4aSElliott Hughes self.tearDownUFO() 2902*e1fe3e4aSElliott Hughes # postscriptBlueShift 2903*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2904*e1fe3e4aSElliott Hughes infoObject.postscriptBlueShift = "abc" 2905*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2906*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2907*e1fe3e4aSElliott Hughes self.tearDownUFO() 2908*e1fe3e4aSElliott Hughes # postscriptBlueScale 2909*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2910*e1fe3e4aSElliott Hughes infoObject.postscriptBlueScale = "abc" 2911*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2912*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2913*e1fe3e4aSElliott Hughes self.tearDownUFO() 2914*e1fe3e4aSElliott Hughes # postscriptForceBold 2915*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2916*e1fe3e4aSElliott Hughes infoObject.postscriptForceBold = "abc" 2917*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2918*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2919*e1fe3e4aSElliott Hughes self.tearDownUFO() 2920*e1fe3e4aSElliott Hughes # postscriptDefaultWidthX 2921*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2922*e1fe3e4aSElliott Hughes infoObject.postscriptDefaultWidthX = "abc" 2923*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2924*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2925*e1fe3e4aSElliott Hughes self.tearDownUFO() 2926*e1fe3e4aSElliott Hughes # postscriptNominalWidthX 2927*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2928*e1fe3e4aSElliott Hughes infoObject.postscriptNominalWidthX = "abc" 2929*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2930*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2931*e1fe3e4aSElliott Hughes self.tearDownUFO() 2932*e1fe3e4aSElliott Hughes # postscriptWeightName 2933*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2934*e1fe3e4aSElliott Hughes infoObject.postscriptWeightName = 123 2935*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2936*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2937*e1fe3e4aSElliott Hughes self.tearDownUFO() 2938*e1fe3e4aSElliott Hughes # postscriptDefaultCharacter 2939*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2940*e1fe3e4aSElliott Hughes infoObject.postscriptDefaultCharacter = 123 2941*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2942*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2943*e1fe3e4aSElliott Hughes self.tearDownUFO() 2944*e1fe3e4aSElliott Hughes # postscriptWindowsCharacterSet 2945*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2946*e1fe3e4aSElliott Hughes infoObject.postscriptWindowsCharacterSet = -1 2947*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2948*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2949*e1fe3e4aSElliott Hughes self.tearDownUFO() 2950*e1fe3e4aSElliott Hughes # macintoshFONDFamilyID 2951*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2952*e1fe3e4aSElliott Hughes infoObject.macintoshFONDFamilyID = "abc" 2953*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2954*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2955*e1fe3e4aSElliott Hughes self.tearDownUFO() 2956*e1fe3e4aSElliott Hughes # macintoshFONDName 2957*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2958*e1fe3e4aSElliott Hughes infoObject.macintoshFONDName = 123 2959*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2960*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2961*e1fe3e4aSElliott Hughes self.tearDownUFO() 2962*e1fe3e4aSElliott Hughes 2963*e1fe3e4aSElliott Hughes def testWOFFWrite(self): 2964*e1fe3e4aSElliott Hughes # woffMajorVersion 2965*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2966*e1fe3e4aSElliott Hughes infoObject.woffMajorVersion = 1.0 2967*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2968*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2969*e1fe3e4aSElliott Hughes self.tearDownUFO() 2970*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2971*e1fe3e4aSElliott Hughes infoObject.woffMajorVersion = "abc" 2972*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2973*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2974*e1fe3e4aSElliott Hughes self.tearDownUFO() 2975*e1fe3e4aSElliott Hughes # woffMinorVersion 2976*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2977*e1fe3e4aSElliott Hughes infoObject.woffMinorVersion = 1.0 2978*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2979*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2980*e1fe3e4aSElliott Hughes self.tearDownUFO() 2981*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2982*e1fe3e4aSElliott Hughes infoObject.woffMinorVersion = "abc" 2983*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2984*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2985*e1fe3e4aSElliott Hughes self.tearDownUFO() 2986*e1fe3e4aSElliott Hughes # woffMetadataUniqueID 2987*e1fe3e4aSElliott Hughes ## none 2988*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2989*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = None 2990*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2991*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 2992*e1fe3e4aSElliott Hughes self.tearDownUFO() 2993*e1fe3e4aSElliott Hughes ## not a dict 2994*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 2995*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = 1 2996*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 2997*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 2998*e1fe3e4aSElliott Hughes self.tearDownUFO() 2999*e1fe3e4aSElliott Hughes ## unknown key 3000*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3001*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = dict(id="foo", notTheRightKey=1) 3002*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3003*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3004*e1fe3e4aSElliott Hughes self.tearDownUFO() 3005*e1fe3e4aSElliott Hughes ## no id 3006*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3007*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = dict() 3008*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3009*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3010*e1fe3e4aSElliott Hughes self.tearDownUFO() 3011*e1fe3e4aSElliott Hughes ## not a string for id 3012*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3013*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = dict(id=1) 3014*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3015*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3016*e1fe3e4aSElliott Hughes self.tearDownUFO() 3017*e1fe3e4aSElliott Hughes ## empty string 3018*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3019*e1fe3e4aSElliott Hughes infoObject.woffMetadataUniqueID = dict(id="") 3020*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3021*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3022*e1fe3e4aSElliott Hughes self.tearDownUFO() 3023*e1fe3e4aSElliott Hughes # woffMetadataVendor 3024*e1fe3e4aSElliott Hughes ## no name 3025*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3026*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(url="foo") 3027*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3028*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3029*e1fe3e4aSElliott Hughes self.tearDownUFO() 3030*e1fe3e4aSElliott Hughes ## name not a string 3031*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3032*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name=1, url="foo") 3033*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3034*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3035*e1fe3e4aSElliott Hughes self.tearDownUFO() 3036*e1fe3e4aSElliott Hughes ## name an empty string 3037*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3038*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="", url="foo") 3039*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3040*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3041*e1fe3e4aSElliott Hughes self.tearDownUFO() 3042*e1fe3e4aSElliott Hughes ## no URL 3043*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3044*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo") 3045*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3046*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3047*e1fe3e4aSElliott Hughes self.tearDownUFO() 3048*e1fe3e4aSElliott Hughes ## url not a string 3049*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3050*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url=1) 3051*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3052*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3053*e1fe3e4aSElliott Hughes self.tearDownUFO() 3054*e1fe3e4aSElliott Hughes ## url empty string 3055*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3056*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url="") 3057*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3058*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3059*e1fe3e4aSElliott Hughes self.tearDownUFO() 3060*e1fe3e4aSElliott Hughes ## have dir 3061*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3062*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url="bar", dir="ltr") 3063*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3064*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3065*e1fe3e4aSElliott Hughes self.tearDownUFO() 3066*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3067*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url="bar", dir="rtl") 3068*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3069*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3070*e1fe3e4aSElliott Hughes self.tearDownUFO() 3071*e1fe3e4aSElliott Hughes ## dir not a string 3072*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3073*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url="bar", dir=1) 3074*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3075*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3076*e1fe3e4aSElliott Hughes self.tearDownUFO() 3077*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3078*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3079*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = dict(name="foo", url="bar", dir="utd") 3080*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3081*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3082*e1fe3e4aSElliott Hughes self.tearDownUFO() 3083*e1fe3e4aSElliott Hughes ## have class 3084*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3085*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = {"name": "foo", "url": "bar", "class": "hello"} 3086*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3087*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3088*e1fe3e4aSElliott Hughes self.tearDownUFO() 3089*e1fe3e4aSElliott Hughes ## class not a string 3090*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3091*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = {"name": "foo", "url": "bar", "class": 1} 3092*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3093*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3094*e1fe3e4aSElliott Hughes self.tearDownUFO() 3095*e1fe3e4aSElliott Hughes ## class empty string 3096*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3097*e1fe3e4aSElliott Hughes infoObject.woffMetadataVendor = {"name": "foo", "url": "bar", "class": ""} 3098*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3099*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3100*e1fe3e4aSElliott Hughes self.tearDownUFO() 3101*e1fe3e4aSElliott Hughes # woffMetadataCredits 3102*e1fe3e4aSElliott Hughes ## no credits attribute 3103*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3104*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = {} 3105*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3106*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3107*e1fe3e4aSElliott Hughes self.tearDownUFO() 3108*e1fe3e4aSElliott Hughes ## unknown attribute 3109*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3110*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict( 3111*e1fe3e4aSElliott Hughes credits=[dict(name="foo")], notTheRightKey=1 3112*e1fe3e4aSElliott Hughes ) 3113*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3114*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3115*e1fe3e4aSElliott Hughes self.tearDownUFO() 3116*e1fe3e4aSElliott Hughes ## not a list 3117*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3118*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits="abc") 3119*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3120*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3121*e1fe3e4aSElliott Hughes self.tearDownUFO() 3122*e1fe3e4aSElliott Hughes ## no elements in credits 3123*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3124*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[]) 3125*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3126*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3127*e1fe3e4aSElliott Hughes self.tearDownUFO() 3128*e1fe3e4aSElliott Hughes ## credit not a dict 3129*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3130*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=["abc"]) 3131*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3132*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3133*e1fe3e4aSElliott Hughes self.tearDownUFO() 3134*e1fe3e4aSElliott Hughes ## unknown key 3135*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3136*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict( 3137*e1fe3e4aSElliott Hughes credits=[dict(name="foo", notTheRightKey=1)] 3138*e1fe3e4aSElliott Hughes ) 3139*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3140*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3141*e1fe3e4aSElliott Hughes self.tearDownUFO() 3142*e1fe3e4aSElliott Hughes ## no name 3143*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3144*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(url="foo")]) 3145*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3146*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3147*e1fe3e4aSElliott Hughes self.tearDownUFO() 3148*e1fe3e4aSElliott Hughes ## name not a string 3149*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3150*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(name=1)]) 3151*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3152*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3153*e1fe3e4aSElliott Hughes self.tearDownUFO() 3154*e1fe3e4aSElliott Hughes ## url not a string 3155*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3156*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(name="foo", url=1)]) 3157*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3158*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3159*e1fe3e4aSElliott Hughes self.tearDownUFO() 3160*e1fe3e4aSElliott Hughes ## role not a string 3161*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3162*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(name="foo", role=1)]) 3163*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3164*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3165*e1fe3e4aSElliott Hughes self.tearDownUFO() 3166*e1fe3e4aSElliott Hughes ## dir not a string 3167*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3168*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(name="foo", dir=1)]) 3169*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3170*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3171*e1fe3e4aSElliott Hughes self.tearDownUFO() 3172*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3173*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3174*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[dict(name="foo", dir="utd")]) 3175*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3176*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3177*e1fe3e4aSElliott Hughes self.tearDownUFO() 3178*e1fe3e4aSElliott Hughes ## class not a string 3179*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3180*e1fe3e4aSElliott Hughes infoObject.woffMetadataCredits = dict(credits=[{"name": "foo", "class": 1}]) 3181*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3182*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3183*e1fe3e4aSElliott Hughes self.tearDownUFO() 3184*e1fe3e4aSElliott Hughes # woffMetadataDescription 3185*e1fe3e4aSElliott Hughes ## no url 3186*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3187*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text="foo")]) 3188*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3189*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3190*e1fe3e4aSElliott Hughes self.tearDownUFO() 3191*e1fe3e4aSElliott Hughes ## url not a string 3192*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3193*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text="foo")], url=1) 3194*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3195*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3196*e1fe3e4aSElliott Hughes self.tearDownUFO() 3197*e1fe3e4aSElliott Hughes ## no text 3198*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3199*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(url="foo") 3200*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3201*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3202*e1fe3e4aSElliott Hughes self.tearDownUFO() 3203*e1fe3e4aSElliott Hughes ## text not a list 3204*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3205*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text="abc") 3206*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3207*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3208*e1fe3e4aSElliott Hughes self.tearDownUFO() 3209*e1fe3e4aSElliott Hughes ## text item not a dict 3210*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3211*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=["abc"]) 3212*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3213*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3214*e1fe3e4aSElliott Hughes self.tearDownUFO() 3215*e1fe3e4aSElliott Hughes ## text item unknown key 3216*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3217*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict( 3218*e1fe3e4aSElliott Hughes text=[dict(text="foo", notTheRightKey=1)] 3219*e1fe3e4aSElliott Hughes ) 3220*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3221*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3222*e1fe3e4aSElliott Hughes self.tearDownUFO() 3223*e1fe3e4aSElliott Hughes ## text item missing text 3224*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3225*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(language="foo")]) 3226*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3227*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3228*e1fe3e4aSElliott Hughes self.tearDownUFO() 3229*e1fe3e4aSElliott Hughes ## text not a string 3230*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3231*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text=1)]) 3232*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3233*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3234*e1fe3e4aSElliott Hughes self.tearDownUFO() 3235*e1fe3e4aSElliott Hughes ## url not a string 3236*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3237*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text="foo", url=1)]) 3238*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3239*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3240*e1fe3e4aSElliott Hughes self.tearDownUFO() 3241*e1fe3e4aSElliott Hughes ## language not a string 3242*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3243*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text="foo", language=1)]) 3244*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3245*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3246*e1fe3e4aSElliott Hughes self.tearDownUFO() 3247*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3248*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3249*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[dict(text="foo", dir="utd")]) 3250*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3251*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3252*e1fe3e4aSElliott Hughes self.tearDownUFO() 3253*e1fe3e4aSElliott Hughes ## class not a string 3254*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3255*e1fe3e4aSElliott Hughes infoObject.woffMetadataDescription = dict(text=[{"text": "foo", "class": 1}]) 3256*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3257*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3258*e1fe3e4aSElliott Hughes self.tearDownUFO() 3259*e1fe3e4aSElliott Hughes # woffMetadataLicense 3260*e1fe3e4aSElliott Hughes ## no url 3261*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3262*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo")]) 3263*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3264*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3265*e1fe3e4aSElliott Hughes self.tearDownUFO() 3266*e1fe3e4aSElliott Hughes ## url not a string 3267*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3268*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo")], url=1) 3269*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3270*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3271*e1fe3e4aSElliott Hughes self.tearDownUFO() 3272*e1fe3e4aSElliott Hughes ## id not a string 3273*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3274*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo")], id=1) 3275*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3276*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3277*e1fe3e4aSElliott Hughes self.tearDownUFO() 3278*e1fe3e4aSElliott Hughes ## no text 3279*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3280*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(url="foo") 3281*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3282*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3283*e1fe3e4aSElliott Hughes self.tearDownUFO() 3284*e1fe3e4aSElliott Hughes ## text not a list 3285*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3286*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text="abc") 3287*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3288*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3289*e1fe3e4aSElliott Hughes self.tearDownUFO() 3290*e1fe3e4aSElliott Hughes ## text item not a dict 3291*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3292*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=["abc"]) 3293*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3294*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3295*e1fe3e4aSElliott Hughes self.tearDownUFO() 3296*e1fe3e4aSElliott Hughes ## text item unknown key 3297*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3298*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo", notTheRightKey=1)]) 3299*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3300*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3301*e1fe3e4aSElliott Hughes self.tearDownUFO() 3302*e1fe3e4aSElliott Hughes ## text item missing text 3303*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3304*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3305*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(language="foo")]) 3306*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3307*e1fe3e4aSElliott Hughes self.tearDownUFO() 3308*e1fe3e4aSElliott Hughes ## text not a string 3309*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3310*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3311*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text=1)]) 3312*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3313*e1fe3e4aSElliott Hughes self.tearDownUFO() 3314*e1fe3e4aSElliott Hughes ## url not a string 3315*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3316*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3317*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo", url=1)]) 3318*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3319*e1fe3e4aSElliott Hughes self.tearDownUFO() 3320*e1fe3e4aSElliott Hughes ## language not a string 3321*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3322*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3323*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo", language=1)]) 3324*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3325*e1fe3e4aSElliott Hughes self.tearDownUFO() 3326*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3327*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3328*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3329*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[dict(text="foo", dir="utd")]) 3330*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3331*e1fe3e4aSElliott Hughes self.tearDownUFO() 3332*e1fe3e4aSElliott Hughes ## class not a string 3333*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3334*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3335*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicense = dict(text=[{"text": "foo", "class": 1}]) 3336*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3337*e1fe3e4aSElliott Hughes self.tearDownUFO() 3338*e1fe3e4aSElliott Hughes # woffMetadataCopyright 3339*e1fe3e4aSElliott Hughes ## unknown attribute 3340*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3341*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3342*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict( 3343*e1fe3e4aSElliott Hughes text=[dict(text="foo")], notTheRightKey=1 3344*e1fe3e4aSElliott Hughes ) 3345*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3346*e1fe3e4aSElliott Hughes self.tearDownUFO() 3347*e1fe3e4aSElliott Hughes ## no text 3348*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3349*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3350*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict() 3351*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3352*e1fe3e4aSElliott Hughes self.tearDownUFO() 3353*e1fe3e4aSElliott Hughes ## text not a list 3354*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3355*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3356*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text="abc") 3357*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3358*e1fe3e4aSElliott Hughes self.tearDownUFO() 3359*e1fe3e4aSElliott Hughes ## text item not a dict 3360*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3361*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3362*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=["abc"]) 3363*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3364*e1fe3e4aSElliott Hughes self.tearDownUFO() 3365*e1fe3e4aSElliott Hughes ## text item unknown key 3366*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3367*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3368*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict( 3369*e1fe3e4aSElliott Hughes text=[dict(text="foo", notTheRightKey=1)] 3370*e1fe3e4aSElliott Hughes ) 3371*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3372*e1fe3e4aSElliott Hughes self.tearDownUFO() 3373*e1fe3e4aSElliott Hughes ## text item missing text 3374*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3375*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[dict(language="foo")]) 3376*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3377*e1fe3e4aSElliott Hughes self.tearDownUFO() 3378*e1fe3e4aSElliott Hughes ## text not a string 3379*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3380*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3381*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[dict(text=1)]) 3382*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3383*e1fe3e4aSElliott Hughes self.tearDownUFO() 3384*e1fe3e4aSElliott Hughes ## url not a string 3385*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3386*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3387*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", url=1)]) 3388*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3389*e1fe3e4aSElliott Hughes self.tearDownUFO() 3390*e1fe3e4aSElliott Hughes ## language not a string 3391*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3392*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3393*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", language=1)]) 3394*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3395*e1fe3e4aSElliott Hughes self.tearDownUFO() 3396*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3397*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3398*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3399*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[dict(text="foo", dir="utd")]) 3400*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3401*e1fe3e4aSElliott Hughes self.tearDownUFO() 3402*e1fe3e4aSElliott Hughes ## class not a string 3403*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3404*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3405*e1fe3e4aSElliott Hughes infoObject.woffMetadataCopyright = dict(text=[{"text": "foo", "class": 1}]) 3406*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3407*e1fe3e4aSElliott Hughes self.tearDownUFO() 3408*e1fe3e4aSElliott Hughes # woffMetadataTrademark 3409*e1fe3e4aSElliott Hughes ## unknown attribute 3410*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3411*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3412*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict( 3413*e1fe3e4aSElliott Hughes text=[dict(text="foo")], notTheRightKey=1 3414*e1fe3e4aSElliott Hughes ) 3415*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3416*e1fe3e4aSElliott Hughes self.tearDownUFO() 3417*e1fe3e4aSElliott Hughes ## no text 3418*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3419*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3420*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict() 3421*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3422*e1fe3e4aSElliott Hughes self.tearDownUFO() 3423*e1fe3e4aSElliott Hughes ## text not a list 3424*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3425*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3426*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text="abc") 3427*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3428*e1fe3e4aSElliott Hughes self.tearDownUFO() 3429*e1fe3e4aSElliott Hughes ## text item not a dict 3430*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3431*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3432*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=["abc"]) 3433*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3434*e1fe3e4aSElliott Hughes self.tearDownUFO() 3435*e1fe3e4aSElliott Hughes ## text item unknown key 3436*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3437*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3438*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict( 3439*e1fe3e4aSElliott Hughes text=[dict(text="foo", notTheRightKey=1)] 3440*e1fe3e4aSElliott Hughes ) 3441*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3442*e1fe3e4aSElliott Hughes self.tearDownUFO() 3443*e1fe3e4aSElliott Hughes ## text item missing text 3444*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3445*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3446*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[dict(language="foo")]) 3447*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3448*e1fe3e4aSElliott Hughes self.tearDownUFO() 3449*e1fe3e4aSElliott Hughes ## text not a string 3450*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3451*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3452*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[dict(text=1)]) 3453*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3454*e1fe3e4aSElliott Hughes self.tearDownUFO() 3455*e1fe3e4aSElliott Hughes ## url not a string 3456*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3457*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3458*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[dict(text="foo", url=1)]) 3459*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3460*e1fe3e4aSElliott Hughes self.tearDownUFO() 3461*e1fe3e4aSElliott Hughes ## language not a string 3462*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3463*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3464*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[dict(text="foo", language=1)]) 3465*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3466*e1fe3e4aSElliott Hughes self.tearDownUFO() 3467*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3468*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3469*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3470*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[dict(text="foo", dir="utd")]) 3471*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3472*e1fe3e4aSElliott Hughes self.tearDownUFO() 3473*e1fe3e4aSElliott Hughes ## class not a string 3474*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3475*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3476*e1fe3e4aSElliott Hughes infoObject.woffMetadataTrademark = dict(text=[{"text": "foo", "class": 1}]) 3477*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3478*e1fe3e4aSElliott Hughes self.tearDownUFO() 3479*e1fe3e4aSElliott Hughes # woffMetadataLicensee 3480*e1fe3e4aSElliott Hughes ## no name 3481*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3482*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3483*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict() 3484*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3485*e1fe3e4aSElliott Hughes self.tearDownUFO() 3486*e1fe3e4aSElliott Hughes ## unknown attribute 3487*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3488*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3489*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict(name="foo", notTheRightKey=1) 3490*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3491*e1fe3e4aSElliott Hughes self.tearDownUFO() 3492*e1fe3e4aSElliott Hughes ## name not a string 3493*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3494*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3495*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict(name=1) 3496*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3497*e1fe3e4aSElliott Hughes self.tearDownUFO() 3498*e1fe3e4aSElliott Hughes ## dir options 3499*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3500*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict(name="foo", dir="ltr") 3501*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3502*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3503*e1fe3e4aSElliott Hughes self.tearDownUFO() 3504*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3505*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict(name="foo", dir="rtl") 3506*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3507*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3508*e1fe3e4aSElliott Hughes self.tearDownUFO() 3509*e1fe3e4aSElliott Hughes ## dir not ltr or rtl 3510*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3511*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = dict(name="foo", dir="utd") 3512*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3513*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3514*e1fe3e4aSElliott Hughes self.tearDownUFO() 3515*e1fe3e4aSElliott Hughes ## have class 3516*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3517*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = {"name": "foo", "class": "hello"} 3518*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3519*e1fe3e4aSElliott Hughes writer.writeInfo(infoObject) 3520*e1fe3e4aSElliott Hughes self.tearDownUFO() 3521*e1fe3e4aSElliott Hughes ## class not a string 3522*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3523*e1fe3e4aSElliott Hughes infoObject.woffMetadataLicensee = {"name": "foo", "class": 1} 3524*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3525*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3526*e1fe3e4aSElliott Hughes self.tearDownUFO() 3527*e1fe3e4aSElliott Hughes 3528*e1fe3e4aSElliott Hughes def testGuidelinesWrite(self): 3529*e1fe3e4aSElliott Hughes # x 3530*e1fe3e4aSElliott Hughes ## not an int or float 3531*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3532*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x="1")] 3533*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3534*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3535*e1fe3e4aSElliott Hughes self.tearDownUFO() 3536*e1fe3e4aSElliott Hughes # y 3537*e1fe3e4aSElliott Hughes ## not an int or float 3538*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3539*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(y="1")] 3540*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3541*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3542*e1fe3e4aSElliott Hughes self.tearDownUFO() 3543*e1fe3e4aSElliott Hughes # angle 3544*e1fe3e4aSElliott Hughes ## < 0 3545*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3546*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, y=0, angle=-1)] 3547*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3548*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3549*e1fe3e4aSElliott Hughes self.tearDownUFO() 3550*e1fe3e4aSElliott Hughes ## > 360 3551*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3552*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, y=0, angle=361)] 3553*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3554*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3555*e1fe3e4aSElliott Hughes self.tearDownUFO() 3556*e1fe3e4aSElliott Hughes # name 3557*e1fe3e4aSElliott Hughes ## not a string 3558*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3559*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, name=1)] 3560*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3561*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3562*e1fe3e4aSElliott Hughes self.tearDownUFO() 3563*e1fe3e4aSElliott Hughes # color 3564*e1fe3e4aSElliott Hughes ## not a string 3565*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3566*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color=1)] 3567*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3568*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3569*e1fe3e4aSElliott Hughes self.tearDownUFO() 3570*e1fe3e4aSElliott Hughes ## not enough commas 3571*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3572*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1 0, 0, 0")] 3573*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3574*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3575*e1fe3e4aSElliott Hughes self.tearDownUFO() 3576*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3577*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1 0 0, 0")] 3578*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3579*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3580*e1fe3e4aSElliott Hughes self.tearDownUFO() 3581*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3582*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1 0 0 0")] 3583*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3584*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3585*e1fe3e4aSElliott Hughes self.tearDownUFO() 3586*e1fe3e4aSElliott Hughes ## not enough parts 3587*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3588*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color=", 0, 0, 0")] 3589*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3590*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3591*e1fe3e4aSElliott Hughes self.tearDownUFO() 3592*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3593*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, , 0, 0")] 3594*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3595*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3596*e1fe3e4aSElliott Hughes self.tearDownUFO() 3597*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3598*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, 0, , 0")] 3599*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3600*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3601*e1fe3e4aSElliott Hughes self.tearDownUFO() 3602*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3603*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, 0, 0, ")] 3604*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3605*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3606*e1fe3e4aSElliott Hughes self.tearDownUFO() 3607*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3608*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color=", , , ")] 3609*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3610*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3611*e1fe3e4aSElliott Hughes self.tearDownUFO() 3612*e1fe3e4aSElliott Hughes ## not a number in all positions 3613*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3614*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="r, 1, 1, 1")] 3615*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3616*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3617*e1fe3e4aSElliott Hughes self.tearDownUFO() 3618*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3619*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, g, 1, 1")] 3620*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3621*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3622*e1fe3e4aSElliott Hughes self.tearDownUFO() 3623*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3624*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, 1, b, 1")] 3625*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3626*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3627*e1fe3e4aSElliott Hughes self.tearDownUFO() 3628*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3629*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, 1, 1, a")] 3630*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3631*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3632*e1fe3e4aSElliott Hughes self.tearDownUFO() 3633*e1fe3e4aSElliott Hughes ## too many parts 3634*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3635*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="1, 0, 0, 0, 0")] 3636*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3637*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3638*e1fe3e4aSElliott Hughes self.tearDownUFO() 3639*e1fe3e4aSElliott Hughes ## < 0 in each position 3640*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3641*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="-1, 0, 0, 0")] 3642*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3643*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3644*e1fe3e4aSElliott Hughes self.tearDownUFO() 3645*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3646*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, -1, 0, 0")] 3647*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3648*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3649*e1fe3e4aSElliott Hughes self.tearDownUFO() 3650*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3651*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, 0, -1, 0")] 3652*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3653*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3654*e1fe3e4aSElliott Hughes self.tearDownUFO() 3655*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3656*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, 0, 0, -1")] 3657*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3658*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3659*e1fe3e4aSElliott Hughes self.tearDownUFO() 3660*e1fe3e4aSElliott Hughes ## > 1 in each position 3661*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3662*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="2, 0, 0, 0")] 3663*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3664*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3665*e1fe3e4aSElliott Hughes self.tearDownUFO() 3666*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3667*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, 2, 0, 0")] 3668*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3669*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3670*e1fe3e4aSElliott Hughes self.tearDownUFO() 3671*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3672*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, 0, 2, 0")] 3673*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3674*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3675*e1fe3e4aSElliott Hughes self.tearDownUFO() 3676*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3677*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, color="0, 0, 0, 2")] 3678*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3679*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3680*e1fe3e4aSElliott Hughes self.tearDownUFO() 3681*e1fe3e4aSElliott Hughes # identifier 3682*e1fe3e4aSElliott Hughes ## duplicate 3683*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3684*e1fe3e4aSElliott Hughes infoObject.guidelines = [ 3685*e1fe3e4aSElliott Hughes dict(x=0, identifier="guide1"), 3686*e1fe3e4aSElliott Hughes dict(y=0, identifier="guide1"), 3687*e1fe3e4aSElliott Hughes ] 3688*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3689*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3690*e1fe3e4aSElliott Hughes self.tearDownUFO() 3691*e1fe3e4aSElliott Hughes ## below min 3692*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3693*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, identifier="\0x1F")] 3694*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3695*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3696*e1fe3e4aSElliott Hughes self.tearDownUFO() 3697*e1fe3e4aSElliott Hughes ## above max 3698*e1fe3e4aSElliott Hughes infoObject = self.makeInfoObject() 3699*e1fe3e4aSElliott Hughes infoObject.guidelines = [dict(x=0, identifier="\0x7F")] 3700*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 3701*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.writeInfo, info=infoObject) 3702*e1fe3e4aSElliott Hughes self.tearDownUFO() 3703*e1fe3e4aSElliott Hughes 3704*e1fe3e4aSElliott Hughes 3705*e1fe3e4aSElliott Hughes# ------ 3706*e1fe3e4aSElliott Hughes# layers 3707*e1fe3e4aSElliott Hughes# ------ 3708*e1fe3e4aSElliott Hughes 3709*e1fe3e4aSElliott Hughes 3710*e1fe3e4aSElliott Hughesclass UFO3ReadLayersTestCase(unittest.TestCase): 3711*e1fe3e4aSElliott Hughes def setUp(self): 3712*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 3713*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 3714*e1fe3e4aSElliott Hughes self.ufoPath = os.path.join(self.tempDir, "test.ufo") 3715*e1fe3e4aSElliott Hughes 3716*e1fe3e4aSElliott Hughes def tearDown(self): 3717*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 3718*e1fe3e4aSElliott Hughes 3719*e1fe3e4aSElliott Hughes def makeUFO(self, metaInfo=None, layerContents=None): 3720*e1fe3e4aSElliott Hughes self.clearUFO() 3721*e1fe3e4aSElliott Hughes if not os.path.exists(self.ufoPath): 3722*e1fe3e4aSElliott Hughes os.mkdir(self.ufoPath) 3723*e1fe3e4aSElliott Hughes # metainfo.plist 3724*e1fe3e4aSElliott Hughes if metaInfo is None: 3725*e1fe3e4aSElliott Hughes metaInfo = dict(creator="test", formatVersion=3) 3726*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "metainfo.plist") 3727*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3728*e1fe3e4aSElliott Hughes plistlib.dump(metaInfo, f) 3729*e1fe3e4aSElliott Hughes # layers 3730*e1fe3e4aSElliott Hughes if layerContents is None: 3731*e1fe3e4aSElliott Hughes layerContents = [ 3732*e1fe3e4aSElliott Hughes ("public.default", "glyphs"), 3733*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3734*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3735*e1fe3e4aSElliott Hughes ] 3736*e1fe3e4aSElliott Hughes if layerContents: 3737*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3738*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3739*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3740*e1fe3e4aSElliott Hughes else: 3741*e1fe3e4aSElliott Hughes layerContents = [("", "glyphs")] 3742*e1fe3e4aSElliott Hughes for name, directory in layerContents: 3743*e1fe3e4aSElliott Hughes glyphsPath = os.path.join(self.ufoPath, directory) 3744*e1fe3e4aSElliott Hughes os.mkdir(glyphsPath) 3745*e1fe3e4aSElliott Hughes contents = dict(a="a.glif") 3746*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "contents.plist") 3747*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3748*e1fe3e4aSElliott Hughes plistlib.dump(contents, f) 3749*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "a.glif") 3750*e1fe3e4aSElliott Hughes with open(path, "w") as f: 3751*e1fe3e4aSElliott Hughes f.write(" ") 3752*e1fe3e4aSElliott Hughes 3753*e1fe3e4aSElliott Hughes def clearUFO(self): 3754*e1fe3e4aSElliott Hughes if os.path.exists(self.ufoPath): 3755*e1fe3e4aSElliott Hughes shutil.rmtree(self.ufoPath) 3756*e1fe3e4aSElliott Hughes 3757*e1fe3e4aSElliott Hughes # valid 3758*e1fe3e4aSElliott Hughes 3759*e1fe3e4aSElliott Hughes def testValidRead(self): 3760*e1fe3e4aSElliott Hughes # UFO 1 3761*e1fe3e4aSElliott Hughes self.makeUFO( 3762*e1fe3e4aSElliott Hughes metaInfo=dict(creator="test", formatVersion=1), layerContents=dict() 3763*e1fe3e4aSElliott Hughes ) 3764*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3765*e1fe3e4aSElliott Hughes reader.getGlyphSet() 3766*e1fe3e4aSElliott Hughes # UFO 2 3767*e1fe3e4aSElliott Hughes self.makeUFO( 3768*e1fe3e4aSElliott Hughes metaInfo=dict(creator="test", formatVersion=2), layerContents=dict() 3769*e1fe3e4aSElliott Hughes ) 3770*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3771*e1fe3e4aSElliott Hughes reader.getGlyphSet() 3772*e1fe3e4aSElliott Hughes # UFO 3 3773*e1fe3e4aSElliott Hughes self.makeUFO() 3774*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3775*e1fe3e4aSElliott Hughes reader.getGlyphSet() 3776*e1fe3e4aSElliott Hughes 3777*e1fe3e4aSElliott Hughes # missing layer contents 3778*e1fe3e4aSElliott Hughes 3779*e1fe3e4aSElliott Hughes def testMissingLayerContents(self): 3780*e1fe3e4aSElliott Hughes self.makeUFO() 3781*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3782*e1fe3e4aSElliott Hughes os.remove(path) 3783*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3784*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3785*e1fe3e4aSElliott Hughes 3786*e1fe3e4aSElliott Hughes # layer contents invalid format 3787*e1fe3e4aSElliott Hughes 3788*e1fe3e4aSElliott Hughes def testInvalidLayerContentsFormat(self): 3789*e1fe3e4aSElliott Hughes # bogus 3790*e1fe3e4aSElliott Hughes self.makeUFO() 3791*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3792*e1fe3e4aSElliott Hughes os.remove(path) 3793*e1fe3e4aSElliott Hughes with open(path, "w") as f: 3794*e1fe3e4aSElliott Hughes f.write("test") 3795*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3796*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3797*e1fe3e4aSElliott Hughes # dict 3798*e1fe3e4aSElliott Hughes self.makeUFO() 3799*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3800*e1fe3e4aSElliott Hughes os.remove(path) 3801*e1fe3e4aSElliott Hughes layerContents = { 3802*e1fe3e4aSElliott Hughes "public.default": "glyphs", 3803*e1fe3e4aSElliott Hughes "layer 1": "glyphs.layer 1", 3804*e1fe3e4aSElliott Hughes "layer 2": "glyphs.layer 2", 3805*e1fe3e4aSElliott Hughes } 3806*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3807*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3808*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3809*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3810*e1fe3e4aSElliott Hughes 3811*e1fe3e4aSElliott Hughes # layer contents invalid name format 3812*e1fe3e4aSElliott Hughes 3813*e1fe3e4aSElliott Hughes def testInvalidLayerContentsNameFormat(self): 3814*e1fe3e4aSElliott Hughes self.makeUFO() 3815*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3816*e1fe3e4aSElliott Hughes os.remove(path) 3817*e1fe3e4aSElliott Hughes layerContents = [ 3818*e1fe3e4aSElliott Hughes (1, "glyphs"), 3819*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3820*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3821*e1fe3e4aSElliott Hughes ] 3822*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3823*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3824*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3825*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3826*e1fe3e4aSElliott Hughes 3827*e1fe3e4aSElliott Hughes # layer contents invalid directory format 3828*e1fe3e4aSElliott Hughes 3829*e1fe3e4aSElliott Hughes def testInvalidLayerContentsDirectoryFormat(self): 3830*e1fe3e4aSElliott Hughes self.makeUFO() 3831*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3832*e1fe3e4aSElliott Hughes os.remove(path) 3833*e1fe3e4aSElliott Hughes layerContents = [ 3834*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3835*e1fe3e4aSElliott Hughes ("layer 1", 1), 3836*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3837*e1fe3e4aSElliott Hughes ] 3838*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3839*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3840*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3841*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3842*e1fe3e4aSElliott Hughes 3843*e1fe3e4aSElliott Hughes # directory listed in contents not on disk 3844*e1fe3e4aSElliott Hughes 3845*e1fe3e4aSElliott Hughes def testLayerContentsHasMissingDirectory(self): 3846*e1fe3e4aSElliott Hughes self.makeUFO() 3847*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3848*e1fe3e4aSElliott Hughes os.remove(path) 3849*e1fe3e4aSElliott Hughes layerContents = [ 3850*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3851*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.doesnotexist"), 3852*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3853*e1fe3e4aSElliott Hughes ] 3854*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3855*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3856*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3857*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3858*e1fe3e4aSElliott Hughes 3859*e1fe3e4aSElliott Hughes # # directory on disk not listed in contents 3860*e1fe3e4aSElliott Hughes # XXX should this raise an error? 3861*e1fe3e4aSElliott Hughes # 3862*e1fe3e4aSElliott Hughes # def testLayerContentsHasMissingDirectory(self): 3863*e1fe3e4aSElliott Hughes # self.makeUFO() 3864*e1fe3e4aSElliott Hughes # path = os.path.join(self.ufoPath, "layercontents.plist") 3865*e1fe3e4aSElliott Hughes # os.remove(path) 3866*e1fe3e4aSElliott Hughes # layerContents = [ 3867*e1fe3e4aSElliott Hughes # ("public.foregound", "glyphs"), 3868*e1fe3e4aSElliott Hughes # ("layer 1", "glyphs.layer 2") 3869*e1fe3e4aSElliott Hughes # ] 3870*e1fe3e4aSElliott Hughes # with open(path, "wb") as f: 3871*e1fe3e4aSElliott Hughes # plistlib.dump(layerContents, f) 3872*e1fe3e4aSElliott Hughes # reader = UFOReader(self.ufoPath, validate=True) 3873*e1fe3e4aSElliott Hughes # with self.assertRaises(UFOLibError): 3874*e1fe3e4aSElliott Hughes # reader.getGlyphSet() 3875*e1fe3e4aSElliott Hughes 3876*e1fe3e4aSElliott Hughes # no default layer on disk 3877*e1fe3e4aSElliott Hughes 3878*e1fe3e4aSElliott Hughes def testMissingDefaultLayer(self): 3879*e1fe3e4aSElliott Hughes self.makeUFO() 3880*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3881*e1fe3e4aSElliott Hughes os.remove(path) 3882*e1fe3e4aSElliott Hughes layerContents = [("layer 1", "glyphs.layer 1"), ("layer 2", "glyphs.layer 2")] 3883*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3884*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3885*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3886*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3887*e1fe3e4aSElliott Hughes 3888*e1fe3e4aSElliott Hughes # duplicate layer name 3889*e1fe3e4aSElliott Hughes 3890*e1fe3e4aSElliott Hughes def testDuplicateLayerName(self): 3891*e1fe3e4aSElliott Hughes self.makeUFO() 3892*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3893*e1fe3e4aSElliott Hughes os.remove(path) 3894*e1fe3e4aSElliott Hughes layerContents = [ 3895*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3896*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3897*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 2"), 3898*e1fe3e4aSElliott Hughes ] 3899*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3900*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3901*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3902*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3903*e1fe3e4aSElliott Hughes 3904*e1fe3e4aSElliott Hughes # directory referenced by two layer names 3905*e1fe3e4aSElliott Hughes 3906*e1fe3e4aSElliott Hughes def testDuplicateLayerDirectory(self): 3907*e1fe3e4aSElliott Hughes self.makeUFO() 3908*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3909*e1fe3e4aSElliott Hughes os.remove(path) 3910*e1fe3e4aSElliott Hughes layerContents = [ 3911*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3912*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3913*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 1"), 3914*e1fe3e4aSElliott Hughes ] 3915*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3916*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3917*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3918*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, reader.getGlyphSet) 3919*e1fe3e4aSElliott Hughes 3920*e1fe3e4aSElliott Hughes # default without a name 3921*e1fe3e4aSElliott Hughes 3922*e1fe3e4aSElliott Hughes def testDefaultLayerNoName(self): 3923*e1fe3e4aSElliott Hughes # get the glyph set 3924*e1fe3e4aSElliott Hughes self.makeUFO() 3925*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3926*e1fe3e4aSElliott Hughes os.remove(path) 3927*e1fe3e4aSElliott Hughes layerContents = [ 3928*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3929*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3930*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3931*e1fe3e4aSElliott Hughes ] 3932*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3933*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3934*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3935*e1fe3e4aSElliott Hughes reader.getGlyphSet() 3936*e1fe3e4aSElliott Hughes 3937*e1fe3e4aSElliott Hughes # default with a name 3938*e1fe3e4aSElliott Hughes 3939*e1fe3e4aSElliott Hughes def testDefaultLayerName(self): 3940*e1fe3e4aSElliott Hughes # get the name 3941*e1fe3e4aSElliott Hughes self.makeUFO() 3942*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3943*e1fe3e4aSElliott Hughes os.remove(path) 3944*e1fe3e4aSElliott Hughes layerContents = [ 3945*e1fe3e4aSElliott Hughes ("custom name", "glyphs"), 3946*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3947*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3948*e1fe3e4aSElliott Hughes ] 3949*e1fe3e4aSElliott Hughes expected = layerContents[0][0] 3950*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3951*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3952*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3953*e1fe3e4aSElliott Hughes result = reader.getDefaultLayerName() 3954*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 3955*e1fe3e4aSElliott Hughes # get the glyph set 3956*e1fe3e4aSElliott Hughes self.makeUFO() 3957*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3958*e1fe3e4aSElliott Hughes os.remove(path) 3959*e1fe3e4aSElliott Hughes layerContents = [ 3960*e1fe3e4aSElliott Hughes ("custom name", "glyphs"), 3961*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3962*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3963*e1fe3e4aSElliott Hughes ] 3964*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3965*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3966*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3967*e1fe3e4aSElliott Hughes reader.getGlyphSet(expected) 3968*e1fe3e4aSElliott Hughes 3969*e1fe3e4aSElliott Hughes # layer order 3970*e1fe3e4aSElliott Hughes 3971*e1fe3e4aSElliott Hughes def testLayerOrder(self): 3972*e1fe3e4aSElliott Hughes self.makeUFO() 3973*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3974*e1fe3e4aSElliott Hughes os.remove(path) 3975*e1fe3e4aSElliott Hughes layerContents = [ 3976*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3977*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3978*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3979*e1fe3e4aSElliott Hughes ] 3980*e1fe3e4aSElliott Hughes expected = [name for (name, directory) in layerContents] 3981*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3982*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3983*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3984*e1fe3e4aSElliott Hughes result = reader.getLayerNames() 3985*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 3986*e1fe3e4aSElliott Hughes self.makeUFO() 3987*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 3988*e1fe3e4aSElliott Hughes os.remove(path) 3989*e1fe3e4aSElliott Hughes layerContents = [ 3990*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 3991*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 3992*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 3993*e1fe3e4aSElliott Hughes ] 3994*e1fe3e4aSElliott Hughes expected = [name for (name, directory) in layerContents] 3995*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 3996*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 3997*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 3998*e1fe3e4aSElliott Hughes result = reader.getLayerNames() 3999*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4000*e1fe3e4aSElliott Hughes self.makeUFO() 4001*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4002*e1fe3e4aSElliott Hughes os.remove(path) 4003*e1fe3e4aSElliott Hughes layerContents = [ 4004*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4005*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4006*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4007*e1fe3e4aSElliott Hughes ] 4008*e1fe3e4aSElliott Hughes expected = [name for (name, directory) in layerContents] 4009*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4010*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4011*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4012*e1fe3e4aSElliott Hughes result = reader.getLayerNames() 4013*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4014*e1fe3e4aSElliott Hughes 4015*e1fe3e4aSElliott Hughes 4016*e1fe3e4aSElliott Hughesclass UFO3WriteLayersTestCase(unittest.TestCase): 4017*e1fe3e4aSElliott Hughes def setUp(self): 4018*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 4019*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 4020*e1fe3e4aSElliott Hughes self.ufoPath = os.path.join(self.tempDir, "test.ufo") 4021*e1fe3e4aSElliott Hughes 4022*e1fe3e4aSElliott Hughes def tearDown(self): 4023*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 4024*e1fe3e4aSElliott Hughes 4025*e1fe3e4aSElliott Hughes def makeUFO(self, metaInfo=None, layerContents=None): 4026*e1fe3e4aSElliott Hughes self.clearUFO() 4027*e1fe3e4aSElliott Hughes if not os.path.exists(self.ufoPath): 4028*e1fe3e4aSElliott Hughes os.mkdir(self.ufoPath) 4029*e1fe3e4aSElliott Hughes # metainfo.plist 4030*e1fe3e4aSElliott Hughes if metaInfo is None: 4031*e1fe3e4aSElliott Hughes metaInfo = dict(creator="test", formatVersion=3) 4032*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "metainfo.plist") 4033*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4034*e1fe3e4aSElliott Hughes plistlib.dump(metaInfo, f) 4035*e1fe3e4aSElliott Hughes # layers 4036*e1fe3e4aSElliott Hughes if layerContents is None: 4037*e1fe3e4aSElliott Hughes layerContents = [ 4038*e1fe3e4aSElliott Hughes ("public.default", "glyphs"), 4039*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4040*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4041*e1fe3e4aSElliott Hughes ] 4042*e1fe3e4aSElliott Hughes if layerContents: 4043*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4044*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4045*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4046*e1fe3e4aSElliott Hughes else: 4047*e1fe3e4aSElliott Hughes layerContents = [("", "glyphs")] 4048*e1fe3e4aSElliott Hughes for name, directory in layerContents: 4049*e1fe3e4aSElliott Hughes glyphsPath = os.path.join(self.ufoPath, directory) 4050*e1fe3e4aSElliott Hughes os.mkdir(glyphsPath) 4051*e1fe3e4aSElliott Hughes contents = dict(a="a.glif") 4052*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "contents.plist") 4053*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4054*e1fe3e4aSElliott Hughes plistlib.dump(contents, f) 4055*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "a.glif") 4056*e1fe3e4aSElliott Hughes with open(path, "w") as f: 4057*e1fe3e4aSElliott Hughes f.write(" ") 4058*e1fe3e4aSElliott Hughes 4059*e1fe3e4aSElliott Hughes def clearUFO(self): 4060*e1fe3e4aSElliott Hughes if os.path.exists(self.ufoPath): 4061*e1fe3e4aSElliott Hughes shutil.rmtree(self.ufoPath) 4062*e1fe3e4aSElliott Hughes 4063*e1fe3e4aSElliott Hughes # __init__: missing layer contents 4064*e1fe3e4aSElliott Hughes 4065*e1fe3e4aSElliott Hughes def testMissingLayerContents(self): 4066*e1fe3e4aSElliott Hughes self.makeUFO() 4067*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4068*e1fe3e4aSElliott Hughes os.remove(path) 4069*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4070*e1fe3e4aSElliott Hughes 4071*e1fe3e4aSElliott Hughes # __init__: layer contents invalid format 4072*e1fe3e4aSElliott Hughes 4073*e1fe3e4aSElliott Hughes def testInvalidLayerContentsFormat(self): 4074*e1fe3e4aSElliott Hughes # bogus 4075*e1fe3e4aSElliott Hughes self.makeUFO() 4076*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4077*e1fe3e4aSElliott Hughes os.remove(path) 4078*e1fe3e4aSElliott Hughes with open(path, "w") as f: 4079*e1fe3e4aSElliott Hughes f.write("test") 4080*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4081*e1fe3e4aSElliott Hughes # dict 4082*e1fe3e4aSElliott Hughes self.makeUFO() 4083*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4084*e1fe3e4aSElliott Hughes os.remove(path) 4085*e1fe3e4aSElliott Hughes layerContents = { 4086*e1fe3e4aSElliott Hughes "public.default": "glyphs", 4087*e1fe3e4aSElliott Hughes "layer 1": "glyphs.layer 1", 4088*e1fe3e4aSElliott Hughes "layer 2": "glyphs.layer 2", 4089*e1fe3e4aSElliott Hughes } 4090*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4091*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4092*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4093*e1fe3e4aSElliott Hughes 4094*e1fe3e4aSElliott Hughes # __init__: layer contents invalid name format 4095*e1fe3e4aSElliott Hughes 4096*e1fe3e4aSElliott Hughes def testInvalidLayerContentsNameFormat(self): 4097*e1fe3e4aSElliott Hughes self.makeUFO() 4098*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4099*e1fe3e4aSElliott Hughes os.remove(path) 4100*e1fe3e4aSElliott Hughes layerContents = [ 4101*e1fe3e4aSElliott Hughes (1, "glyphs"), 4102*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4103*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4104*e1fe3e4aSElliott Hughes ] 4105*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4106*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4107*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4108*e1fe3e4aSElliott Hughes 4109*e1fe3e4aSElliott Hughes # __init__: layer contents invalid directory format 4110*e1fe3e4aSElliott Hughes 4111*e1fe3e4aSElliott Hughes def testInvalidLayerContentsDirectoryFormat(self): 4112*e1fe3e4aSElliott Hughes self.makeUFO() 4113*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4114*e1fe3e4aSElliott Hughes os.remove(path) 4115*e1fe3e4aSElliott Hughes layerContents = [ 4116*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4117*e1fe3e4aSElliott Hughes ("layer 1", 1), 4118*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4119*e1fe3e4aSElliott Hughes ] 4120*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4121*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4122*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4123*e1fe3e4aSElliott Hughes 4124*e1fe3e4aSElliott Hughes # __init__: directory listed in contents not on disk 4125*e1fe3e4aSElliott Hughes 4126*e1fe3e4aSElliott Hughes def testLayerContentsHasMissingDirectory(self): 4127*e1fe3e4aSElliott Hughes self.makeUFO() 4128*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4129*e1fe3e4aSElliott Hughes os.remove(path) 4130*e1fe3e4aSElliott Hughes layerContents = [ 4131*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4132*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.doesnotexist"), 4133*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4134*e1fe3e4aSElliott Hughes ] 4135*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4136*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4137*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4138*e1fe3e4aSElliott Hughes 4139*e1fe3e4aSElliott Hughes # __init__: no default layer on disk 4140*e1fe3e4aSElliott Hughes 4141*e1fe3e4aSElliott Hughes def testMissingDefaultLayer(self): 4142*e1fe3e4aSElliott Hughes self.makeUFO() 4143*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4144*e1fe3e4aSElliott Hughes os.remove(path) 4145*e1fe3e4aSElliott Hughes layerContents = [("layer 1", "glyphs.layer 1"), ("layer 2", "glyphs.layer 2")] 4146*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4147*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4148*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4149*e1fe3e4aSElliott Hughes 4150*e1fe3e4aSElliott Hughes # __init__: duplicate layer name 4151*e1fe3e4aSElliott Hughes 4152*e1fe3e4aSElliott Hughes def testDuplicateLayerName(self): 4153*e1fe3e4aSElliott Hughes self.makeUFO() 4154*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4155*e1fe3e4aSElliott Hughes os.remove(path) 4156*e1fe3e4aSElliott Hughes layerContents = [ 4157*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4158*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4159*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 2"), 4160*e1fe3e4aSElliott Hughes ] 4161*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4162*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4163*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4164*e1fe3e4aSElliott Hughes 4165*e1fe3e4aSElliott Hughes # __init__: directory referenced by two layer names 4166*e1fe3e4aSElliott Hughes 4167*e1fe3e4aSElliott Hughes def testDuplicateLayerDirectory(self): 4168*e1fe3e4aSElliott Hughes self.makeUFO() 4169*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4170*e1fe3e4aSElliott Hughes os.remove(path) 4171*e1fe3e4aSElliott Hughes layerContents = [ 4172*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4173*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4174*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 1"), 4175*e1fe3e4aSElliott Hughes ] 4176*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4177*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4178*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath) 4179*e1fe3e4aSElliott Hughes 4180*e1fe3e4aSElliott Hughes # __init__: default without a name 4181*e1fe3e4aSElliott Hughes 4182*e1fe3e4aSElliott Hughes def testDefaultLayerNoName(self): 4183*e1fe3e4aSElliott Hughes # get the glyph set 4184*e1fe3e4aSElliott Hughes self.makeUFO() 4185*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4186*e1fe3e4aSElliott Hughes os.remove(path) 4187*e1fe3e4aSElliott Hughes layerContents = [ 4188*e1fe3e4aSElliott Hughes ("public.foregound", "glyphs"), 4189*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4190*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4191*e1fe3e4aSElliott Hughes ] 4192*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4193*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4194*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4195*e1fe3e4aSElliott Hughes 4196*e1fe3e4aSElliott Hughes # __init__: default with a name 4197*e1fe3e4aSElliott Hughes 4198*e1fe3e4aSElliott Hughes def testDefaultLayerName(self): 4199*e1fe3e4aSElliott Hughes self.makeUFO() 4200*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4201*e1fe3e4aSElliott Hughes os.remove(path) 4202*e1fe3e4aSElliott Hughes layerContents = [ 4203*e1fe3e4aSElliott Hughes ("custom name", "glyphs"), 4204*e1fe3e4aSElliott Hughes ("layer 1", "glyphs.layer 1"), 4205*e1fe3e4aSElliott Hughes ("layer 2", "glyphs.layer 2"), 4206*e1fe3e4aSElliott Hughes ] 4207*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4208*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4209*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4210*e1fe3e4aSElliott Hughes 4211*e1fe3e4aSElliott Hughes # __init__: up convert 1 > 3 4212*e1fe3e4aSElliott Hughes 4213*e1fe3e4aSElliott Hughes def testUpConvert1To3(self): 4214*e1fe3e4aSElliott Hughes self.makeUFO( 4215*e1fe3e4aSElliott Hughes metaInfo=dict(creator="test", formatVersion=1), layerContents=dict() 4216*e1fe3e4aSElliott Hughes ) 4217*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4218*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default"]) 4219*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4220*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4221*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4222*e1fe3e4aSElliott Hughes expected = [["public.default", "glyphs"]] 4223*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4224*e1fe3e4aSElliott Hughes 4225*e1fe3e4aSElliott Hughes # __init__: up convert 2 > 3 4226*e1fe3e4aSElliott Hughes 4227*e1fe3e4aSElliott Hughes def testUpConvert2To3(self): 4228*e1fe3e4aSElliott Hughes self.makeUFO( 4229*e1fe3e4aSElliott Hughes metaInfo=dict(creator="test", formatVersion=2), layerContents=dict() 4230*e1fe3e4aSElliott Hughes ) 4231*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4232*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default"]) 4233*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4234*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4235*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4236*e1fe3e4aSElliott Hughes expected = [["public.default", "glyphs"]] 4237*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4238*e1fe3e4aSElliott Hughes 4239*e1fe3e4aSElliott Hughes # __init__: down convert 3 > 1 4240*e1fe3e4aSElliott Hughes 4241*e1fe3e4aSElliott Hughes def testDownConvert3To1(self): 4242*e1fe3e4aSElliott Hughes self.makeUFO() 4243*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath, formatVersion=1) 4244*e1fe3e4aSElliott Hughes 4245*e1fe3e4aSElliott Hughes # __init__: down convert 3 > 2 4246*e1fe3e4aSElliott Hughes 4247*e1fe3e4aSElliott Hughes def testDownConvert3To2(self): 4248*e1fe3e4aSElliott Hughes self.makeUFO() 4249*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, UFOWriter, self.ufoPath, formatVersion=2) 4250*e1fe3e4aSElliott Hughes 4251*e1fe3e4aSElliott Hughes # get glyph sets 4252*e1fe3e4aSElliott Hughes 4253*e1fe3e4aSElliott Hughes def testGetGlyphSets(self): 4254*e1fe3e4aSElliott Hughes self.makeUFO() 4255*e1fe3e4aSElliott Hughes # hack contents.plist 4256*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1", "contents.plist") 4257*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4258*e1fe3e4aSElliott Hughes plistlib.dump(dict(b="a.glif"), f) 4259*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2", "contents.plist") 4260*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4261*e1fe3e4aSElliott Hughes plistlib.dump(dict(c="a.glif"), f) 4262*e1fe3e4aSElliott Hughes # now test 4263*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4264*e1fe3e4aSElliott Hughes # default 4265*e1fe3e4aSElliott Hughes expected = ["a"] 4266*e1fe3e4aSElliott Hughes result = list(writer.getGlyphSet().keys()) 4267*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4268*e1fe3e4aSElliott Hughes # layer 1 4269*e1fe3e4aSElliott Hughes expected = ["b"] 4270*e1fe3e4aSElliott Hughes result = list(writer.getGlyphSet("layer 1", defaultLayer=False).keys()) 4271*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4272*e1fe3e4aSElliott Hughes # layer 2 4273*e1fe3e4aSElliott Hughes expected = ["c"] 4274*e1fe3e4aSElliott Hughes result = list(writer.getGlyphSet("layer 2", defaultLayer=False).keys()) 4275*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4276*e1fe3e4aSElliott Hughes 4277*e1fe3e4aSElliott Hughes def testGetGlyphSetNoContents(self): 4278*e1fe3e4aSElliott Hughes self.makeUFO() 4279*e1fe3e4aSElliott Hughes os.remove(os.path.join(self.ufoPath, "glyphs.layer 1", "contents.plist")) 4280*e1fe3e4aSElliott Hughes 4281*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4282*e1fe3e4aSElliott Hughes with self.assertRaises(GlifLibError): 4283*e1fe3e4aSElliott Hughes reader.getGlyphSet("layer 1") 4284*e1fe3e4aSElliott Hughes 4285*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath, validate=True) 4286*e1fe3e4aSElliott Hughes with self.assertRaises(GlifLibError): 4287*e1fe3e4aSElliott Hughes writer.getGlyphSet("layer 1", defaultLayer=False, expectContentsFile=True) 4288*e1fe3e4aSElliott Hughes 4289*e1fe3e4aSElliott Hughes # There's a separate code path for < v3 UFOs. 4290*e1fe3e4aSElliott Hughes with open(os.path.join(self.ufoPath, "metainfo.plist"), "wb") as f: 4291*e1fe3e4aSElliott Hughes plistlib.dump(dict(creator="test", formatVersion=2), f) 4292*e1fe3e4aSElliott Hughes os.remove(os.path.join(self.ufoPath, "glyphs", "contents.plist")) 4293*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath, validate=True, formatVersion=2) 4294*e1fe3e4aSElliott Hughes with self.assertRaises(GlifLibError): 4295*e1fe3e4aSElliott Hughes writer.getGlyphSet(expectContentsFile=True) 4296*e1fe3e4aSElliott Hughes 4297*e1fe3e4aSElliott Hughes # make a new font with two layers 4298*e1fe3e4aSElliott Hughes 4299*e1fe3e4aSElliott Hughes def testNewFontOneLayer(self): 4300*e1fe3e4aSElliott Hughes self.clearUFO() 4301*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4302*e1fe3e4aSElliott Hughes writer.getGlyphSet() 4303*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default"]) 4304*e1fe3e4aSElliott Hughes # directory 4305*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4306*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4307*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4308*e1fe3e4aSElliott Hughes # layer contents 4309*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4310*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4311*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4312*e1fe3e4aSElliott Hughes expected = [["public.default", "glyphs"]] 4313*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4314*e1fe3e4aSElliott Hughes 4315*e1fe3e4aSElliott Hughes def testNewFontThreeLayers(self): 4316*e1fe3e4aSElliott Hughes self.clearUFO() 4317*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4318*e1fe3e4aSElliott Hughes writer.getGlyphSet("layer 1", defaultLayer=False) 4319*e1fe3e4aSElliott Hughes writer.getGlyphSet() 4320*e1fe3e4aSElliott Hughes writer.getGlyphSet("layer 2", defaultLayer=False) 4321*e1fe3e4aSElliott Hughes writer.writeLayerContents(["layer 1", "public.default", "layer 2"]) 4322*e1fe3e4aSElliott Hughes # directories 4323*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4324*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4325*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4326*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4327*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4328*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4329*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4330*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4331*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4332*e1fe3e4aSElliott Hughes # layer contents 4333*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4334*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4335*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4336*e1fe3e4aSElliott Hughes expected = [ 4337*e1fe3e4aSElliott Hughes ["layer 1", "glyphs.layer 1"], 4338*e1fe3e4aSElliott Hughes ["public.default", "glyphs"], 4339*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4340*e1fe3e4aSElliott Hughes ] 4341*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4342*e1fe3e4aSElliott Hughes 4343*e1fe3e4aSElliott Hughes # add a layer to an existing font 4344*e1fe3e4aSElliott Hughes 4345*e1fe3e4aSElliott Hughes def testAddLayerToExistingFont(self): 4346*e1fe3e4aSElliott Hughes self.makeUFO() 4347*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4348*e1fe3e4aSElliott Hughes writer.getGlyphSet("layer 3", defaultLayer=False) 4349*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default", "layer 1", "layer 2", "layer 3"]) 4350*e1fe3e4aSElliott Hughes # directories 4351*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4352*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4353*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4354*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4355*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4356*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4357*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4358*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4359*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4360*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 3") 4361*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4362*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4363*e1fe3e4aSElliott Hughes # layer contents 4364*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4365*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4366*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4367*e1fe3e4aSElliott Hughes expected = [ 4368*e1fe3e4aSElliott Hughes ["public.default", "glyphs"], 4369*e1fe3e4aSElliott Hughes ["layer 1", "glyphs.layer 1"], 4370*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4371*e1fe3e4aSElliott Hughes ["layer 3", "glyphs.layer 3"], 4372*e1fe3e4aSElliott Hughes ] 4373*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4374*e1fe3e4aSElliott Hughes 4375*e1fe3e4aSElliott Hughes # rename valid name 4376*e1fe3e4aSElliott Hughes 4377*e1fe3e4aSElliott Hughes def testRenameLayer(self): 4378*e1fe3e4aSElliott Hughes self.makeUFO() 4379*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4380*e1fe3e4aSElliott Hughes writer.renameGlyphSet("layer 1", "layer 3") 4381*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default", "layer 3", "layer 2"]) 4382*e1fe3e4aSElliott Hughes # directories 4383*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4384*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4385*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4386*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4387*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4388*e1fe3e4aSElliott Hughes self.assertEqual(False, exists) 4389*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4390*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4391*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4392*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 3") 4393*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4394*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4395*e1fe3e4aSElliott Hughes # layer contents 4396*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4397*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4398*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4399*e1fe3e4aSElliott Hughes expected = [ 4400*e1fe3e4aSElliott Hughes ["public.default", "glyphs"], 4401*e1fe3e4aSElliott Hughes ["layer 3", "glyphs.layer 3"], 4402*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4403*e1fe3e4aSElliott Hughes ] 4404*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4405*e1fe3e4aSElliott Hughes 4406*e1fe3e4aSElliott Hughes def testRenameLayerDefault(self): 4407*e1fe3e4aSElliott Hughes self.makeUFO() 4408*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4409*e1fe3e4aSElliott Hughes writer.renameGlyphSet("public.default", "layer xxx") 4410*e1fe3e4aSElliott Hughes writer.renameGlyphSet("layer 1", "layer 1", defaultLayer=True) 4411*e1fe3e4aSElliott Hughes writer.writeLayerContents(["layer xxx", "layer 1", "layer 2"]) 4412*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4413*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4414*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4415*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4416*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4417*e1fe3e4aSElliott Hughes self.assertEqual(False, exists) 4418*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4419*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4420*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4421*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer xxx") 4422*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4423*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4424*e1fe3e4aSElliott Hughes # layer contents 4425*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4426*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4427*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4428*e1fe3e4aSElliott Hughes expected = [ 4429*e1fe3e4aSElliott Hughes ["layer xxx", "glyphs.layer xxx"], 4430*e1fe3e4aSElliott Hughes ["layer 1", "glyphs"], 4431*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4432*e1fe3e4aSElliott Hughes ] 4433*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4434*e1fe3e4aSElliott Hughes 4435*e1fe3e4aSElliott Hughes # rename duplicate name 4436*e1fe3e4aSElliott Hughes 4437*e1fe3e4aSElliott Hughes def testRenameLayerDuplicateName(self): 4438*e1fe3e4aSElliott Hughes self.makeUFO() 4439*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4440*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.renameGlyphSet, "layer 1", "layer 2") 4441*e1fe3e4aSElliott Hughes 4442*e1fe3e4aSElliott Hughes # rename unknown layer 4443*e1fe3e4aSElliott Hughes 4444*e1fe3e4aSElliott Hughes def testRenameLayerUnknownName(self): 4445*e1fe3e4aSElliott Hughes self.makeUFO() 4446*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4447*e1fe3e4aSElliott Hughes self.assertRaises( 4448*e1fe3e4aSElliott Hughes UFOLibError, writer.renameGlyphSet, "does not exist", "layer 2" 4449*e1fe3e4aSElliott Hughes ) 4450*e1fe3e4aSElliott Hughes 4451*e1fe3e4aSElliott Hughes # remove valid layer 4452*e1fe3e4aSElliott Hughes 4453*e1fe3e4aSElliott Hughes def testRemoveLayer(self): 4454*e1fe3e4aSElliott Hughes self.makeUFO() 4455*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4456*e1fe3e4aSElliott Hughes writer.deleteGlyphSet("layer 1") 4457*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default", "layer 2"]) 4458*e1fe3e4aSElliott Hughes # directories 4459*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4460*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4461*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4462*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4463*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4464*e1fe3e4aSElliott Hughes self.assertEqual(False, exists) 4465*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4466*e1fe3e4aSElliott Hughes exists = os.path.exists(path) 4467*e1fe3e4aSElliott Hughes self.assertEqual(True, exists) 4468*e1fe3e4aSElliott Hughes # layer contents 4469*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4470*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4471*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4472*e1fe3e4aSElliott Hughes expected = [["public.default", "glyphs"], ["layer 2", "glyphs.layer 2"]] 4473*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4474*e1fe3e4aSElliott Hughes 4475*e1fe3e4aSElliott Hughes # remove default layer 4476*e1fe3e4aSElliott Hughes 4477*e1fe3e4aSElliott Hughes def testRemoveDefaultLayer(self): 4478*e1fe3e4aSElliott Hughes self.makeUFO() 4479*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4480*e1fe3e4aSElliott Hughes writer.deleteGlyphSet("public.default") 4481*e1fe3e4aSElliott Hughes writer.writeLayerContents(["layer 1", "layer 2"]) 4482*e1fe3e4aSElliott Hughes # directories 4483*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs") 4484*e1fe3e4aSElliott Hughes self.assertEqual(False, os.path.exists(path)) 4485*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 1") 4486*e1fe3e4aSElliott Hughes self.assertEqual(True, os.path.exists(path)) 4487*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs.layer 2") 4488*e1fe3e4aSElliott Hughes self.assertEqual(True, os.path.exists(path)) 4489*e1fe3e4aSElliott Hughes # layer contents 4490*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4491*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4492*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4493*e1fe3e4aSElliott Hughes expected = [["layer 1", "glyphs.layer 1"], ["layer 2", "glyphs.layer 2"]] 4494*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4495*e1fe3e4aSElliott Hughes 4496*e1fe3e4aSElliott Hughes # remove unknown layer 4497*e1fe3e4aSElliott Hughes 4498*e1fe3e4aSElliott Hughes def testRemoveDefaultLayer2(self): 4499*e1fe3e4aSElliott Hughes self.makeUFO() 4500*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4501*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, writer.deleteGlyphSet, "does not exist") 4502*e1fe3e4aSElliott Hughes 4503*e1fe3e4aSElliott Hughes def testWriteAsciiLayerOrder(self): 4504*e1fe3e4aSElliott Hughes self.makeUFO( 4505*e1fe3e4aSElliott Hughes layerContents=[ 4506*e1fe3e4aSElliott Hughes ["public.default", "glyphs"], 4507*e1fe3e4aSElliott Hughes ["layer 1", "glyphs.layer 1"], 4508*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4509*e1fe3e4aSElliott Hughes ] 4510*e1fe3e4aSElliott Hughes ) 4511*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4512*e1fe3e4aSElliott Hughes writer.writeLayerContents(["public.default", "layer 2", "layer 1"]) 4513*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4514*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4515*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4516*e1fe3e4aSElliott Hughes expected = [ 4517*e1fe3e4aSElliott Hughes ["public.default", "glyphs"], 4518*e1fe3e4aSElliott Hughes ["layer 2", "glyphs.layer 2"], 4519*e1fe3e4aSElliott Hughes ["layer 1", "glyphs.layer 1"], 4520*e1fe3e4aSElliott Hughes ] 4521*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4522*e1fe3e4aSElliott Hughes for layerName, _ in result: 4523*e1fe3e4aSElliott Hughes assert isinstance(layerName, str) 4524*e1fe3e4aSElliott Hughes 4525*e1fe3e4aSElliott Hughes 4526*e1fe3e4aSElliott Hughes# ----- 4527*e1fe3e4aSElliott Hughes# /data 4528*e1fe3e4aSElliott Hughes# ----- 4529*e1fe3e4aSElliott Hughes 4530*e1fe3e4aSElliott Hughes 4531*e1fe3e4aSElliott Hughesclass UFO3ReadDataTestCase(unittest.TestCase): 4532*e1fe3e4aSElliott Hughes def getFontPath(self): 4533*e1fe3e4aSElliott Hughes testdata = os.path.join(os.path.dirname(__file__), "testdata") 4534*e1fe3e4aSElliott Hughes return os.path.join(testdata, "UFO3-Read Data.ufo") 4535*e1fe3e4aSElliott Hughes 4536*e1fe3e4aSElliott Hughes def testUFOReaderDataDirectoryListing(self): 4537*e1fe3e4aSElliott Hughes reader = UFOReader(self.getFontPath()) 4538*e1fe3e4aSElliott Hughes found = reader.getDataDirectoryListing() 4539*e1fe3e4aSElliott Hughes expected = [ 4540*e1fe3e4aSElliott Hughes "org.unifiedfontobject.directory/bar/lol.txt", 4541*e1fe3e4aSElliott Hughes "org.unifiedfontobject.directory/foo.txt", 4542*e1fe3e4aSElliott Hughes "org.unifiedfontobject.file.txt", 4543*e1fe3e4aSElliott Hughes ] 4544*e1fe3e4aSElliott Hughes self.assertEqual(set(found), set(expected)) 4545*e1fe3e4aSElliott Hughes 4546*e1fe3e4aSElliott Hughes def testUFOReaderBytesFromPath(self): 4547*e1fe3e4aSElliott Hughes reader = UFOReader(self.getFontPath()) 4548*e1fe3e4aSElliott Hughes found = reader.readBytesFromPath("data/org.unifiedfontobject.file.txt") 4549*e1fe3e4aSElliott Hughes expected = b"file.txt" 4550*e1fe3e4aSElliott Hughes self.assertEqual(found, expected) 4551*e1fe3e4aSElliott Hughes found = reader.readBytesFromPath( 4552*e1fe3e4aSElliott Hughes "data/org.unifiedfontobject.directory/bar/lol.txt" 4553*e1fe3e4aSElliott Hughes ) 4554*e1fe3e4aSElliott Hughes expected = b"lol.txt" 4555*e1fe3e4aSElliott Hughes self.assertEqual(found, expected) 4556*e1fe3e4aSElliott Hughes found = reader.readBytesFromPath("data/org.unifiedfontobject.doesNotExist") 4557*e1fe3e4aSElliott Hughes expected = None 4558*e1fe3e4aSElliott Hughes self.assertEqual(found, expected) 4559*e1fe3e4aSElliott Hughes 4560*e1fe3e4aSElliott Hughes def testUFOReaderReadFileFromPath(self): 4561*e1fe3e4aSElliott Hughes reader = UFOReader(self.getFontPath()) 4562*e1fe3e4aSElliott Hughes fileObject = reader.getReadFileForPath("data/org.unifiedfontobject.file.txt") 4563*e1fe3e4aSElliott Hughes self.assertNotEqual(fileObject, None) 4564*e1fe3e4aSElliott Hughes hasRead = hasattr(fileObject, "read") 4565*e1fe3e4aSElliott Hughes self.assertEqual(hasRead, True) 4566*e1fe3e4aSElliott Hughes fileObject.close() 4567*e1fe3e4aSElliott Hughes fileObject = reader.getReadFileForPath( 4568*e1fe3e4aSElliott Hughes "data/org.unifiedfontobject.doesNotExist" 4569*e1fe3e4aSElliott Hughes ) 4570*e1fe3e4aSElliott Hughes self.assertEqual(fileObject, None) 4571*e1fe3e4aSElliott Hughes 4572*e1fe3e4aSElliott Hughes def testUFOReaderKernGroupDuplicatesRemoved(self): 4573*e1fe3e4aSElliott Hughes # Non-kerning group duplicates are kept 4574*e1fe3e4aSElliott Hughes # Kerning group duplicates are removed 4575*e1fe3e4aSElliott Hughes expected_groups = { 4576*e1fe3e4aSElliott Hughes "group1": ["A"], 4577*e1fe3e4aSElliott Hughes "group2": ["B", "C", "B"], 4578*e1fe3e4aSElliott Hughes "public.kern1.A": ["A"], 4579*e1fe3e4aSElliott Hughes "public.kern2.B": ["B", "A", "C"], 4580*e1fe3e4aSElliott Hughes } 4581*e1fe3e4aSElliott Hughes reader = UFOReader(self.getFontPath()) 4582*e1fe3e4aSElliott Hughes groups = reader.readGroups() 4583*e1fe3e4aSElliott Hughes self.assertEqual(expected_groups, groups) 4584*e1fe3e4aSElliott Hughes 4585*e1fe3e4aSElliott Hughes 4586*e1fe3e4aSElliott Hughesclass UFO3WriteDataTestCase(unittest.TestCase): 4587*e1fe3e4aSElliott Hughes def setUp(self): 4588*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 4589*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 4590*e1fe3e4aSElliott Hughes self.dstDir = os.path.join(self.tempDir, "test.ufo") 4591*e1fe3e4aSElliott Hughes 4592*e1fe3e4aSElliott Hughes def tearDown(self): 4593*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 4594*e1fe3e4aSElliott Hughes 4595*e1fe3e4aSElliott Hughes def tearDownUFO(self): 4596*e1fe3e4aSElliott Hughes if os.path.exists(self.dstDir): 4597*e1fe3e4aSElliott Hughes shutil.rmtree(self.dstDir) 4598*e1fe3e4aSElliott Hughes 4599*e1fe3e4aSElliott Hughes def testUFOWriterWriteBytesToPath(self): 4600*e1fe3e4aSElliott Hughes # basic file 4601*e1fe3e4aSElliott Hughes path = "data/org.unifiedfontobject.writebytesbasicfile.txt" 4602*e1fe3e4aSElliott Hughes testBytes = b"test" 4603*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4604*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path, testBytes) 4605*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, path) 4606*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(path), True) 4607*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4608*e1fe3e4aSElliott Hughes written = f.read() 4609*e1fe3e4aSElliott Hughes self.assertEqual(testBytes, written) 4610*e1fe3e4aSElliott Hughes self.tearDownUFO() 4611*e1fe3e4aSElliott Hughes # basic file with unicode text 4612*e1fe3e4aSElliott Hughes path = "data/org.unifiedfontobject.writebytesbasicunicodefile.txt" 4613*e1fe3e4aSElliott Hughes text = b"t\xeb\xdft" 4614*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4615*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path, text) 4616*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, path) 4617*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(path), True) 4618*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4619*e1fe3e4aSElliott Hughes written = f.read() 4620*e1fe3e4aSElliott Hughes self.assertEqual(text, written) 4621*e1fe3e4aSElliott Hughes self.tearDownUFO() 4622*e1fe3e4aSElliott Hughes # basic directory 4623*e1fe3e4aSElliott Hughes path = "data/org.unifiedfontobject.writebytesdirectory/level1/level2/file.txt" 4624*e1fe3e4aSElliott Hughes testBytes = b"test" 4625*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4626*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path, testBytes) 4627*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, path) 4628*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(path), True) 4629*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4630*e1fe3e4aSElliott Hughes written = f.read() 4631*e1fe3e4aSElliott Hughes self.assertEqual(testBytes, written) 4632*e1fe3e4aSElliott Hughes self.tearDownUFO() 4633*e1fe3e4aSElliott Hughes 4634*e1fe3e4aSElliott Hughes def testUFOWriterWriteFileToPath(self): 4635*e1fe3e4aSElliott Hughes # basic file 4636*e1fe3e4aSElliott Hughes path = "data/org.unifiedfontobject.getwritefile.txt" 4637*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4638*e1fe3e4aSElliott Hughes fileObject = writer.getFileObjectForPath(path) 4639*e1fe3e4aSElliott Hughes self.assertNotEqual(fileObject, None) 4640*e1fe3e4aSElliott Hughes hasRead = hasattr(fileObject, "read") 4641*e1fe3e4aSElliott Hughes self.assertEqual(hasRead, True) 4642*e1fe3e4aSElliott Hughes fileObject.close() 4643*e1fe3e4aSElliott Hughes self.tearDownUFO() 4644*e1fe3e4aSElliott Hughes 4645*e1fe3e4aSElliott Hughes def testUFOWriterRemoveFile(self): 4646*e1fe3e4aSElliott Hughes path1 = "data/org.unifiedfontobject.removefile/level1/level2/file1.txt" 4647*e1fe3e4aSElliott Hughes path2 = "data/org.unifiedfontobject.removefile/level1/level2/file2.txt" 4648*e1fe3e4aSElliott Hughes path3 = "data/org.unifiedfontobject.removefile/level1/file3.txt" 4649*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4650*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path1, b"test") 4651*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path2, b"test") 4652*e1fe3e4aSElliott Hughes writer.writeBytesToPath(path3, b"test") 4653*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path1)), True) 4654*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path2)), True) 4655*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path3)), True) 4656*e1fe3e4aSElliott Hughes writer.removeFileForPath(path1) 4657*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path1)), False) 4658*e1fe3e4aSElliott Hughes self.assertEqual( 4659*e1fe3e4aSElliott Hughes os.path.exists(os.path.dirname(os.path.join(self.dstDir, path1))), True 4660*e1fe3e4aSElliott Hughes ) 4661*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path2)), True) 4662*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path3)), True) 4663*e1fe3e4aSElliott Hughes writer.removeFileForPath(path2) 4664*e1fe3e4aSElliott Hughes self.assertEqual( 4665*e1fe3e4aSElliott Hughes os.path.exists(os.path.dirname(os.path.join(self.dstDir, path1))), False 4666*e1fe3e4aSElliott Hughes ) 4667*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path2)), False) 4668*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path3)), True) 4669*e1fe3e4aSElliott Hughes writer.removeFileForPath(path3) 4670*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(os.path.join(self.dstDir, path3)), False) 4671*e1fe3e4aSElliott Hughes self.assertEqual( 4672*e1fe3e4aSElliott Hughes os.path.exists(os.path.dirname(os.path.join(self.dstDir, path2))), False 4673*e1fe3e4aSElliott Hughes ) 4674*e1fe3e4aSElliott Hughes self.assertEqual( 4675*e1fe3e4aSElliott Hughes os.path.exists( 4676*e1fe3e4aSElliott Hughes os.path.join(self.dstDir, "data/org.unifiedfontobject.removefile") 4677*e1fe3e4aSElliott Hughes ), 4678*e1fe3e4aSElliott Hughes False, 4679*e1fe3e4aSElliott Hughes ) 4680*e1fe3e4aSElliott Hughes self.assertRaises( 4681*e1fe3e4aSElliott Hughes UFOLibError, 4682*e1fe3e4aSElliott Hughes writer.removeFileForPath, 4683*e1fe3e4aSElliott Hughes path="data/org.unifiedfontobject.doesNotExist.txt", 4684*e1fe3e4aSElliott Hughes ) 4685*e1fe3e4aSElliott Hughes self.tearDownUFO() 4686*e1fe3e4aSElliott Hughes 4687*e1fe3e4aSElliott Hughes def testUFOWriterCopy(self): 4688*e1fe3e4aSElliott Hughes sourceDir = self.dstDir.replace(".ufo", "") + "-copy source" + ".ufo" 4689*e1fe3e4aSElliott Hughes dataPath = "data/org.unifiedfontobject.copy/level1/level2/file1.txt" 4690*e1fe3e4aSElliott Hughes writer = UFOWriter(sourceDir, formatVersion=3) 4691*e1fe3e4aSElliott Hughes writer.writeBytesToPath(dataPath, b"test") 4692*e1fe3e4aSElliott Hughes # copy a file 4693*e1fe3e4aSElliott Hughes reader = UFOReader(sourceDir) 4694*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4695*e1fe3e4aSElliott Hughes writer.copyFromReader(reader, dataPath, dataPath) 4696*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, dataPath) 4697*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(path), True) 4698*e1fe3e4aSElliott Hughes self.tearDownUFO() 4699*e1fe3e4aSElliott Hughes # copy a directory 4700*e1fe3e4aSElliott Hughes reader = UFOReader(sourceDir) 4701*e1fe3e4aSElliott Hughes writer = UFOWriter(self.dstDir, formatVersion=3) 4702*e1fe3e4aSElliott Hughes p = "data/org.unifiedfontobject.copy" 4703*e1fe3e4aSElliott Hughes writer.copyFromReader(reader, p, p) 4704*e1fe3e4aSElliott Hughes path = os.path.join(self.dstDir, dataPath) 4705*e1fe3e4aSElliott Hughes self.assertEqual(os.path.exists(path), True) 4706*e1fe3e4aSElliott Hughes self.tearDownUFO() 4707*e1fe3e4aSElliott Hughes 4708*e1fe3e4aSElliott Hughes 4709*e1fe3e4aSElliott Hughes# --------------- 4710*e1fe3e4aSElliott Hughes# layerinfo.plist 4711*e1fe3e4aSElliott Hughes# --------------- 4712*e1fe3e4aSElliott Hughes 4713*e1fe3e4aSElliott Hughes 4714*e1fe3e4aSElliott Hughesclass TestLayerInfoObject: 4715*e1fe3e4aSElliott Hughes color = guidelines = lib = None 4716*e1fe3e4aSElliott Hughes 4717*e1fe3e4aSElliott Hughes 4718*e1fe3e4aSElliott Hughesclass UFO3ReadLayerInfoTestCase(unittest.TestCase): 4719*e1fe3e4aSElliott Hughes def setUp(self): 4720*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 4721*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 4722*e1fe3e4aSElliott Hughes self.ufoPath = os.path.join(self.tempDir, "test.ufo") 4723*e1fe3e4aSElliott Hughes 4724*e1fe3e4aSElliott Hughes def tearDown(self): 4725*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 4726*e1fe3e4aSElliott Hughes 4727*e1fe3e4aSElliott Hughes def makeUFO(self, formatVersion=3, layerInfo=None): 4728*e1fe3e4aSElliott Hughes self.clearUFO() 4729*e1fe3e4aSElliott Hughes if not os.path.exists(self.ufoPath): 4730*e1fe3e4aSElliott Hughes os.mkdir(self.ufoPath) 4731*e1fe3e4aSElliott Hughes # metainfo.plist 4732*e1fe3e4aSElliott Hughes metaInfo = dict(creator="test", formatVersion=formatVersion) 4733*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "metainfo.plist") 4734*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4735*e1fe3e4aSElliott Hughes plistlib.dump(metaInfo, f) 4736*e1fe3e4aSElliott Hughes # layercontents.plist 4737*e1fe3e4aSElliott Hughes layerContents = [("public.default", "glyphs")] 4738*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "layercontents.plist") 4739*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4740*e1fe3e4aSElliott Hughes plistlib.dump(layerContents, f) 4741*e1fe3e4aSElliott Hughes # glyphs 4742*e1fe3e4aSElliott Hughes glyphsPath = os.path.join(self.ufoPath, "glyphs") 4743*e1fe3e4aSElliott Hughes os.mkdir(glyphsPath) 4744*e1fe3e4aSElliott Hughes contents = dict(a="a.glif") 4745*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "contents.plist") 4746*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4747*e1fe3e4aSElliott Hughes plistlib.dump(contents, f) 4748*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "a.glif") 4749*e1fe3e4aSElliott Hughes with open(path, "w") as f: 4750*e1fe3e4aSElliott Hughes f.write(" ") 4751*e1fe3e4aSElliott Hughes # layerinfo.plist 4752*e1fe3e4aSElliott Hughes if layerInfo is None: 4753*e1fe3e4aSElliott Hughes layerInfo = dict(color="0,0,0,1", lib={"foo": "bar"}) 4754*e1fe3e4aSElliott Hughes path = os.path.join(glyphsPath, "layerinfo.plist") 4755*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4756*e1fe3e4aSElliott Hughes plistlib.dump(layerInfo, f) 4757*e1fe3e4aSElliott Hughes 4758*e1fe3e4aSElliott Hughes def clearUFO(self): 4759*e1fe3e4aSElliott Hughes if os.path.exists(self.ufoPath): 4760*e1fe3e4aSElliott Hughes shutil.rmtree(self.ufoPath) 4761*e1fe3e4aSElliott Hughes 4762*e1fe3e4aSElliott Hughes def testValidLayerInfo(self): 4763*e1fe3e4aSElliott Hughes self.makeUFO() 4764*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4765*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4766*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4767*e1fe3e4aSElliott Hughes glyphSet.readLayerInfo(info) 4768*e1fe3e4aSElliott Hughes expectedColor = "0,0,0,1" 4769*e1fe3e4aSElliott Hughes self.assertEqual(expectedColor, info.color) 4770*e1fe3e4aSElliott Hughes expectedLib = {"foo": "bar"} 4771*e1fe3e4aSElliott Hughes self.assertEqual(expectedLib, info.lib) 4772*e1fe3e4aSElliott Hughes 4773*e1fe3e4aSElliott Hughes def testMissingLayerInfo(self): 4774*e1fe3e4aSElliott Hughes self.makeUFO() 4775*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs", "layerinfo.plist") 4776*e1fe3e4aSElliott Hughes os.remove(path) 4777*e1fe3e4aSElliott Hughes # read 4778*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4779*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4780*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4781*e1fe3e4aSElliott Hughes glyphSet.readLayerInfo(info) 4782*e1fe3e4aSElliott Hughes self.assertEqual(None, info.color) 4783*e1fe3e4aSElliott Hughes self.assertEqual(None, info.guidelines) 4784*e1fe3e4aSElliott Hughes self.assertEqual(None, info.lib) 4785*e1fe3e4aSElliott Hughes 4786*e1fe3e4aSElliott Hughes def testBogusLayerInfo(self): 4787*e1fe3e4aSElliott Hughes self.makeUFO() 4788*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs", "layerinfo.plist") 4789*e1fe3e4aSElliott Hughes os.remove(path) 4790*e1fe3e4aSElliott Hughes with open(path, "w") as f: 4791*e1fe3e4aSElliott Hughes f.write("test") 4792*e1fe3e4aSElliott Hughes # read 4793*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4794*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4795*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4796*e1fe3e4aSElliott Hughes self.assertRaises(UFOLibError, glyphSet.readLayerInfo, info) 4797*e1fe3e4aSElliott Hughes 4798*e1fe3e4aSElliott Hughes def testInvalidFormatLayerInfo(self): 4799*e1fe3e4aSElliott Hughes self.makeUFO() 4800*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs", "layerinfo.plist") 4801*e1fe3e4aSElliott Hughes info = [("color", "0,0,0,0")] 4802*e1fe3e4aSElliott Hughes with open(path, "wb") as f: 4803*e1fe3e4aSElliott Hughes plistlib.dump(info, f) 4804*e1fe3e4aSElliott Hughes # read 4805*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4806*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4807*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4808*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, info) 4809*e1fe3e4aSElliott Hughes 4810*e1fe3e4aSElliott Hughes def testColor(self): 4811*e1fe3e4aSElliott Hughes ## not a string 4812*e1fe3e4aSElliott Hughes info = {} 4813*e1fe3e4aSElliott Hughes info["color"] = 1 4814*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4815*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4816*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4817*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4818*e1fe3e4aSElliott Hughes ## not enough commas 4819*e1fe3e4aSElliott Hughes info = {} 4820*e1fe3e4aSElliott Hughes info["color"] = "1 0, 0, 0" 4821*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4822*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4823*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4824*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4825*e1fe3e4aSElliott Hughes info = {} 4826*e1fe3e4aSElliott Hughes info["color"] = "1 0 0, 0" 4827*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4828*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4829*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4830*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4831*e1fe3e4aSElliott Hughes info = {} 4832*e1fe3e4aSElliott Hughes info["color"] = "1 0 0 0" 4833*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4834*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4835*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4836*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4837*e1fe3e4aSElliott Hughes ## not enough parts 4838*e1fe3e4aSElliott Hughes info = {} 4839*e1fe3e4aSElliott Hughes info["color"] = ", 0, 0, 0" 4840*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4841*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4842*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4843*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4844*e1fe3e4aSElliott Hughes info = {} 4845*e1fe3e4aSElliott Hughes info["color"] = "1, , 0, 0" 4846*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4847*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4848*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4849*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4850*e1fe3e4aSElliott Hughes info = {} 4851*e1fe3e4aSElliott Hughes info["color"] = "1, 0, , 0" 4852*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4853*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4854*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4855*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4856*e1fe3e4aSElliott Hughes info = {} 4857*e1fe3e4aSElliott Hughes info["color"] = "1, 0, 0, " 4858*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4859*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4860*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4861*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4862*e1fe3e4aSElliott Hughes info = {} 4863*e1fe3e4aSElliott Hughes info["color"] = ", , , " 4864*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4865*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4866*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4867*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4868*e1fe3e4aSElliott Hughes ## not a number in all positions 4869*e1fe3e4aSElliott Hughes info = {} 4870*e1fe3e4aSElliott Hughes info["color"] = "r, 1, 1, 1" 4871*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4872*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4873*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4874*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4875*e1fe3e4aSElliott Hughes info = {} 4876*e1fe3e4aSElliott Hughes info["color"] = "1, g, 1, 1" 4877*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4878*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4879*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4880*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4881*e1fe3e4aSElliott Hughes info = {} 4882*e1fe3e4aSElliott Hughes info["color"] = "1, 1, b, 1" 4883*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4884*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4885*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4886*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4887*e1fe3e4aSElliott Hughes info = {} 4888*e1fe3e4aSElliott Hughes info["color"] = "1, 1, 1, a" 4889*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4890*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4891*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4892*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4893*e1fe3e4aSElliott Hughes ## too many parts 4894*e1fe3e4aSElliott Hughes info = {} 4895*e1fe3e4aSElliott Hughes info["color"] = "1, 0, 0, 0, 0" 4896*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4897*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4898*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4899*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4900*e1fe3e4aSElliott Hughes ## < 0 in each position 4901*e1fe3e4aSElliott Hughes info = {} 4902*e1fe3e4aSElliott Hughes info["color"] = "-1, 0, 0, 0" 4903*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4904*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4905*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4906*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4907*e1fe3e4aSElliott Hughes info = {} 4908*e1fe3e4aSElliott Hughes info["color"] = "0, -1, 0, 0" 4909*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4910*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4911*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4912*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4913*e1fe3e4aSElliott Hughes info = {} 4914*e1fe3e4aSElliott Hughes info["color"] = "0, 0, -1, 0" 4915*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4916*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4917*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4918*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4919*e1fe3e4aSElliott Hughes info = {} 4920*e1fe3e4aSElliott Hughes info["color"] = "0, 0, 0, -1" 4921*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4922*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4923*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4924*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4925*e1fe3e4aSElliott Hughes ## > 1 in each position 4926*e1fe3e4aSElliott Hughes info = {} 4927*e1fe3e4aSElliott Hughes info["color"] = "2, 0, 0, 0" 4928*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4929*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4930*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4931*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4932*e1fe3e4aSElliott Hughes info = {} 4933*e1fe3e4aSElliott Hughes info["color"] = "0, 2, 0, 0" 4934*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4935*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4936*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4937*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4938*e1fe3e4aSElliott Hughes info = {} 4939*e1fe3e4aSElliott Hughes info["color"] = "0, 0, 2, 0" 4940*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4941*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4942*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4943*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4944*e1fe3e4aSElliott Hughes info = {} 4945*e1fe3e4aSElliott Hughes info["color"] = "0, 0, 0, 2" 4946*e1fe3e4aSElliott Hughes self.makeUFO(layerInfo=info) 4947*e1fe3e4aSElliott Hughes reader = UFOReader(self.ufoPath, validate=True) 4948*e1fe3e4aSElliott Hughes glyphSet = reader.getGlyphSet() 4949*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.readLayerInfo, TestLayerInfoObject()) 4950*e1fe3e4aSElliott Hughes 4951*e1fe3e4aSElliott Hughes 4952*e1fe3e4aSElliott Hughesclass UFO3WriteLayerInfoTestCase(unittest.TestCase): 4953*e1fe3e4aSElliott Hughes def setUp(self): 4954*e1fe3e4aSElliott Hughes self.tempDir = tempfile.mktemp() 4955*e1fe3e4aSElliott Hughes os.mkdir(self.tempDir) 4956*e1fe3e4aSElliott Hughes self.ufoPath = os.path.join(self.tempDir, "test.ufo") 4957*e1fe3e4aSElliott Hughes 4958*e1fe3e4aSElliott Hughes def tearDown(self): 4959*e1fe3e4aSElliott Hughes shutil.rmtree(self.tempDir) 4960*e1fe3e4aSElliott Hughes 4961*e1fe3e4aSElliott Hughes def makeGlyphSet(self): 4962*e1fe3e4aSElliott Hughes self.clearUFO() 4963*e1fe3e4aSElliott Hughes writer = UFOWriter(self.ufoPath) 4964*e1fe3e4aSElliott Hughes return writer.getGlyphSet() 4965*e1fe3e4aSElliott Hughes 4966*e1fe3e4aSElliott Hughes def clearUFO(self): 4967*e1fe3e4aSElliott Hughes if os.path.exists(self.ufoPath): 4968*e1fe3e4aSElliott Hughes shutil.rmtree(self.ufoPath) 4969*e1fe3e4aSElliott Hughes 4970*e1fe3e4aSElliott Hughes def testValidWrite(self): 4971*e1fe3e4aSElliott Hughes expected = dict(color="0,0,0,1", lib={"foo": "bar"}) 4972*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4973*e1fe3e4aSElliott Hughes info.color = expected["color"] 4974*e1fe3e4aSElliott Hughes info.lib = expected["lib"] 4975*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 4976*e1fe3e4aSElliott Hughes glyphSet.writeLayerInfo(info) 4977*e1fe3e4aSElliott Hughes path = os.path.join(self.ufoPath, "glyphs", "layerinfo.plist") 4978*e1fe3e4aSElliott Hughes with open(path, "rb") as f: 4979*e1fe3e4aSElliott Hughes result = plistlib.load(f) 4980*e1fe3e4aSElliott Hughes self.assertEqual(expected, result) 4981*e1fe3e4aSElliott Hughes 4982*e1fe3e4aSElliott Hughes def testColor(self): 4983*e1fe3e4aSElliott Hughes ## not a string 4984*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4985*e1fe3e4aSElliott Hughes info.color = 1 4986*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 4987*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 4988*e1fe3e4aSElliott Hughes ## not enough commas 4989*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4990*e1fe3e4aSElliott Hughes info.color = "1 0, 0, 0" 4991*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 4992*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 4993*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4994*e1fe3e4aSElliott Hughes info.color = "1 0 0, 0" 4995*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 4996*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 4997*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 4998*e1fe3e4aSElliott Hughes info.color = "1 0 0 0" 4999*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5000*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5001*e1fe3e4aSElliott Hughes ## not enough parts 5002*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5003*e1fe3e4aSElliott Hughes info.color = ", 0, 0, 0" 5004*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5005*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5006*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5007*e1fe3e4aSElliott Hughes info.color = "1, , 0, 0" 5008*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5009*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5010*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5011*e1fe3e4aSElliott Hughes info.color = "1, 0, , 0" 5012*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5013*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5014*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5015*e1fe3e4aSElliott Hughes info.color = "1, 0, 0, " 5016*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5017*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5018*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5019*e1fe3e4aSElliott Hughes info.color = ", , , " 5020*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5021*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5022*e1fe3e4aSElliott Hughes ## not a number in all positions 5023*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5024*e1fe3e4aSElliott Hughes info.color = "r, 1, 1, 1" 5025*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5026*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5027*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5028*e1fe3e4aSElliott Hughes info.color = "1, g, 1, 1" 5029*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5030*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5031*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5032*e1fe3e4aSElliott Hughes info.color = "1, 1, b, 1" 5033*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5034*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5035*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5036*e1fe3e4aSElliott Hughes info.color = "1, 1, 1, a" 5037*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5038*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5039*e1fe3e4aSElliott Hughes ## too many parts 5040*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5041*e1fe3e4aSElliott Hughes info.color = "1, 0, 0, 0, 0" 5042*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5043*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5044*e1fe3e4aSElliott Hughes ## < 0 in each position 5045*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5046*e1fe3e4aSElliott Hughes info.color = "-1, 0, 0, 0" 5047*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5048*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5049*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5050*e1fe3e4aSElliott Hughes info.color = "0, -1, 0, 0" 5051*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5052*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5053*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5054*e1fe3e4aSElliott Hughes info.color = "0, 0, -1, 0" 5055*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5056*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5057*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5058*e1fe3e4aSElliott Hughes info.color = "0, 0, 0, -1" 5059*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5060*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5061*e1fe3e4aSElliott Hughes ## > 1 in each position 5062*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5063*e1fe3e4aSElliott Hughes info.color = "2, 0, 0, 0" 5064*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5065*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5066*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5067*e1fe3e4aSElliott Hughes info.color = "0, 2, 0, 0" 5068*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5069*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5070*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5071*e1fe3e4aSElliott Hughes info.color = "0, 0, 2, 0" 5072*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5073*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5074*e1fe3e4aSElliott Hughes info = TestLayerInfoObject() 5075*e1fe3e4aSElliott Hughes info.color = "0, 0, 0, 2" 5076*e1fe3e4aSElliott Hughes glyphSet = self.makeGlyphSet() 5077*e1fe3e4aSElliott Hughes self.assertRaises(GlifLibError, glyphSet.writeLayerInfo, info) 5078