Using the OpenType calt table

The OpenType calt table looks interesting.

http://www.microsoft.com/typography/otspec/features_ae.htm#calt

I am thinking of starting from a copy of the Learning_ordn_001.otf font from the following thread, using a project file Learning_calt_001.fcp to produce a font.

http://forum.high-logic.com:9080/t/opentype-code-with-in-it/3866/1

I would like to start by substituting a t with t.longbar if the t is followed by any of a c e g m n o p q s u v w x y z and by substituting a y with y.swashtail if the y follows any of a b c d e h k m n o s u v w x z.

How does one do that please?

William Overington

23 October 2013

The script below is one example on how to achieve this, but there are actually several ways to do it.

Please note that I also added the t.longbar back to the input for the “y”. This will result in the combination of “ty” to be substituted by the alternates as well:
calt.png

script latn {
  # Latin
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup LookupCalt1;
}

group @CaltTInput [a c e g m n o p q s u v w x y z];
group @CaltTMatch [t];

group @CaltYInput [a b c d e h k m n o s u v w x z t.longbar];
group @CaltYMatch [y];

lookup LookupCalt1 {
  context @CaltTMatch (@CaltTInput);
  sub 0 LookupCaltReplace; 
  context  (@CaltYInput) @CaltYMatch;
  sub 0 LookupCaltReplace;   
}

lookup LookupCaltReplace {
  sub t -> t.longbar;
  sub y -> y.swashtail;
}

Thank you.

William

I have made a font and tried it in Serif PagePlus X5.

Here is the font.
Learning_calt_001.otf (26.4 KB)
It mostly works very well though the ty pair has a t.longbar yet not a y.swashtail.

Can readers possibly try this font in whatever OpenType-aware applications that they have available please and post their results?

I have tried adding t into the list just in case PagePlus X5 was using the underlying plain text, but it made no difference.

William Overington

25 October 2013

I have been experimenting and a font with the following code and a few extra glyphs works well in Serif PagePlus X5.

Please note particularly the f.both glyph substitution accessed using three items in the context line of the code.

script latn {
  # Latin
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup LookupCalt1;
}

group @CaltTInput [a c e g m n o p q s u v w x y z];
group @CaltTMatch [t];

group @CaltPInput [a e o u];
group @CaltPMatch [p];

group @CaltGInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltGMatch [g];

group @CaltYInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltYMatch [y];

group @CaltFMatch [f];

lookup LookupCalt1 {

  context (@CaltYInput) @CaltFMatch (@CaltTInput);
  sub 0 LookupCaltReplace2;

  context @CaltTMatch (@CaltTInput);
  sub 0 LookupCaltReplace;
  context  (@CaltYInput) @CaltYMatch;
  sub 0 LookupCaltReplace; 
  context @CaltPMatch (@CaltPInput);
  sub 0 LookupCaltReplace;
  context  (@CaltGInput) @CaltGMatch;
  sub 0 LookupCaltReplace;  
}

lookup LookupCaltReplace {
  sub p -> p.swash;
  sub t -> t.longbar;
  sub g -> g.swashtail;
  sub y -> y.swashtail;
}

lookup LookupCaltReplace2 {
  sub f -> f.both;
}

William Overington

4 November 2013

Interesting. Do you really need a separate function for the f.both glyph substitution? :confused:

By the way, I can confirm that (as per your previous post) León’s ‘ty’ substitution doesn’t give me a y.swashtail in PagePlus.

Yes.

No. I have just tried it as follows and it works in PagePlus X5.

script latn {
  # Latin
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup LookupCalt1;
}

group @CaltTInput [a c e g m n o p q s u v w x y z];
group @CaltTMatch [t];

group @CaltPInput [a e o u];
group @CaltPMatch [p];

group @CaltGInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltGMatch [g];

group @CaltYInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltYMatch [y];

group @CaltFMatch [f];

lookup LookupCalt1 {

  context (@CaltYInput) @CaltFMatch (@CaltTInput);
  sub 0 LookupCaltReplace;

  context @CaltTMatch (@CaltTInput);
  sub 0 LookupCaltReplace;
  context  (@CaltYInput) @CaltYMatch;
  sub 0 LookupCaltReplace; 
  context @CaltPMatch (@CaltPInput);
  sub 0 LookupCaltReplace;
  context  (@CaltGInput) @CaltGMatch;
  sub 0 LookupCaltReplace;  
}

lookup LookupCaltReplace {
  sub p -> p.swash;
  sub t -> t.longbar;
  sub g -> g.swashtail;
  sub y -> y.swashtail;
  sub f -> f.both;
}

It was just an example of my programming style of separating different types of situation.

Thank you for checking that.

William Overington

5 November 2013

It works perfectly in FontCreator’s Font Test dialog and in Mozilla Firefox, so I suspect this is a bug within PagePlus. Maybe there is a work-around, but you’ll have to try and experiment with the script yourself.

I tried the following and it would not compile without error, which is not unreasonable considering the task for which calt is defined.

INCORRECT CODE IN THIS FRAME

script latn {
  # Latin
  feature ContextualAlternates1;
}

feature ContextualAlternates1 calt {
  lookup LookupCalt1;
}

group @CaltTInput [a c e g m n o p q s u v w x y z];
group @CaltTMatch [t];

group @CaltPInput [a e o u];
group @CaltPMatch [p];

group @CaltGInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltGMatch [g];

group @CaltYInput [a b c d e h k m n o s t u v w x z t.longbar];
group @CaltYMatch [y];

group @CaltFMatch [f];

lookup LookupCalt1 {

  context (@CaltYInput) (@CaltYInput) @CaltGMatch (@CaltYInput) (@CaltYInput);
  sub 0 LookupCaltReplace3;

  context (@CaltYInput) @CaltFMatch (@CaltTInput);
  sub 0 LookupCaltReplace2;

  context @CaltTMatch (@CaltTInput);
  sub 0 LookupCaltReplace;
  context  (@CaltYInput) @CaltYMatch;
  sub 0 LookupCaltReplace; 
  context @CaltPMatch (@CaltPInput);
  sub 0 LookupCaltReplace;
  context  (@CaltGInput) @CaltGMatch;
  sub 0 LookupCaltReplace;  
}

lookup LookupCaltReplace {
  sub p -> p.swash;
  sub t -> t.longbar;
  sub g -> g.swashtail;
  sub y -> y.swashtail;
}

lookup LookupCaltReplace2 {
  sub f -> f.both;
}

lookup LookupCaltReplace3 {
  sub g -> g.bigloop;
}

However, is there any way, not necessarily using calt, to achieve the desired result?

For example, the word cabbages to have g.bigloop with the loop extending under the five letters from the second b through to s.

William Overington

7 November 2013

Should theoretically be possible, but I currently don’t have the time to have a look at it.

You can double-click the output line which starts with [Error] to jump to the specific line of your OpenType layout script.
otlscripterror.png