Changeset 699
- Timestamp:
- 02/15/10 19:43:44 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/defconAppKit/trunk/Lib/defconAppKit/controls/fontInfoView.py
r686 r699 75 75 if self._finalCallback is not None: 76 76 self._finalCallback(sender) 77 78 79 class PostscriptStemSnapFormatter(NSFormatter):80 81 def stringForObjectValue_(self, obj):82 if obj is None or isinstance(obj, NSNull):83 return ""84 return " ".join([str(i) for i in obj])85 86 def getObjectValue_forString_errorDescription_(self, value, string, error):87 if not string.strip():88 return True, [], ""89 try:90 values = [int(i) for i in string.strip().split(" ")]91 except ValueError:92 return False, string, "Could not convert entries to integers."93 if len(values) >= 12:94 return False, string, "Too many values."95 return True, values, ""96 97 98 class PostscriptBluesFormatter(NSFormatter):99 100 def stringForObjectValue_(self, obj):101 if obj is None or isinstance(obj, NSNull):102 return ""103 return " ".join([str(i) for i in obj])104 105 def getObjectValue_forString_errorDescription_(self, value, string, error):106 if not string.strip():107 return True, [], ""108 try:109 values = [int(i) for i in string.strip().split(" ")]110 values = sorted(values)111 except ValueError:112 return False, string, "Could not convert entries to integers."113 if len(values) % 2:114 return False, string, "An even number of values is required."115 if len(values) >= 14:116 return False, string, "Too many values."117 return True, values, ""118 77 119 78 … … 797 756 798 757 def noneToZero(value): 799 print value800 758 if value is None: 801 759 return 0 … … 1115 1073 title="", 1116 1074 hasDefault=False, 1117 controlClass=PanoseControl, 1118 controlOptions=dict(formatter=PostscriptBluesFormatter.alloc().init()) 1075 controlClass=PanoseControl 1119 1076 ) 1120 1077 … … 1382 1339 ## Postscript Hinting 1383 1340 1341 def postscriptBluesToUFO(string): 1342 if not string: 1343 return [] 1344 try: 1345 values = [int(i) for i in string.split(" ") if i] 1346 except ValueError: 1347 values = [] 1348 values = sorted(values) 1349 if len(values) % 2: 1350 values.pop() 1351 if len(values) >= 14: 1352 value = value[:14] 1353 return values 1354 1355 def postscriptStemSnapToUFO(string): 1356 if not string: 1357 return [] 1358 try: 1359 values = [int(i) for i in string.split(" ") if i] 1360 except ValueError: 1361 values = [] 1362 if len(values) >= 12: 1363 value = value[:12] 1364 return values 1365 1366 def infoListFromUFO(value): 1367 if value is None: 1368 return "" 1369 value = [str(i) for i in value] 1370 return " ".join(value) 1371 1384 1372 postscriptBlueValuesItem = inputItemDict( 1385 1373 title="BlueValues", 1386 1374 hasDefault=False, 1387 controlOptions=dict(formatter=PostscriptBluesFormatter.alloc().init()) 1375 conversionFromUFO=infoListFromUFO, 1376 conversionToUFO=postscriptBluesToUFO, 1388 1377 ) 1389 1378 postscriptOtherBluesItem = inputItemDict( 1390 1379 title="OtherBlues", 1391 1380 hasDefault=False, 1392 controlOptions=dict(formatter=PostscriptBluesFormatter.alloc().init()) 1381 conversionFromUFO=infoListFromUFO, 1382 conversionToUFO=postscriptBluesToUFO, 1393 1383 ) 1394 1384 postscriptFamilyBluesItem = inputItemDict( 1395 1385 title="FamilyBlues", 1396 1386 hasDefault=False, 1397 controlOptions=dict(formatter=PostscriptBluesFormatter.alloc().init()) 1387 conversionFromUFO=infoListFromUFO, 1388 conversionToUFO=postscriptBluesToUFO, 1398 1389 ) 1399 1390 postscriptFamilyOtherBluesItem = inputItemDict( 1400 1391 title="FamilyOtherBlues", 1401 1392 hasDefault=False, 1402 controlOptions=dict(formatter=PostscriptBluesFormatter.alloc().init()) 1393 conversionFromUFO=infoListFromUFO, 1394 conversionToUFO=postscriptBluesToUFO, 1403 1395 ) 1404 1396 postscriptStemSnapHItem = inputItemDict( 1405 1397 title="StemSnapH", 1406 1398 hasDefault=False, 1407 controlOptions=dict(formatter=PostscriptStemSnapFormatter.alloc().init()) 1399 conversionFromUFO=infoListFromUFO, 1400 conversionToUFO=postscriptStemSnapToUFO, 1408 1401 ) 1409 1402 postscriptStemSnapVItem = inputItemDict( 1410 1403 title="StemSnapV", 1411 1404 hasDefault=False, 1412 controlOptions=dict(formatter=PostscriptStemSnapFormatter.alloc().init()) 1405 conversionFromUFO=infoListFromUFO, 1406 conversionToUFO=postscriptStemSnapToUFO, 1413 1407 ) 1414 1408 postscriptBlueFuzzItem = inputItemDict(
