I think all the features that contain only substitution lookup type could be added to the aalt. In a text editor it gives user access to all the alternate shapes for the selected glyph. For example in glyphs panel of indesign you can choose to see alternate glyphs for the selected character.
Function: This feature makes all variations of a selected
character accessible. This serves several purposes: An application may
not support the feature by which the desired glyph would normally be
accessed; the user may need a glyph outside the context supported by the
normal substitution, or the user may not know what feature produces the
desired glyph.
Can "sub <glyphclass> from <glyphclass>;" considered to be type 3 and thus work with aalt?
Only if <glyphclass1> has a single member.
If <glyphclass1> has multiple members, then this syntax will fail to compile, due to the “from” keyword, which only applies to one-from-many substitutions.
Because aalt is there to provide access to alternate glyphs, I find it much better to just be explicit about these things and write out the "sub x from [x];" syntax for the feature, instead of using the include feature.
If you're using a sane glyph naming scheme, this is pretty easy to script, for example:
from robofab.world import CurrentFont
font = CurrentFont()
def rotate(l,n):
return l[-n:] + l[:-n]
alts = {}
for glyph in font:
if "." in glyph.name:
if glyph.name.split(".")[0] is not "":
if glyph.name.split(".")[0] not in alts:
alts[glyph.name.split(".")[0]] = [glyph.name.split(".")[0], glyph.name]
else:
t = alts[glyph.name.split(".")[0]]
if glyph.name not in t:
t.append(glyph.name)
alts[glyph.name.split(".")[0]] = t
keys = alts.keys()
keys.sort()
for i in keys:
s = alts[i]
glyphs = []
for n in s:
if n in font.keys():
glyphs.append(n)
if len(glyphs) > 1:
r = len(glyphs)
c = 0
while c < r:
w = rotate(glyphs, c)
sub = ""
for n in w:
sub = sub + " " + n
print " sub " + w[0] + " from ["+ sub[1:] + "];"
c += 1
I'm sure that one can come up with something better/cleaner than this example if they wanted.
I've never bothered including the {aalt} feature in fonts, because it seems to me that software should be able to parse the other features and compile its own list of alternates. Basically, I think it's one of those features that Adobe registered in the early days of OpenType without fully considering how the technology might actually work. The use case was always given as the InDesign glyph palette which, unsurprisingly, is perfectly capable of parsing other OTL features to compile lists of alternates.
feature name { # name # DEFAULT sub @glyphclass1 by @glyphclass2; script latn; # Latin sub @glyphclass1 by @glyphclass2; language AZE ; # Azeri language TRK ; # Turkish language MOL ; # Moldavian language ROM ; # Romanian language CRT ; # Crimean Tatar } name;
As you see on example above, I often see features defined default then greek/cyrillic/latin multiple times even if they are same thing as default followed by languages.
It seems redundant, is this something I should just follow?
That example looks like the result of opening a compiled font into a font editor. This is reflective of the actual structure of the compiled font, where each declared language gets mapped to lookups. “Cracking” open a font into a font editor usually leads to such explicit interpretations.
But in development the redundant declarations are not necessary, as the Adobe syntax compiler will assign defaults to all relevant languages when undeclared.
Rules that are specified after the start of a feature and before the
first "script" and/or "language" statement will be included in all the
language systems specified by the "languagesystem" statements. [ . . . ] Once the first script or language statement occurs within a feature
block, subsequent lookups and rules are registered only within the
currently specified script and language.
Comments
See: http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#8.a
From: https://www.microsoft.com/typography/otspec/features_ae.htm#aalt
5.c. [GSUB LookupType 3] Alternate substitution
An Alternate Sub rule is specified as:
Only if <glyphclass1> has a single member.
If <glyphclass1> has multiple members, then this syntax will fail to compile, due to the “from” keyword, which only applies to one-from-many substitutions.
If you're using a sane glyph naming scheme, this is pretty easy to script, for example:
I'm sure that one can come up with something better/cleaner than this example if they wanted.
It seems redundant, is this something I should just follow?
But in development the redundant declarations are not necessary, as the Adobe syntax compiler will assign defaults to all relevant languages when undeclared.
From: http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#4.b.ii