Generating alternate substitution features

How do I generate an alternate substitution feature automatically, say I want:

feature salt {
 sub a from [a.salt1 a.salt2 a.salt3];
} salt;

(it would be nice if it worked with any feature tag, but that is not a requirement for my case right now, any non-default feature tag will do).

That should work just like that (according to the FDK feature spec. I’ll try tomorrow.

Sorry, my question was not about the syntax, but about automatically generating such a feature.

To generate that automatically, we would need to establish a naming scheme. But as it is very rare, it might not be worth it.
You could write a script that generates the code.

I don’t think it is that rare, several OpenType features need alternate substitutions e.g. ssty feature for math fonts, and rand feature (which is supported by HarfBuzz and Affinity Publisher), so I think establishing a syntax for this would still be a good idea. I’d suggest some thing simple as xxxxNNNN where xxxx is the feature tag, and NNNN the alternate number, then glyph can be named salt01salt55, ssty1ssty2, rand001rand999 etc.

I’ll have a look.

1 Like