Changeset 548

Show
Ignore:
Timestamp:
01/30/12 09:19:05 (4 months ago)
Author:
tal
Message:

Make the automatic group rename mapping available.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ufo3k/Lib/ufoLib/__init__.py

    r515 r548  
    147147                        ) 
    148148                        # convert kerning and groups 
    149                         kerning, groups = convertUFO1OrUFO2KerningToUFO3Kerning( 
     149                        kerning, groups, conversionMaps = convertUFO1OrUFO2KerningToUFO3Kerning( 
    150150                                self._upConvertedKerningData["originalKerning"], 
    151151                                deepcopy(self._upConvertedKerningData["originalGroups"]) 
     
    154154                        self._upConvertedKerningData["kerning"] = kerning 
    155155                        self._upConvertedKerningData["groups"] = groups 
     156                        self._upConvertedKerningData["groupRenameMaps"] = conversionMaps 
    156157 
    157158        # support methods 
     
    269270                        raise UFOLibError(message) 
    270271                return groups 
     272 
     273        def getKerningGroupConversionRenameMaps(self): 
     274                """ 
     275                Get maps defining the renaming that was done during any 
     276                needed kerning group conversion. This method returns a 
     277                dictionary of this form: 
     278 
     279                        { 
     280                                "side1" : {"old group name" : "new group name"}, 
     281                                "side2" : {"old group name" : "new group name"} 
     282                        } 
     283 
     284                When no conversion has been performed, the side1 and side2 
     285                dictionaries will be empty. 
     286                """ 
     287                if self._formatVersion >= 3: 
     288                        return dict(side1={}, side2={}) 
     289                # use the public group reader to force the load and 
     290                # conversion of the data if it hasn't happened yet. 
     291                self.readGroups() 
     292                return self._upConvertedKerningData["groupRenameMaps"] 
    271293 
    272294        # fontinfo.plist 
  • branches/ufo3k/Lib/ufoLib/converters.py

    r361 r548  
    5555        groups[newName] = group 
    5656    # Return the kerning and the groups. 
    57     return newKerning, groups 
     57    return newKerning, groups, dict(side1=firstRenamedGroups, side2=secondRenamedGroups) 
    5858 
    5959def makeUniqueGroupName(name, groupNames, counter=0): 
     
    9595    ...     "DGroup" : ["D"], 
    9696    ... } 
    97     >>> kerning, groups = convertUFO1OrUFO2KerningToUFO3Kerning( 
     97    >>> kerning, groups, maps = convertUFO1OrUFO2KerningToUFO3Kerning( 
    9898    ...     testKerning, testGroups) 
    9999    >>> expected = {