salt or aalt?

Michael Rafailyk
Michael Rafailyk Posts: 146
edited May 2021 in Font Technology
Hi TypeDrawers!

Just figured out that salt and aalt features can doing the same substitution. What the difference between them and in which cases do I need use each of? For example, which one feature work better to allow the user to choice an alternate by selecting a character in the text?

feature salt {
  sub A from [A A.alt1 A.alt2];
} salt;

feature aalt {
  sub A from [A A.alt1 A.alt2];
} aalt;

Comments

  • Craig Eliason
    Craig Eliason Posts: 1,436
    Someone will correct me if I'm wrong, but aalt is the place to "round up" all the features that offer alternates (not only stylistic sets but also, for example, oldstyle figs). Best practice I think is to name the feature in the aalt code rather than reproducing the sub line. So that if you had in a ss01 feature the line
    sub g by g.salt;
    in your aalt code you could just have the line
    feature ss01;
  • Thomas Phinney
    Thomas Phinney Posts: 2,887
    'aalt' is short for "all alternates." It is intended as a grab-bag or summation of all possible one-to-one substitutions. Everything in 'aalt' should already also be in another substitution feature. Basically the purpose is to allow an app to easily do feature like the Adobe popout of alternate glyphs in the glyph panel.

    The need for 'aalt' to even exist has been reduced by apps being smarter and constructing their own such lists from all other features.

    So in most cases the right answer is:
    - use whatever other feature you are thinking might be appropriate
    - optionally use 'aalt' to include all substitutions you put in any other single substitution feature
  • Michael Rafailyk
    Michael Rafailyk Posts: 146
    edited May 2021
    @Craig Eliason @Thomas Phinney 
    Thank you so much for make it clear and for your patience with beginners. I will ask something here, only if I can't find information in the manuals.
    So, aalt is optional and make a reference to other features. Should it also include liga (not a single substitution)?

    feature aalt {
      feature salt;
      feature ss01;
      #feature liga;
    } aalt;
    feature salt {
      sub A from [A A.alt1 A.alt2];
    } salt;
    feature ss01 {
      sub A by A.alt1;
    } ss01;
    feature liga {
      sub f i by fi;
    } liga;
  • Roel Nieskens
    Roel Nieskens Posts: 188
    Probably not as `liga` isn't a single substitution, but it'd be curious what'd happen if you did :-)
  • Probably not as `liga` isn't a single substitution, but it'd be curious what'd happen if you did :-)
    True, FontLab says me that's wrong and show an error.
  • It should give a warning rather than an error, but I'm still using FontLab Studio 5, so things might have changed. You can ignore this warning and the font will compile just fine.

    Note that the use of the feature keyword inside 'aalt' is just a convenience. It doesn't correspond to anything that actually exists in the GSUB table. The compiler generates a bunch of 'sub X from Y' substitutions drawing on the set of substitutions found in all the features listed inside aalt. If you're a masochist, you can create all these substitutions yourself.

    If the features listed in 'aalt' include contextual substitutions, the contexts will be ignored. If they include ligature substitutions, those will be ignored altogether.
  • André G. Isaak
    André G. Isaak Posts: 633
    edited May 2021
    One other thing about 'aalt'. There may be cases where you'll want to add actual substitutions to 'aalt' rather than just listing features. consider the following:

    languagesystem DFLT dflt;
    languagesystem latn dflt;

    lookup foo {
        sub a from [a.alt a.alt2];
    } foo;

    feature aalt {
        feature salt;
    } aalt;

    feature salt {
        lookup foo;
    } salt;

    At least in FontLab studio 5, the above will result in an empty 'aalt' feature, because any substitutions which occur in lookups declared outside of a feature block will not be included, even if those lookups are referred to in features blocks which are included in aalt. So you'd have to manually add the sub a from [a.alt alt2] to 'aalt'.

    I don't know if things have changed in FontLab 7. I paid for FontLab 6, and hated it so much that I went back to FontLab 5.