Opentype feature auto-disable?

Beau Williamson
Beau Williamson Posts: 80
edited November 2016 in Technique and Theory
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

  • It is not possible the way you show it, but you can ensure the smcp lookup and/or feature is first in the list. That will first process that lookup, so all lower case characters are replaced by small caps prior to processing dlig.
  • Thank you for the reply,

    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.
  • Kent Lew
    Kent Lew Posts: 944
    If you put the {scmp} feature ahead of the {dlig} feature in the order of your feature file, then the Small Caps will supercede, and take precedence over, the Discretionary Ligatures (as Erwin pointed out).

        feature smcp {<br>        sub @lowercase by @smallcaps;<br>    } smcp;<br><br>    feature dlig {<br>        sub s t by s_t;<br>    } dlig;<br>

    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.

  • The text processing engine gathers all activated features and then applies them in the order in which they are compiled in the font.

    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.

  • Ok, thanks.
    I will try that out.