AutomaticAlignment vs. Alignment

The Docu says_

Defines whether the component is automatically aligned.
    Type:	bool

New in version 2.5.

What’s the difference between those? Please for API and coding, as well as UI considerations.
I am working on a plugin for displaying those and related statuses, but I am confused by those slightly different properties. In the UI you can only Enable/Disable “Automatic Alignment”. But by enabling and disabling some components in a test setup, as well as reading those 2 properties, I can’t get my head around which is doing what.

It also appears that automaticAlignment returns True or False, while alignment can return 0, 1 and -1. What does that mean?

Also it appears that if I start with one component, and set Automatic Alignment in the UI for it, and copy/paste it, it will have the same state for automaticAlignment (as expected). However if I disable and re-enable that second component’s Alignment in the UI, I can never get the Automatic Alignment state back, only the alignment. Urgh, this is so confusing.

here’s my Skedge snippet that you can try with for example 2 “acutecomb” instances in another random glyph:

from AppKit import NSColor

alignmentColors = {
	-1 : NSColor.redColor(),
	0  : NSColor.yellowColor(),
	1  : NSColor.greenColor(),

for c in Glyphs.font.selectedLayers[0].components:
	if c.automaticAlignment:

Alignment is more fine grained. It stores the setting by the user. It can have the following values

GSAlignmentDisable = -1
GSAlignmentDefault = 0
GSAlignmentForce = 1

What you are looking for is isAligned(). That is set by the alignment code with those values:

GSAlignmentNoAligned = -2,
GSAlignmentAligned = 2,
GSAlignmentHorizontal = 3,

according to the documentation ìsAligned` belongs to the GSLayer, not the component. Why is that? I can call component.isAligned() and get “2”.

Both layer and component have it. But it is not documented and wrapped for the componet (that’s why you need the parenthesis).

And which one is the one that the user sets in the UI: Context Menu > Enable/Disable Automatic alignment?

Now after you added .isAligned() here, we got even 3 different alignments on a component, and in my initial question I was already confused by the 2 different alignments.

Main reason why I ask:
My Plugin is supposed to show broken alignments, that happen when you generate an instance as a .glyphs file and add this as a new master to the font. (Which I hereby might consider a BTW-bug-report :wink: )
– while “breaks” means just, that the components don’t have the same alignment state as in the other masters.

The user set the .alignment but that doesn’t necessarily tell you if the componet is aligned or not.

What do you expect when two master have different alignment settings. I can’t interpolate them. So I think it picks the first it finds.

No, it was the same in the 2 extreme masters and just different in the one in the middle

Thank you, this is one information I was after.

And this adds to the confusion :smiley:
So how can I tell?
I want to get the proper information, in order to visualize it properly, in order to have the user have a consistent setup through all masters (which can easily happen to not be, and it’s hard to spot single components that are for example not aligned in one master).

I try a little more later with a clean mind and let you know about potential continued struggles :slightly_smiling_face:

The set value in .alignment might not be in effect as because of a number of reasons. Some base glyphs are not aligned by default (so it needs a GSAlignmentForce, a previous component is not aligned…

I see, thank you so much! :slightly_smiling_face: