I've been searching around for any way to automatically disable an open type feature when a second feature is activated (within the opentype coding). For example, I don't want discretionary ligatures to be on when the user switches to smallcaps. I am imaging something like:
feature smcp { #Small Capitals
# DEFAULT
script latn;
feature
@dlig = off;
sub
@lowercase by
@smallcaps;
} smcp;
Of course 'feature
@dlig = off' doesn't exist, but is something like this possible?
I find building small cap ligatures an inelegant solution.
Comments
I was thinking more of- if the user has already applied dlig, and then turns on small caps, I want them to be protected from their own inattentiveness. Applying small caps will automatically turn off other features that conflict.
I tried just adding a sub before:
sub s_t by s t;
sub @lowercase by @smallcaps;
but that doesn't work.
Maybe I'll try that zero width space thing... sub s_t by s zeroWidthSpace t;
Again. It doesn't seem elegant. I suppose I'll have to trust users to notice and turn off unwanted ligatures.
This happens regardless of the order in which the features are applied by the end user.
The text processing engine gathers all activated features and then applies them in the order in which they are compiled in the font. So, if both Discretionary Ligatures and Small Caps are applied, but it encounters the rules for {smcp} first, then a sequence of “st” will first get turned into /s.smcp /t.smcp first — at which point, there is no longer a target of “st” for the {dlig} rule to replace with /s_t and that rule becomes moot in this setting now.
So, the relevant concept in OT Layout Features is not how can a given rule turn off others, but rather how might a given rule intercept and prevent others. That’s the way you have to think about it.
There are some hard-coded order in layout engines (and some time differ per script), but this is uasually for features that should be applied by default not optional ones.
I will try that out.