Questions about custom classes using tokens

After adding a class in Classes section in the sidebar…what is the setup to use predicate tokens to generate custom classes?

For example: what comes before $[name endswith '.sc'] from the sample image in the Tokens tutorial to create a generated SmallCaps class?

Another question: Is it possible to add to subtract classes from classes or glyphs from classes?

Something like this
@consonants = [b c d]
@vowels = [a e]
@lowercase = [@consonants + @vowels]

or something this
@lowercase = [abcde]
@consonants = @lowercase - [a e]

It sort of lets you with adding classes or at least opt click shows what you would expect but there is also the error message of invalid character “+”…so is there another way to do that?

but this one doesn’t remove specific glyphs from a class

"Adding classes means that you can put class names where you can add glyph names. So [@class1 @class2] is all use need. Subtracting is not supported.

ah ok. make sense.

and what about the first question…say that we want a class of SmallCaps then what is the code we need to have that will automatically populate that class with all the .sc glyphs using the $[name endswith '.sc'] predicate token?

(in the tutorial sample image there is something needed to include before the $[name endswith ‘.sc’] but it is hidden behind the popup menu)

Instead of subtracting @FlorianPircher suggests in this post using name in class(SomeClass) predicate token.

trying something based off of @TimAhrens example this but it doesn’t work

@lowercase = [a b c d e];
@vowels = [a e];
@all_lowercase = [$[name in class(lowercase)]];
@all_lowercase_except_vowels = [$[name in class(lowercase) AND NOT name in class(vowels)]];

getting this error:

Problem expanding glyph class predicate “$[name in class(lowercase) AND NOT name in class(vowels)]”: Use of undefined class name “vowels” in predicate expression: “name in {“(null)”} AND NOT name in class(vowels)”

Thank you for reporting this. The token expansion code runs into an edge case here which is why it is currently not working. You can work around this by creating a Lowercase and a vowels class in the Classes section of the Features tab. See this demo file:

Demo.glyphs (6.1 KB)

1 Like

Nothing. Just write the predicate inside $[ ]. This will be expanded the glyph names.

This is possible. Just leave out the plus sign, and add a semicolon at the end:

@lowercase = [@consonants @vowels];

Subtraction doesn’t work, as Georg already stated (sorry overlooked your response).

1 Like

Subtraction does not work directly, but you can get subtraction to work like in your example:

[$[name in class(Lowercase) AND NOT name in class(Vowels)]];
2 Likes