Noob needs to learn how to code contextual alternatives

mekkablue
I realize this code is obviously what I need to do, but I honestly cannot even decipher it, know where it goes, etc. SORRY!

Imagine I am using a car for the first time. I don’t even know which is the gas and which is the brake. Can someone direct me on getting started at that point?

I know I am trying to dive in over my head.

I found this typophile.com/node/32809

Georg Seifert
Okay, this is getting helpful.
Thanks!

This is a good start as well: http://ilovetypography.com/OpenType/opentype-features.html

Dan,
in the Typophile thread that Georg mentioned, Thomas Phinney writes this:

So, if it’s for use in InDesign, the easiest solution for you is to simply add a .fina suffix to the glyphs without connecting tails. For this, you can make use of the built-in batch renaming.

Afterwards, all you need to do is to re-build features: Font Info > Features > Circled Arrow button.

In InDesign, you select Automatic Form from the Positional Form menu in the OpenType options. Hope this helps.

Okay, just to reiterate and make sure I’m on the right page.

I have built additional glyphs that all contain no connectors on them (which is basically the entire font duplicated just without connectors) that will serve as the terminating glyph for each word. Each of these character should then be appended by the ‘.terminal’ suffix (or .fina if I’m feeling InDesign-y); ‘X.terminal’, x.terminal’, ‘Y.terminal’, ‘y.terminal’, etc. (Which I can do with batch renaming [awesome, Georg, thanks!]

Then in the feature panel I enter:

@medial = [a b c d e f g h i]; # (of course will all letters listed)
@terminal = [a.fina b.fina c.fina d.fina e.fina f.fina g.fina h.fina i.fina]; # (etc)

lookup final {
ignore sub @medial’ [@medial @terminal];
sub @medial’ by @terminal;
} final;

And hit the circular button to propagate.

Output the OTF and it should work?

The code looks fine.

But you need to hit the compile button, not the arrow button.

Better yet, you hit the PLUS button and pick CLASS, and an ‘xxxx’ will appear. Double click the ‘xxxx’, type ‘medial’ instead, and in the text field at the top, you type: a b c d e f g h i j k l m n o p q r s t u v w x y z

Repeat the process for the terminals: plus > class > ‘xxxx’ > rename to ‘terminal’ > and you type: a.fina b.fina c.fina d.fina e.fina f.fina g.fina h.fina i.fina j.fina k.fina l.fina m.fina n.fina o.fina p.fina q.fina r.fina s.fina t.fina u.fina v.fina w.fina x.fina y.fina z.fina

Now, for the following part, you need to pick or create a feature. In your case, a good idea is ‘calt’ (=contextual alternatives). This time, it’s: plus > feature > ‘xxxx’ > rename to ‘calt’, and then copy and paste this part into the top text field:

This is what it should look like now (the indentation of ‘ignore’ and ‘sub’ does not matter):

Now, hit the Compile button (sorry for my confusion in my previous posting). If no error message appears, you’ve done everything right. If an error message appears, please copy and paste it into this thread.

It works and it is wonderful. Thank you so much. Now I’m feeling cocky and may have to take on a few ‘initial’ glyphs.

I am finding one discrepancy though. When working with the font, it seems that I substitute an alternate character at the end (‘r.ss01’ for ‘r’ for example) my font applies ‘r.terminal’ instead of ‘r.ss01.terminal’

Any suggestions?

This depends on the order of the feature. If the salt feature precedes the ss01 feature, the r -> r.terminal is already done when the ss01 features is locking for the r. So either you put the salt feature after the ss01, or even better change the name of the r.ss01.terminal to r.terminal.ss01.

Georg Seifert

That did it. Thanks!

Gah! You guys are rockstars. I had been scouring the internet and typophile for this very thing to no avail.

This is exactly what I needed with a wonderful, easy to understand explanation. Much, much thanks!

angie
You’re welcome.
Can we see the font when it’s finished? :slight_smile:

Sure! Just finishing up the lowercase… which means only the entire uppercase and all the punctuation left. Psh. Easy right?

This is just what i need, thank you!

There is also a step-by-step tutorial available:
http://www.glyphsapp.com/tutorials/features-part-4-positional-alternates

Hello.
I did everything as Dan_Apparatus
I had an error (see photo)!
How can i change it
My code is correct?

Read the error message. You target class @terminal does not have the same number of glyphs as the replacement class @medial. If you replace one class by another, both need to have the same number and order of glyphs.

1 Like

Thanks for the answer!

I read this topic:
https://glyphsapp.com/tutorials/features-part-4-positional-alternates
Everything works! All is well!

But the question remains:
Do I have a condition that all glyphs have the same amount of classes?

What should I do if I have a total of 3 terminal forms and 4 initial forms?
For example:
b.fina
d.fina
h.fina
and
c.init
k.init
j.init

I want to automatically work once these letters.
You can configure the code so that only worked these letters at the beginning and the end?

P.S. Forgive me for bad English

If you want to substitute one class by another, they have to have the same amount of glyphs. Makes sense, I think. If you have a different amount of initial, medial and final glyphs, you will have to find a different class setup. Try the script that is mentioned at the end of the tutorial, it does exactly that.