Multiple contexts for contextual anchors

This is a feature request. Could we please have the ability to specify multiple contexts for contextual anchors, possibly one per line?

Assuming an Arabic font with fully decomposed dots. Suppose I want an anchor contextualised on the previous glyph being a REH-shape, I create one like so:

lookupflag UseMarkFilteringSet @BottomMarks; reh-ar.fina *

Oh, but I have a beh_reh ligature, so I should say:

lookupflag UseMarkFilteringSet @BottomMarks; [reh-ar.fina beh_reh-ar.rlig] *

Strange, that doesn’t work sometimes. It’s fine if the previous word ends “تر” but not if the previous word ends “بر”. Oh, it’s because the BEH has a dot below, which is now in the shaper’s “glyph stream” so our contextual rule does not match! So I need two anchors, one with marks and one without:

  1. *bottom.reh: lookupflag UseMarkFilteringSet @BottomMarks; [reh-ar.fina beh_reh-ar.rlig] *
  2. *bottom.reh2: lookupflag UseMarkFilteringSet @BottomMarks; beh_reh-ar.rlig @BottomMarks *

Very soon I am cluttering up my glyph with lots of alternate anchors which only exist to slightly modify the context. If I could have one anchor with the context:

lookupflag UseMarkFilteringSet @BottomMarks; @FinalRe *
lookupflag UseMarkFilteringSet @BottomMarks; @FinalRe @BottomMarks *

that would make life much easier.

I’m told if you don’t set the context for a contextual anchor, Glyphs will generate an anchor lookup but no contextual one, so one can write a contextual lookup in the feature code and reference the anchor lookup from it. I haven’t tried this yet, but if it works it would be a better way to handle more complex contextual rules.

I have implemented the multiple context already in Glyphs 4 (I put it only there as I also changed the UI for it and that required G4 stuff).

The standalone feature will be in the next Glyphs 3.

1 Like

If you’re working on this in G4, please also add the ability to sync contexts of the same anchor across masters. Sometimes due to changing the context but not quite copying it to all masters, they get out of sync and incompatible. It doesn’t really make sense if the same anchor has different contexts across its designspace if a variable font is being built; in fontmake this is an error, but in Glyphs it compiles silently and who knows which context is actually used?

1 Like

Good point. I’ll have an idea. It could sett the same context for all layers everywhere time, like with the ‘in all Masters’ commands that you get when holding the option key.

I changed it that it is possible to only put in the lookup flag and no context like so: lookupflag UseMarkFilteringSet @foo;

And then I have to write the contextual rules manually? How do I know what lookup name to use to trigger the anchor? (I still think it would be cleaner just to allow one context per line…)

You can inspect the feature code in the temp folder. There you find all lookups and it is also a good place to check how custom code is inserted.
I’ll see what I can do about the multi line support.