Feature request: copy-paste entire variable table data

I’m working on a typeface with many different variables, and it is starting to become tiresome to enter the same data manually for each affected letter. Since many letters share the same data, it would be nifty to copy-paste the entire table, thus saving some time.

What data do you mean?

The intermediate and alternative master tables

Are you sure you don’t need some real masters for this setup?

Yes, I am certain. Oh, and the attached image is just to state an example.

Select the layer where you want to copy the axis settings and run this in the Macro panel:

Font.tempData['axisRulesCopy'] = Layer.attributes['axisRules']

This stores a copy of the axis settings of the current layer. Then, select all glyph layers where you want to apply the same axis settings and run the following code:

axisRulesCopy = Font.tempData['axisRulesCopy']
for layer in Font.selectedLayers:
	layer.attributes['axisRules'] = axisRulesCopy

You can also put these snippets into scripts and run them with a keyboard shortcut.

Interesting! I will check it out.

Too bad, the second part of the macro crashes my Glyphs 3.

I wrote these scripts without much testing and handled only Alternate layers, but not Intermediate layers. Here is a more complete solution that handles both:

1. Store attributes of current layer for later reuse:

Font.tempData['sourceAttributes'] = Layer.attributes

2. Reuse layer attributes for all selected layers:

sourceAttributes = Font.tempData['sourceAttributes']

if 'axisRules' in sourceAttributes:
	axisRules = sourceAttributes['axisRules']
	for layer in Font.selectedLayers:
		if layer.isBracketLayer():
			layer.attributes['axisRules'] = axisRules

if 'coordinates' in sourceAttributes:
	coordinates = sourceAttributes['coordinates']
	for layer in Font.selectedLayers:
		if layer.isBraceLayer():
			layer.attributes['coordinates'] = coordinates

Thank you! @FlorianPircher This seems to be woking, however, I can only reuse the attribute for one layer at the time. If the target layers are more than one, only the first one will receive the attributes.
How would go about creating a snippet for Glyphs? Automator?

It’s difficult to select multiple Alternate/Intermediate layers at the same time since in Font View only master layers can be selected. It’s probably best to create a script.

To create a script, go to the Script menu and choose Open Scripts Folder (⇧⌘Y). A Finder window will open with the Scripts folder selected.

  1. Go into the Scripts folder and create a new folder. Most people name it after themselves, so name the folder “KTKM”. I named mine “Florian Pircher”.
  2. Open a plain text editor. If you are used to code editors like TextMate, Sublime Text, or VS Code, those work well. If not, use the TextEdit app included on the Mac.
  3. (If using TextEdit) Create a new file with File → New. Ensure that you are in plain text mode, not rich text mode. If you see formatting controls (font, font size, text alignment, …) in the window toolbar, convert the document to plain text mode by choosing FormatMake Plain Text (⇧⌘T).
  4. Paste the code of the script.
  5. Add a new line at the beginning of the file with # MenuTitle: Some Script where “Some Script” is the name of the script.
  6. Save the file to your new scripts folder (e.g. “KTKM”). The filename is the name of the script and .py at the end. If you edit in TextEdit, ensure that If no extension is provided, uses “.txt”. is unchecked, like so:
  7. With the file saved, go back to Glyphs, open the Script menu, hold down the Option key and choose Reload Scripts (⌥⇧⌘Y, scripts are automatically reloaded when relaunching Glyphs).
  8. Open the Script menu again and you will find your script folder as a submenu with the script place in it:

Assign a keyboard shortcut to the script by going to GlyphsPreferences…Shortcuts. There, search for your script, click Record shortcut, and press the key combination that should trigger the script (make sure the same shortcut is not already used in Glyphs).

Now, pressing the keyboard shortcut will run the script. If anything goes wrong because some error is in the script code, it will be printed to the console in the Macro panel.

Creating scripts will involve less steps in a future release of Glyphs :​)

This will definitely save some time! Thank you @FlorianPircher for giving me a crash course in creating custom scripts.