Page 1 of 1

Best way to do this substitution

Posted: Tue Jul 19, 2016 4:57 pm
by Siavash
Hi,

I have designed fonts before. Persian fonts. But I had never changed too much the OpenType features except the ligatures and intial, medial,... and diacritics and stuff like that.

But now I'm designing a Persian font with detached separated glyphs (like a Latin one).

And I have decided to do a {salt}. But it is a little complicated and I only do these things with the Open Type Designer, so maybe it is my lack of scripting capabilities.

It goes like this:

Substitute Kaf (only inital and medial) with a glyph I added myself to the Persian standard glyphs named _longKaf if all the next glyphs after Kaf are some glyphs gathered in a Class for example @NotDotAbove. Also do all of these just when users set the text to {salt}.

So I want to know which kind of substitution works better here and how? I did single sub, it worked but does the sub all the time.

Any help? :!: :?:

Re: Best way to do this substitution

Posted: Tue Jul 19, 2016 5:33 pm
by Bhikkhu Pesala
I think what you need is a contextual substitution (calt)

Re: Best way to do this substitution

Posted: Tue Jul 19, 2016 6:53 pm
by Siavash
Thanks.

I did that too, but I can't make that to ignore some glyphs. It would apply the substitution at all times.
Should I use ChainingContext?

Re: Best way to do this substitution

Posted: Tue Jul 19, 2016 7:19 pm
by Bhikkhu Pesala
I have only ever used a chaining context for Ordinals.
Ordinals Feature.png
Ordinals Feature.png (33.21 KiB) Viewed 2462 times
I think what you need is a Reverse Chaining Context

Re: Best way to do this substitution

Posted: Tue Jul 19, 2016 10:03 pm
by Siavash
Could you please tell me how to replace 2 glyphs with 1 new glyph but only when:

1- Certain Class is in front of the 2 glyphs.
2- Text is set on a salt or calt.

And also do this with reverse chaining context?

I really don't know! :(

Re: Best way to do this substitution

Posted: Fri Aug 12, 2016 12:23 pm
by Erwin Denissen
Siavash wrote:Could you please tell me how to replace 2 glyphs with 1 new glyph but only when:

1- Certain Class is in front of the 2 glyphs.
2- Text is set on a salt or calt.
Here is some OpenType layout feature code that will replace "12" with "3" if it is typed after a capital letter:

Code: Select all

script latn {
  feature ContextualAlternates1;
  feature StylisticAlternates1;
}

class @Uppercase [A B C D E F G H I J K L M N O P Q R S T U V W X Y Z];

feature ContextualAlternates1 calt {
  lookup ChainingContext1;
}

feature StylisticAlternates1 salt {
  lookup ChainingContext1;
}

lookup ChainingContext1 {
  context (@Uppercase) one two;
  sub 0 Ligature1;
}

lookup Ligature1 {
  sub one two -> three;
}
Siavash wrote:And also do this with reverse chaining context?

I really don't know! :(
The above sample should provide enough information for you to get started.