I thought I would be able to use Glyphs to build letter shapes from components, but I’m having trouble getting anchors and components to behave as I expected based on the documentation.
I have created a stem component that now shows up as a glyph in the Other section
I have added an anchor to it called '_stem’
In the glyph for T I have added an anchor called 'stem’
I have added the stem component to the T glyph
What I expected to happen was that the stem glyph would be positioned within the T glyph by aligning the anchors. Instead it looks like the stem is positioned relative to the origin and the anchors are playing no part in positioning and there’s no automatic alignment going on.
What am I missing and how do I get the automatic alignment to happen?
That anchor is not necessary since you can place the stem directly.
Anchors are for aligning several components to each other in a third, compound glyph, e.g., a with a top anchor, dieresis with a _top anchor, in adieresis. Note that there are no more anchors required in adieresis. For placing the stem inside the T, you can simply move the stem component itself.
Can you tell me which part in the documentation was confusing? Perhaps I can reformulate it and make it clearer.
Thanks for your response, the fact that you said “third compound glyph” was what I needed to get me to experiment until I understood the exact recipe to get automatic alignment using anchors to work.
To enable automatic alignment using anchors:
Create a component that contains an anchor with a name that does not begin with an underscore (e.g. ‘stem’)
Create another component that contains an anchor with the same name except that it does begin with an underscore (for example ‘_stem’)
Add both components to a third glyph
Make sure that the component containing the anchor without the underscore (‘stem’) is the first component added. If it is not, Ctrl+click on that component’s shape within the third glyph’s view and choose ‘Make First’ from the context menu.
You can confirm that automatic alignment is enabled and working correctly by editing the anchor position in either of the components and seeing that the relative position of the components in the third glyph changes.
To repeat, there are (at least) four things you need to get automatic alignment using anchors to work:
A component that contains an anchor without an initial underscore
A component that contains an anchor with the same name but with an initial underscore
A glyph to which both the previous components have been added
The component with the non-underscore anchor must be the first component in the glyph (which either means that the component must be added first or that you make it first using the ‘Make First’ menu item)
So I had two errors when I first tried this:
I thought a component’s anchor would align with the corresponding anchor in the glyph itself. That’s not the case - alignment only happens between anchors in imported components.
I was not aware of the significance of the first component (or more generally the order of all components - it looks like anchors can be matched across multiple components as long as the non-underscore component comes first in the component order).
Now I understand. Feel free to use any of this text in the documentation if you think it will make things clearer. I make no claim that this information isn’t already in the documentation; only that I didn’t get it at the speed with which I read it.
Regarding my reasons for wanting to do this with stems and bars - I know that I can position things explicitly, but I want to use relative and automatic positioning with these for exactly the same reasons that it’s useful for diacritics: the ability to make changes in one place and have related places update automatically while retaining their integrity. For example if horizontals may only cross the stem in a few places, I’d like to define those places as anchors on the stem component. I’ll have to experiment further with anchors to see if I can really do that, but it looks hopeful now that I’ve got the basics working.
My experiments are proceeding well now that I understand how anchors are matched. I can confirm that anchors are matched across multiple components (not just with the first) according to the order of the components: non-underscore anchors must come earlier than underscore anchors in the component order.
If you have multiple components with the same non-underscore anchor imported in to your glyph, the underscore anchor will align to the component with the non-underscore anchor that most closely precedes it in component order.
If you have multiple components, you can still control component order within a glyph even after components have been added using the Make First command - for example, just use Make First on each component in reverse order to ensure that the component order is correct.