Help with simple calt code?

Hi!
I’m trying to make a calt code that would basically be like using start, middle and end glyphs. But strugging. Let’s say ‘start’ is the default glyph, the other’s ss01 etc. but I’ll call the classes by simple names to keep the example simple.

So the result I want is, let’s say if only one glyph typed, then:
start
If 2:
start end
If 3:
start middle end
If 4:
start middle middle end
And so on.

I thought something simple like this would work, but it didn’t:
sub @start @start’ by @end;
sub @start @start@start by @middle;

That didn’t work. it gives this kind of result:
If 2:
start end
If 3:
start middle start
If 4:
start middle start end
And so on.

I tried various ways to make it right for maybe a couple of hours, even trying up to 6 lines of code but I still can’t figure out how to do this. Help would be much appreciated!

Once I have it working, I also want it to work regardless of any marks that might be between any of the glyphs. I don’t currently know how to do that so would also really appreciate help with that!

Thank you.

So you want positional alternates like in Arabic? Strongly recommended: Make the medial shape the default. And then read up on it in the tutorial, it is exactly about that:

https://glyphsapp.com/tutorials/features-part-4-positional-alternates

Markdown tip: use triple backticks ``` before and after code.

For that, the marks must be defined as such (either by default in glyph info or in Font View with Edit > Info for Selection). Then you need to add the IgnoredMarks flag at the beginning of the respective feature or lookup. Take a look at the automatic feature code for Arabic for a code sample.

1 Like

Thanks very much for your reply @mekkablue - so helpful!
No I’m using normal English setting. Just a highly specialised font. The script I am writing for doesn’t have it’s own input system as it’s so obscure. So normal English (is it called Latin?) input suits best.

The tutorial was cool! I decided against using the class names in the tutorial and the middle being default, as this is simpler for my current position with start being default (since I need isolated glyphs to have this form). I made code equivelent to this and it works perfectly it seems!

lookup ONE {
ignore sub [@start @middle @end] ’ @start;
sub @start @start’ by @end;
} ONE;
sub @start @start’ by @middle;
sub @middle @start’ by @middle;

Works great!

I’ll now work to add the mark code. Thank you!

I’ve been reading for a few hours and tried but can’t figure out how to use the IgnoredMarks flag. I tried to add it to that well functioning code I made above, like this - higlighting the new parts for your reading convenience:
lookup ONE {
lookupflag IgnoreMarks;
ignore sub [@start @middle @end] ’ @start;
sub @start @start’ by @end;
} ONE;

lookup TWO {
lookupflag IgnoreMarks;
sub @start @start’ by @middle;
sub @middle @start’ by @middle;
} TWO;

It had no effect - result is same as before additions. Help much appreciated!
Also there are a few more glyphs I want to select to also be ignored in this process, so would greatly appreciate a way to make it ignore specific glyphs/classes also.

Thank you!

Where do you test?

Ohhh. I tested within Glyphs. But your question now inspired me to test it in Pages (Mac) exported - and it works! Great, thanks! The IgnoreMarks ended up affecting the rest of the calt code below (I thought it would not because of being in its own lookup) but I moved this code to the bottom in calt, it does work now :hugs:

I would still love to know how to exclude specific glyphs/classes from calt code being applied. Say I want to also ignore comma, would it be something like?

lookup ONE {
ignore comma;
lookupflag IgnoreMarks;
ignore sub [@start @middle @end] ’ @start;
sub @start @start’ by @end;
} ONE;

I searched a lot but haven’t found the way so I expect that’s wrong. :pray:

You cannot ignore classes, you can only ignore substitutions (and positionings, but that doesn’t apply here), and you need to mark what exactly should not get substituted:

ignore sub @comma';

Then every substitution that involves glyphs from that class will be ignored as long as they are tickmarked.

I would argue this kind of ignore rule without any context does not make much sense. Simply do not substitute glyphs from that group I would say instead.

Ignore rules make more sense with context, e.g.:

ignore sub @comma' @otherclass;

That is explained in detail in the Positional Alternates tutorial: https://glyphsapp.com/tutorials/features-part-4-positional-alternates

Also look at the OpenType Cookbook website for more examples.

1 Like

Thanks! That helped me make a workaround…