Changeset 588
- Timestamp:
- 07/01/09 19:52:30 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
packages/ufo2fdk/trunk/Lib/ufo2fdk/kernFeatureWriter.py
r481 r588 33 33 These groups will be studied when attempting to decompose 34 34 these special exceptions. This is as accurate as it can be, 35 but it is not foolproof. 35 but it is not foolproof. Passing a groupNamePrefix that 36 defines a prefix that all referenced kerning groups will 37 start with. If this is known, it will help remove the 38 ambiguities described above. 36 39 """ 37 40 38 def __init__(self, font ):41 def __init__(self, font, groupNamePrefix=""): 39 42 self.font = font 43 self.groupNamePrefix = groupNamePrefix 40 44 self.leftGroups, self.rightGroups = self.getReferencedGroups() 41 45 self.leftUnreferencedGroups, self.rightUnreferencedGroups = self.getUnreferencedGroups() … … 102 106 groups = self.font.groups 103 107 for left, right in self.font.kerning.keys(): 104 if left in groups:108 if left.startswith(self.groupNamePrefix) and left in groups: 105 109 leftReferencedGroups.add(left) 106 if right in groups:110 if right.startswith(self.groupNamePrefix) and right in groups: 107 111 rightReferencedGroups.add(right) 108 112 leftGroups = {} … … 141 145 unreferencedRightGroups = {} 142 146 for groupName, glyphList in sorted(self.font.groups.items()): 143 if not groupName.startswith("@") :147 if not groupName.startswith("@") or not groupName.startswith(self.groupNamePrefix): 144 148 continue 145 149 if groupName in self.leftGroups: … … 171 175 continue 172 176 # skip empty groups 173 if left in self.font.groups and not self.font.groups[left]:174 continue 175 if right in self.font.groups and not self.font.groups[right]:177 if left.startswith(self.groupNamePrefix) and left in self.font.groups and not self.font.groups[left]: 178 continue 179 if right.startswith(self.groupNamePrefix) and right in self.font.groups and not self.font.groups[right]: 176 180 continue 177 181 # store pair 178 if left in self.font.groups:182 if left.startswith(self.groupNamePrefix) and left in self.font.groups: 179 183 if not left.startswith("@"): 180 184 left = "@" + left 181 if right in self.font.groups:185 if right.startswith(self.groupNamePrefix) and right in self.font.groups: 182 186 if not right.startswith("@"): 183 187 right = "@" + right
