From 062dc2b6fe253c356dc21e5da679aff7deb08017 Mon Sep 17 00:00:00 2001 From: Erik van Blokland Date: Wed, 13 Dec 2023 17:43:33 +0100 Subject: [PATCH] more demo scripts --- ...hange_previewLocation_of_all_open_designspaces.py | 4 ++++ .../rf_close_all_sources_from_designspace.py | 12 ++++++++++++ .../rf_open_all_sources_from_designspace.py | 7 +++++++ 3 files changed, 23 insertions(+) create mode 100644 Scripting examples/rf_change_previewLocation_of_all_open_designspaces.py create mode 100644 Scripting examples/rf_close_all_sources_from_designspace.py diff --git a/Scripting examples/rf_change_previewLocation_of_all_open_designspaces.py b/Scripting examples/rf_change_previewLocation_of_all_open_designspaces.py new file mode 100644 index 0000000..8d7de5a --- /dev/null +++ b/Scripting examples/rf_change_previewLocation_of_all_open_designspaces.py @@ -0,0 +1,4 @@ +for ds in AllDesignspaces(): + loc = ds.randomLocation() + print(loc) + ds.setPreviewLocation(loc) \ No newline at end of file diff --git a/Scripting examples/rf_close_all_sources_from_designspace.py b/Scripting examples/rf_close_all_sources_from_designspace.py new file mode 100644 index 0000000..721b883 --- /dev/null +++ b/Scripting examples/rf_close_all_sources_from_designspace.py @@ -0,0 +1,12 @@ + +# save and close all open fonts that belong +# to the current designspace. + +ds = CurrentDesignspace() + +dsFontPaths = [f.path for f, l in ds.getFonts()] + +for f in AllFonts(): + if f.path in dsFontPaths: + f.save() + f.close() \ No newline at end of file diff --git a/Scripting examples/rf_open_all_sources_from_designspace.py b/Scripting examples/rf_open_all_sources_from_designspace.py index 22ed62c..570726c 100644 --- a/Scripting examples/rf_open_all_sources_from_designspace.py +++ b/Scripting examples/rf_open_all_sources_from_designspace.py @@ -3,7 +3,14 @@ # and that edits in the fonts are reflected in the previews. ds = CurrentDesignspace() done = [] + +discreteLocation = {'slab': 0} +discreteLocation = None + for font, loc in ds.getFonts(): + if discreteLocation is not None: + if loc | discreteLocation != loc: + continue if font.path not in done: font.asFontParts().openInterface() # a ufo can appear multiple times in the designspace