Help with quick python script!
 
            
                
                    Fernando Díaz                
                
                    Posts: 133                
            
                        
            
                    Hi everyone,
I'm in need of help, I'm using Flab 6-7 and need to automatically set the starting point in several glyphs and their masters.
There is an option in "contours"–"set starting point" but if i have to do it one by one I'll take forever.
Does anyone have a script for this?
Do scripts actually work in Flab 6-7? I had several crashes
Thank you!
                        
I'm in need of help, I'm using Flab 6-7 and need to automatically set the starting point in several glyphs and their masters.
There is an option in "contours"–"set starting point" but if i have to do it one by one I'll take forever.
Does anyone have a script for this?
Do scripts actually work in Flab 6-7? I had several crashes
Thank you!
0          
            Comments
- 
            Found a way to do it without a script!!!
 Either way, if anyone can tell me if there is a python for typography course I would be thankful.0
- 
            Don't know how to call FL SetStartPoint function from script, but you can try this:import fontlab as fl import math for glyph in fl.CurrentFont().glyphs: for layer in fl.flGlyph(glyph).layers: for contour in layer.getContours(): bbox = contour.boundingBox() dist = lambda pt: math.sqrt( (bbox.x() - pt.x) ** 2 + (bbox.y() - pt.y) ** 2 ) nodes = [ (index, node) for index, node in enumerate(contour.nodes()) if node.type == "on" ] start_index = sorted( [(index, dist(node)) for index, node in nodes], key=lambda _: _[1], )[0][0] if start_index != 0: contour.setStartPoint(start_index) fl.CurrentFont().update()
 1
- 
            2
- 
            @Fernando Díaz What you are looking for is among the many functions of TypeRig, the script/add-on that is sufficiently powerful that the FontLab folks made it an optional install in the app, in FontLab 7.
 I have become highly dependent on TypeRig for a number of things.
 From the FL7 release notes:
 “The Scripts menu has a Update / Install Scripts command. Click it to install some useful Python packages as well as TypeRig, a monumental Python extension for FontLab 7 developed independently by Vassil Kateliev. TypeRig brings some example Python scripts as well as TypeRig GUI, a large panel that lets you perform various batch operations. When you run Update / Install Scripts for the first time, you will need to restart FontLab 7 two or three times. Run the command once every few weeks to update TypeRig. Note: This functionality is experimental.”3
Categories
- All Categories
- 46 Introductions
- 3.9K Typeface Design
- 485 Type Design Critiques
- 560 Type Design Software
- 1.1K Type Design Technique & Theory
- 654 Type Business
- 853 Font Technology
- 29 Punchcutting
- 519 Typography
- 119 Type Education
- 323 Type History
- 77 Type Resources
- 112 Lettering and Calligraphy
- 33 Lettering Critiques
- 79 Lettering Technique & Theory
- 550 Announcements
- 91 Events
- 114 Job Postings
- 170 Type Releases
- 174 Miscellaneous News
- 276 About TypeDrawers
- 54 TypeDrawers Announcements
- 120 Suggestions and Bug Reports


