Changeset 1058
- Timestamp:
- 12/15/11 18:45:03 (17 months ago)
- Location:
- packages/defcon/branches/ufo3/Lib/defcon/objects
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
packages/defcon/branches/ufo3/Lib/defcon/objects/font.py
r1050 r1058 561 561 562 562 def _get_unicodeData(self): 563 return self._glyphSet. _unicodeData563 return self._glyphSet.unicodeData 564 564 565 565 unicodeData = property(_get_unicodeData, doc="The font's :class:`UnicodeData` object.") … … 1623 1623 >>> glyph.unicodes = [65] 1624 1624 >>> font.unicodeData[65] 1625 [' A', 'test']1625 ['test', 'A'] 1626 1626 """ 1627 1627 -
packages/defcon/branches/ufo3/Lib/defcon/objects/layer.py
r1054 r1058 85 85 self._color = None 86 86 self._lib = None 87 self._unicodeData = self.instantiateUnicodeData() 88 self.beginSelfUnicodeDataNotificationObservation() 87 self._unicodeData = None 89 88 90 89 self._directory = None … … 98 97 99 98 if glyphSet is not None: 100 self._unicodeData.disableNotifications()101 99 self._keys = set(self._glyphSet.keys()) 102 cmap = {}103 for glyphName, unicodes in glyphSet.getUnicodes().items():104 for code in unicodes:105 if code in cmap:106 cmap[code].append(glyphName)107 else:108 cmap[code] = [glyphName]109 self._unicodeData.update(cmap)110 self._unicodeData.enableNotifications()111 100 112 101 def __del__(self): … … 243 232 if beginObservations: 244 233 self.beginSelfGlyphNotificationObservation(glyph) 245 if glyph.unicodes :234 if glyph.unicodes and self._unicodeData is not None: 246 235 self._unicodeData.addGlyphData(name, glyph.unicodes) 247 236 … … 271 260 272 261 def _deleteGlyph(self, name, endObservations=True): 273 self._unicodeData.removeGlyphData(name, self[name].unicodes) 262 if self._unicodeData is not None: 263 self._unicodeData.removeGlyphData(name, self[name].unicodes) 274 264 dataOnDiskTimeStamp = None 275 265 dataOnDisk = None … … 546 536 547 537 def endSelfUnicodeDataNotificationObservation(self): 548 if self._unicodeData .dispatcher is None:538 if self._unicodeData is None or self._unicodeData.dispatcher is None: 549 539 return 550 540 self._unicodeData.endSelfNotificationObservation() 551 541 552 542 def _get_unicodeData(self): 543 if self._unicodeData is None: 544 cmap = {} 545 for glyphName, glyph in self._glyphs.items(): 546 if glyphName in self._scheduledForDeletion: 547 continue 548 if not glyph.unicodes: 549 continue 550 for code in glyph.unicodes: 551 if code in cmap: 552 cmap[code].append(glyphName) 553 else: 554 cmap[code] = [glyphName] 555 if self._glyphSet is not None: 556 glyphNames = set(self._glyphSet.keys()) - set(self._glyphs.keys()) 557 for glyphName, unicodes in self._glyphSet.getUnicodes(glyphNames=glyphNames).items(): 558 for code in unicodes: 559 if code in cmap: 560 cmap[code].append(glyphName) 561 else: 562 cmap[code] = [glyphName] 563 564 self._unicodeData = self.instantiateUnicodeData() 565 self._unicodeData.disableNotifications() 566 self._unicodeData.update(cmap) 567 self._unicodeData.enableNotifications() 568 self.beginSelfUnicodeDataNotificationObservation() 553 569 return self._unicodeData 554 570 … … 722 738 glyph = self._glyphs[oldName] 723 739 self._deleteGlyph(oldName, endObservations=False) 724 self._unicodeData.removeGlyphData(oldName, glyph.unicodes) 740 if self._unicodeData is not None: 741 self._unicodeData.removeGlyphData(oldName, glyph.unicodes) 725 742 self._insertGlyph(glyph, beginObservations=False) 726 743 self.postNotification("Layer.GlyphNameChanged", data=dict(oldValue=oldName, newValue=newName)) … … 731 748 oldValues = data["oldValue"] 732 749 newValues = data["newValue"] 733 self._unicodeData.removeGlyphData(glyphName, oldValues) 734 self._unicodeData.addGlyphData(glyphName, newValues) 750 if self._unicodeData is not None: 751 self._unicodeData.removeGlyphData(glyphName, oldValues) 752 self._unicodeData.addGlyphData(glyphName, newValues) 735 753 736 754 … … 1224 1242 >>> glyph.unicodes = [65] 1225 1243 >>> layer.unicodeData[65] 1226 [' A', 'test']1244 ['test', 'A'] 1227 1245 """ 1228 1246
Note: See TracChangeset
for help on using the changeset viewer.
