Replace both glyphs in calt

If I am not making a font for a few weeks I tend to forget virtually everything on the coding side which is quite annoying. So, I want to replace both the initial glyph and the one following it whenever they occur.
This is what I’d like to happen: replace both the R and o.

Use the following code in a feature like clig:

ignore sub @AllLetters R' o';
sub R' o' by R_o;

See here for more details:

I don’t want the RO to be a ligature. There will probably be the long-legged R followed by other small glyphs like A, E etc.

You could do a many-to-many substitution, but that is not supported by all apps (namely Adobe). See here for an explanation how a many-to-many substitution works:

In this case, you might also first substitute the R by the alternative and then match glyphs after that alternative R, like so:

lookup l1 {
	ignore sub @AllLetters R'; # ignore if R is not first letter
	sub R' @AllLetters by R.alt; # ensure R is followed by at least one letter
} l1;

lookup l2 {
	sub R.alt O' by O.alt; # change single glyph after alt R
	# or:
	sub R.alt [A E O]' by [A.alt E.alt O.alt]; # change class of glyphs after alt R
} l2;

Thanks, that worked.

It doesn’t work with another glyph before the R:

When you like to always have the substitution, use this:

lookup l1 {
	sub R' O by R.alt;
	sub R.alt O' by O.alt;
} l1;

The code from Florian assumed that the substitution should only be done at the beginning of the word.

Great, that’s better thanks.

I usually do it in one rule, makes it easier to reason with the feature code instead of having to remember what the input would be after the application of each rule:

lookup RO {
 sub R by R.alt;
 sub O by O.alt;
} RO;

lookup RO_context {
 sub R' lookup RO O' lookup RO;
} RO_context;

But Glyphs makes it a bit cumbersome since the first lookup needs to be in a prefix or it will be unconditionally applied (I often put my entire code in a prefix because of this).

1 Like

We are working on this one.

2 Likes

That is what the prefix is there for, so you can place code outside a feature. If you put the lookup inside a feature, what else should it do?

Because Glyphs wraps everything in the feature in a feature block it makes it harder to control what goes inside the block and what goes outside it. Putting these lookups in prefixes has two downsides 1) it splits the code in two places and makes it harder to follow, and 2) it forces a certain order of the lookups which can have practical impact on how they are applied. If there were, say, a per feature prefix that appears inside it’s editing box (like comments), it might mitigate these two issues.

10 posts were split to a new topic: Standalone lookups inside of features