can I script the FontLab "save as" behavior?

Primary tabs

8 posts / 0 new
Last post
Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm
can I script the FontLab "save as" behavior?
0

Using python in Fontlab, I understand how to save a currently open VFB, or save a currently open VFB under a different name.

What I don't understand is how to get the "save as" behavior: keep the current VFB & its windows open, but give it a new filename.

Adam Twardoch's picture
Offline
Joined: 3 Dec 2002 - 7:36pm
0

fl.font.file_name = "your new path"
fl.font.Save()

or
fl.font.Save("your new path")

A.

Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm
0

Yep, I already tried that. What happens is that FL saves a duplicate of my open font at "your new path." But the filename on the open font doesn't change (and thus if I hit "save" again, any changes go into the old file.)

Adam Twardoch's picture
Offline
Joined: 3 Dec 2002 - 7:36pm
0

How about:
fl.font.file_name = "your new path"
fl.UpdateFont(-1)
fl.font.Save(fl.font.file_name)

?

Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm
0

That works. Thanks.

Does a fontindex of -1 have a predictable result in other functions that ask for a fontindex, or is this a special behavior of UpdateFont()?

Matthew Butterick's picture
Joined: 28 Jul 2009 - 3:14pm
0

Can also be done through Robofab

new_file_path = [whatever you want]
this_font.save(new_file_path)
this_font.update()

Adam Twardoch's picture
Offline
Joined: 3 Dec 2002 - 7:36pm
0

fl.UpdateFont(-1) is synonymous with fl.UpdateFont(fl.ifont) in this case, but it's not universal behavior, I think. Actually, using fl.UpdateFont(fl.ifont) is more elegant to use than fl.UpdateFont(-1).

Thomas Phinney's picture
Offline
Joined: 3 Sep 2002 - 11:00am
0

Geez. Amusingly, what I *need* is the behavior Matthew B was trying to avoid. Here I was going through some extra contortions to get this behavior. Re-reading this just enabled me to drop a bunch of lines of code as unnecessary. :)