I’m having a couple of difficulties writing an export plugin (file format plugin) for Glyphs 3. First, unlike in Glyphs 2, the dialog is not resizeable and, by default, does not take the size of the panel as defined in IBDialog.nib. If I select “OTF” and then reselect the custom file format, it is taller as it gets resized to the OTF dimensions, but it is still not tall enough. How can I make the call to resize the dialog to the custom file format’s dimensions on display?
Secondly, when performing the export, there is no feedback or progress bar; Glyphs just freezes until the export is done (which may take a long time). When performing a normal OTF export, Glyphs displays a notification panel for each instance, which then disappears when the export is completed. How can I do something similar for the custom file format? The Message() function always has an OK button and won’t disappear until it’s OKd. I need to be able to show the panel during processing and then hide it again programmatically.
Thanks, Georg, for the link to the NSView property. I will try it out. Is there any documentation on how the auto layout works? Or can we still use the Interface Builder to explicitly position the elements?
Setting this property to True upon initialization gives me the following result. So it seems that no constraints have been set (despite the view having controls). How can I do this using the Python bridge?
By the way, the Glyphs sample File Format Plugin also needs to be updated to Glyphs 3, as the following happens:
Could you also provide a pointer to my second issue, how I can display a progress pane or similar indicator like the one Glyphs normally shows? Or at least return control to Glyphs so that the Macro window can be updated; currently Glyphs freezes until the whole export is done. Thanks!
The progress dialog from Glyphs can be used like this:
GSProgressWindowController = objc.lookUpClass("GSProgressWindowController")
progressWindow = GSProgressWindowController.new()
progressWindow.setTitle_("doing something long")
progressWindow.showProgress()
# Do the long thing
progressWindow.setMessage_("some detail")
# Do more
progressWindow.hideProgress()
(I didn’t try that from a script, but it should work)
I’m having a couple of further problems getting this export script working, which is based on the sample script in the Glyphs SDK.
The sample script stores the values of the checkboxes and other controls in e.g. Glyphs.defaults[unicodePref], which are then used by the export method.
However, my script has some calculated and other user-selectable controls that aren’t stored as a preference, but as a runtime variable, in particular the destination directory, self.exportDestination.
When the export routine is run, these variables are gone and are replaced by their defaults. It looks like, when the user clicks “Next”, a new instance of the plugin is created, start() is run all over again followed by export(). Is this correct?
Is there any way to store the selections made in the controls on the form (other than using Glyphs.defaults[XXpref]) so that they can be used by the export() method? In particular, I need to be able to pass the destination directory to the export method as a string, and attepting to store a string in Glyphs.defaults[XXpref] causes Glyphs to crash.
@GeorgSeifert If you need my code, I sent you the plugin on December 15 by email to gs@…
Thanks @GeorgSeifert for your reply. However, I am not sure how to pass this dictionary to the export method as Glyphs only calls it with the parameters selfand font. If I try calling self.exportOptions() from the export method it is referencing the new object, and the settings previously chosen in the dialog are missing. Or do I need to store this dictionary somewhere?
And to explain why this is needed: This ensures that each export is done by a unique plugin instance. This is needed when exporting more than one font at a time.