Changeset 180

Show
Ignore:
Timestamp:
03/27/09 15:30:18 (3 years ago)
Author:
erik
Message:

Fix for ticket #6, T_H and T_h glyphs would get the same glifname.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Lib/robofab/glifLib.py

    r27 r180  
    6161                'A'     -> 'A_.glif' 
    6262                'A.alt' -> 'A_.alt.glif' 
    63                 'A.Alt' -> 'A_.Alt.glif'  # this one would cause problems 
     63                'A.Alt' -> 'A_.Alt.glif' 
     64                'T_H'   -> 'T__H_.glif' 
     65                'T_h'   -> 'T__h.glif' 
     66                't_h'   -> 't_h.glif' 
     67                'F_F_I' -> 'F__F__I_.glif' 
     68                'f_f_i' -> 'f_f_i.glif' 
     69 
    6470        """ 
    6571        if glyphName.startswith("."): 
     
    6773                glyphName = "_" + glyphName[1:] 
    6874        parts = glyphName.split(".") 
    69         if parts[0] != parts[0].lower(): 
    70                 parts[0] += "_" 
     75        if parts[0].find("_")!=-1: 
     76                # it is a compound name, check the separate parts 
     77                bits = [] 
     78                for p in parts[0].split("_"): 
     79                        if p != p.lower(): 
     80                                bits.append(p+"_") 
     81                                continue 
     82                        bits.append(p) 
     83                parts[0] = "_".join(bits) 
     84        else: 
     85                # it is a single name 
     86                if parts[0] != parts[0].lower(): 
     87                        parts[0] += "_" 
     88        for i in range(1, len(parts)): 
     89                # resolve additional, period separated parts, like alt / Alt 
     90                if parts[i] != parts[i].lower(): 
     91                        parts[i] += "_" 
    7192        return ".".join(parts) + ".glif" 
     93 
    7294 
    7395 
     
    685707                readGlyphFromString(s, g2, PrintingPointPen()) 
    686708                pprint(g2.__dict__) 
     709