Generate automatic class for features

is there a way for an automatic class generation where i can collect all “glyph”.ss01 glyphs in one class? or should i have to write every glyph manually in the SS01 class? Or as an other example to collect all lowercase glyphs in one class?

You can filter the font view (with the search field and sidebar) select all glyphs you need and the right click > copy glyph names.

Georg, I noticed, there are certain clasees you can build automatically, for instance Uppercase, is there a list of all automatic classes? I think it could be great if Glyphs would create certain classes automatically based on suffices. I would definitely appreciate classes ss01, ss02 and their “oposite” classes without suffix, something like “ss01” and “NOss01”.

The ss01 feature is generated without classes because that would result in quite a lot classes.
What you need the classes for?

Are you aware of the ignore statement?

ignore sub @Uppercase x’;
sub x by x.ss02;

… substitutes x only when it is NOT preceded by a glyph in the Uppercase class.

I created a simple font for a translations of a comic book. I wanted to imitate the hand written style so I designed several alternates. So I have:
A-Z 26 glyphs
ss01 26 glyphs
ss02 10 glyphs (the common letters)
ss03 3 glyphs (the most common letters)
I created pseudo random contextual feature. But every time I add a new ss02 glyph, I have to manually modify two classes: @ss02 and @NOss02.

Therefor I thing it would be great if Glyphs would automatically create classes based on features, for instance:
@ss02 = a.ss02 b.ss02 c.ss02
@NOss02 = a b c

I know how to do it in Glyphs manually, I would just love to have automatic classes.

If I get it right, then NOss02 is the same as ss02, but without the suffix. This sounds like a very specific application, and is better done with a simple script, if at all:

Not every time. You can add all your ss02 glyphs first and then edit them. *duck*

What is your workflow? This is how I would do it:

  1. Type “.ss02” in search field (or use a Custom Filter),
  2. Right-click, copy glyph names
  3. Paste in both classes,
  4. In @NOss02, Cmd-Shift-F to replace “.ss02” with “”,
  5. Compile.

Mekkablue, you did describe my workflow perfectly :slight_smile: My wish to have automatic classes would just make this faster.

(The font is a work in progress, I add new ss02, ss03 etc glyphs to the font randomly while working on the comic book. There is not a decision in the beginning which characters will have alternates.)

You could write a script that updates the classes. You would need to run the script every time you add some glyphs.

OK, I already ask colleague to write the script for me.

Btw. is there a list of automatic classes? So far I noticed @Uppercase, are there more classes?

Hello @filipdesigniq! Did you end up having this script built? If so, would you consider sharing it? Would be a great help to me at the moment.

Loop through glyphs, if name contains the suffix add it to class.code. Here is an example:

suffixedGlyphNames = []
thisFont = Glyphs.font

for thisGlyph in thisFont.glyphs:
	if thisGlyph.name.endswith( ".ss01" ):
		suffixedGlyphNames.append( thisGlyph.name )
		
if suffixedGlyphNames:
	newClass = GSClass()
	newClass.code = " ".join( suffixedGlyphNames )
	newClass.name = "SS01"
	thisFont.classes.append( newClass )
	print "Class created."
else:
	print "Warning: No suffixed glyphs found, no class created."
1 Like

This is so helpful, thanks Rainer!

How will you use the class in your feature code?