Changeset 124

Show
Ignore:
Timestamp:
12/19/07 11:03:40 (1 year ago)
Author:
tal
Message:
Added a getGroupContents method.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • packages/fontMath/trunk/Lib/fontMath/mathKerning.py

    r123 r124  
    3333    def updateGroups(self, groups): 
    3434        self._groupMap = {} 
     35        self._groups = {} 
    3536        groupDict = groups 
    3637        groupMap = self._groupMap 
     
    3839            if not groupName.startswith("@"): 
    3940                continue 
     41            self._groups[groupName] = list(glyphList) 
    4042            for glyphName in glyphList: 
    4143                if not groupMap.has_key(glyphName): 
     
    5456 
    5557    def groups(self): 
    56         g = {} 
    57         for glyphName, groupList in self._groupMap.items(): 
    58             for groupName in groupList: 
    59                 if not g.has_key(groupName): 
    60                     g[groupName] = [] 
    61                 if not glyphName in g[groupName]: 
    62                     g[groupName].append(glyphName) 
    63         return g 
     58        return deepcopy(self._groups) 
    6459 
    6560    def getGroupsForGlyph(self, glyphName): 
     
    7873        """ 
    7974        return list(self._groupMap.get(glyphName, [])) 
     75 
     76    def getGroupContents(self, groupName): 
     77        """ 
     78        >>> groups = { 
     79        ...     "@A1" : ["A", "B"] 
     80        ... } 
     81        >>> obj = MathKerning({}, groups) 
     82        >>> obj.getGroupContents("@A1") 
     83        ['A', 'B'] 
     84        """ 
     85        return list(self._groups[groupName]) 
    8086 
    8187    def __getitem__(self, pair):