Different behaviour script vs export plugin

Hi Glyphs team,

I have written a script to try to get around the problem explained here:

The script works when it is run manually before exporting the file. But, in order to make the workflow more efficient, I would like to be able to set it as an export filter/plugin and be able to forget about it. But, when I put the same code in the plugin, the double accents shift to the right: grafik
(Note that the /brevecomb should be centred on the apex of the A)

I have tried running aligncomponents() on each layer beforehand as advised here, but to no avail: Force a refresh - #3 by Tom_Rickner

Any idea what I’m doing wrong or how to get around this?

Thanks,
Tamir

Can you post the relevant part (method) of the code?

Perhaps consider runnig it as PreFilter instead. Some references may not be there at the Filter stage.

Thanks @mekkablue, running as a PreFilter seems to have solved the problem.

Here is the code, perhaps others will also find it useful.

from GlyphsApp.plugins import *

class RemoveNestedComponents(FilterWithoutDialog):
	
	def settings(self):
		self.menuName = 'Remove Nested Components'

	def filter(self, layer, inEditView, customParameters):
		
		loop = True
		while loop:
			loop = False
			#layer.alignComponents() has no effect
			for c in layer.components:
				cg = c.component # GSGlyph of component
				# now we check whether this component contains one or more components
				if len (cg.layers[layer.layerId].components) > 0:
					print("decomposing component %s"%c)
					c.automaticAlignment = False
					c.decompose()
					loop = True
					break
1 Like

Hi there, I have a similar Problem with a Glyphs3 plugin port.

I used to use the alignComponents method on a layer before, in order to live update the recyclers when an Anchor is moved.

This method doesn’t exist in Glyphs 3 anymore. Hence I made a category on GSLayer to keep my legacy code as is. unfortunately, none of the attempts to force alignment on the layer doesn’t do anything. Here’s my category method with all the things I tried:

- (void)alignComponents {
	for (id shape in self.shapes) {
		if ([shape isKindOfClass:GSComponent.class]) {
			GSComponent *c = shape;
			// [c setAlignment:YES];
			[c setAlignment:GSAlignmentAligned]; // or `GSAlignmentForce` ?
			// [c makeForceAlignment];
			[c setIsAligned:GSAlignmentAligned]; // or `GSAlignmentForce` ?
			[c.componentLayer setIsAligning:YES];
			//[c.componentLayer setNeedUpdateShapes];
		}
	}
}

Note: the layer I called the alignComponents on is a copy of course.

GSLayer *componentLayer = [layer copy];
[componentLayer setParent: layer.parent];
[componentLayer alignComponents];

This used to work fine in Glyphs 2.


Edit:

This actually fixed it, but seems to be more of a hack than a proper solution:
The compiler doesn’t complain anymore about the missing method, and the behaviour is back as expected. However, the compiler should not complain, the alignComponents method is documented in the Glyphs3 docu core

@interface GSLayer (LegacyMethods)

- (void) alignComponents;

@end

The layer alignment is moved to its own file: GSLayer+AlignComponents.h. You need to import that. and if you are sure that you like to align, use the doAlignComponents method.

Thank you! Is there a way to find out about those kind of movements on one own’s behalf? I’d never have guessed that :slightly_smiling_face:

Looking around in the headers might help, Xcodes search should pick it up.

Unfortunate the search does not show anything (I tried that of course :wink: )

The headers are also not showing anymore to me. I usually drag in the Glyphs 3 framework from the GlyphsApp package contents when upgrading a Plugin to G3. I have “Copy if needed” checked, because sometimes it moved the framework instead of copying and then my GlyphsApp was broken :D). However, this is how the Framework looks in Xcode then. it works fine, but I have no access to the header files directly anymore.

Screenshot 2021-02-16 at 15.38.44

This works for me:

Screenshot

Now I tried exactly like that (once more) and what happened was:

  1. I had 2 of those framework iconed GlyphsCore.framework packs listed.
  2. When I deleted the newly created one again, I also saw it being deleted from the GlyphsApp Package Content Folder right away (which means that this app is corrupt now, what happened to me before, but unnoticed by me).

So for some reason it doesn’t work here. I still got the framework and can build the plugins, I just cannot access the headers (as I could some time ago and seen on your screenshot).

When you remove something from Xcode it asked you this:


You need to click the button in the middle.

Usually it’s always the Move to Trash in all the other Books and Videos I consulted over the years.

But will do. Thank you!