An odd (or perhaps even) problem with CALT coding

Andy Hullinger's picture

I'm working with a student on some experimental font designs and learning to code Opentype features.

While these two links were invaluable, we've got a simple snippet of code that is confusing when trying to sub many to one. The thinking was to swap out certain typed words with a single "word" glyph using more efficient coding than the letter at a time method Thomas described in his link.

feature calt {
sub t' e' s' t' by test.word;
} calt;

The code below usually works fine except in the case that the word is immediately repeated. Then it appears to "oscillate" and only substitutes every other sequence of letters. Note that this happens whether a space is used or not to separate the repeating letter sequence. Our question is Why?

Khaled Hosny's picture

Since this is a plain ligature, why using calt at all (I don't see you actually doing any contextual substitution), a plain liga should work just fine:

feature liga {
  sub t e s t by test.word;
} liga;
Andy Hullinger's picture

Ha! thanks Khaled, we were so deep in calt experimentation we completely overlooked the obvious.

Theunis de Jong's picture

Andy, probably this didn't work because 'calt' expects some context:

A Chain Substitution rule target sequence has three parts: backtrack, input, and lookahead glyph sequences. A glyph sequence comprises one or more glyphs or glyph classes.

(5.f. [GSUB LookupType 6] Chaining contextual substitution, from Adobe's "OTF Feature File Specs)

It appears to me you are replacing everything, always. Khaled is right, these are ligatures.

Theunis de Jong's picture

(Holy Double Posting Syndrome, Batman!)

sergeym's picture

Using ligature would be right choice in this case, but this doesn't explain why contextual substitution didn't work.

Having empty backtrack and lookaheasequenceses should be perfectly valid. In fact, empty contexts are used to implement 'ignore' keyword in AFDKO syntax or EXCEPT in VOLT.

If you have access to computer with Windows installed, you can try the same font and text in Notepad and see if it works there.

Syndicate content Syndicate content