Opentype: Substitution one-after-another - sub x by y; sub y by z;?

Sebastian Nagel's picture

Dear Typophiles,

sorry for maybe asking a quite basic question, i just can't find a potent keyword that gets me to the for sure existing answers, so I'm asking for a link to other threads or a short explanation ... It should be simple, but it just does not work at the moment and I don't know what I am doing wrong. :(

I try to to a "multi-step" one-after-another-replacement with opentype (fontlab 5):

Let's say I have a glyph x.
in calt-feature, i substitute x by x.alt
after that, i want to check another condition,
and in case it applies, want to sub x.alt by x.alt2

is this possible to do?

To explain what i actually want to achieve with this:
i want to do a script font, that has three vertical levels of connectors to the glyph right before it. So i have 4 variations of each letter, i.e. h h.low h.mid h.top
depentent on its predecessors "end", the basic "h" is replaced by its low mid or top connector variant so it fits seamlessly.
after that, i want to check if the glyph is set at the end of a word (followed by a space for the beginning), and if so, the .low .mid or .top variant is replaced by a .low.end .mid.end or .top.end variant ...

thanks for your help
Sebastian

behnam's picture

Substitutions occur in sequence, in the order you wrote your lookups from the top to the bottom. So when you have your first lookup for changing x to x.alt1 , you have to pay attention for your second lookup whether the first condition has met, could be met or not. Whether for your second lookup you are dealing with x or x.alt1 or both, in order to change it to x.alt2
So it is important to pay attention to the sequence of events and write the lookups accordingly.

You are right. There are a lot of good discussions about this in here but I don't remember the topics off hand. Keep looking. You'll find them.

Sebastian Nagel's picture

thanks for this.
I have found a (maybe not very sophisticated) solution.

To connect this thread to the font thread I have just created:
http://typophile.com/node/56408

maybe it's better to discuss there.

twardoch's picture

Sebastian,

After one lookup is processed, the application goes back to the beginning of the text string (or better: text run, i.e. the portion of the text string which has the same font, size, writing system/script, and directionality), and processes the next lookup. So your code should look like:

feature calt {
lookup calt1 {
sub @condition1 x' by x.alt;
} calt;
lookup calt2 {
sub @condition2 x.alt' by x.alt2;
} calt2
} calt;

Cheers,
Adam

Sebastian Nagel's picture

Thank you Adam, now it's perfectly clear what it does :)

(i should have known though ...)

Syndicate content Syndicate content