Changeset 99

Show
Ignore:
Timestamp:
10/28/07 21:38:26 (15 months ago)
Author:
verbosus
Message:

Automatic Text: no longer sort glyphs by Unicode name in main font, but creates a temporary copy of the font to order them. Thanks, Karsten Luecke!

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • hacks/trunk/automatic_text.py

    r98 r99  
    3030 
    3131__author__ = "Antonio Cavedoni <http://cavedoni.com/>" 
    32 __version__ = "0.1" 
     32__version__ = "0.2" 
    3333__svnid__ = "$Id$" 
    3434__license__ = "Python" 
     35__contributors__ = [ 
     36    "Claudio Piccinini <http://www.tht.it/>" 
     37    "Karsten Luecke <http://www.kltf.de/>" 
     38    ] 
    3539 
    3640UPPERCASE = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z".split() 
     
    163167 
    164168def get_all_glyphs(): 
    165     # sort the glyphs by Unicode 
     169    # generate a temp font so we can sort its glyphs 
     170    # by Unicode name without damaging the original 
     171    tempfont = Font(fl.font) 
     172    fl.Add(tempfont) 
     173    tempfontid = fl.ifont 
    166174    fl.CallCommand(fl_cmd.FontSortByUnicode) 
    167175 
    168176    # build a string with all the characters 
    169177    glyphs = [] 
    170     for i in range(len(fl.font)): 
     178    for i in range(len(tempfont)): 
    171179        n = fl.font[i].name 
    172180        if n not in ['.notdef', '.null', 'CR']: 
    173181            glyphs.append(get_glyph_name(fl.font[i].name)) 
     182 
     183    # close the temp font 
     184    tempfont.modified = 0 
     185    fl.Close(tempfontid) 
     186 
    174187    return glyphs 
    175188 
     
    198211 
    199212def generate(glyph_set, glyph_name=None): 
    200     # sort the glyphs by Unicode 
    201     fl.CallCommand(fl_cmd.FontSortByUnicode) 
    202  
    203213    # open metrics window 
    204214    fl.CallCommand(fl_cmd.WindowNewMetrics)