CALT replace one glyph with multiple glyphs

Is it possible to replace a glyph with two glyphs?

Example:
feature calt {
sub a b’ by c d ;
} calt;

Input: ab
Output: acd

Yes, but the syntax is a bit more complicated.

lookup A_BC {
sub a by b c;
}

sub a b' lookup A_BC;

The lookup need to be outside of the feature so you need to put it into a Prefix.

Thank you for the response!

I am sure it is because of my lack in knowledge about lookups and prefixes, but I do not get it to work.

This is what I have now:

lookup A_BC {
sub a by b c;
} A_BC ;

feature calt {
sub a b' lookup A_BC;
} calt;

This does not give me any error, but does not work.

Sorry, I miss typed.

lookup B_CD {
    sub b by c d;
} B_CD ;

feature calt {
    sub a b' lookup B_CD;
} calt;

That works great! Thanks again!

BTW, that shorthand form of yours (sub a b' by c d) is supported in Glyphs 3. It’s only for Glyphs 2.* that you have to add the extra lookup.

1 Like

That is great news, thank you!

Hi Georg,

Is it possible to use classes for this?
This example does not work:

lookup ebet1 {
    sub @C21 by E_bet1 @C22 ;
} ebet1 ;

feature calt {
   sub @C11 @C21' lookup ebet1 ; 
} calt;

That is currently not supported, but it seems like a valid use case. The only restriction would be to make sure every class involved in such rule has the same number of glyphs (or that it’s a single glyph entirely). The glyphs from the “input” class would then be matched to the glyphs from the “output” classes, one by one (a single glyph in the rule would match repeatedly). In other words, it would work the same as the single substitution rules involving classes. Is this what you’re trying to achieve with this?

1 Like

Exactly.
Okay, thank you for clearing this up for me. Then my workaround should be the most efficient way to do it:

lookup ebet1 {
    sub 	A	by 	E_bet1 	A_C1	; 
    sub 	B	by 	E_bet1 	B_C1	; 
    sub 	C	by 	E_bet1	C_C1	; 
} ebet1 ;

I’ve just added support for this to the feature compiler in Glyphs 3. Stay tuned for the updates :slight_smile:

Both simple (sub @A by @B @C) and inline contextual (sub @A @B' by @C @D) forms are supported, so no need for that extra lookup. Note that this is just a code-level shortcut and technically does not differ in any way from explicitly enumerating all substitutions with individual rules. Also, if you experience any issues with it, please let us know!

1 Like

Cool! I definitely will. Just got Glyphs 3, and actually just bought a Mac only to be able to use Glyphs, after 10 years of Fontlab use.

3 Likes