Apologies if already answered but I cannot see how to do this. Pointers welcome.
In one of my fonts it uses < f shaped s> . This should become< snake s > at the end of a word or in combination as a double s. That is if followed by space, period,s etc
I am failing to see how to express <fshaped s><period> => <snake s><period> and <fshaped s><space> => <snake s><period> etcetc.
Ordinary ligatures work fine where the target is a single glyph.
thanks
Gareth
Context-sensitive Substitution
-
- Top Typographer
- Posts: 9907
- Joined: Tue Oct 29, 2002 5:28 am
- Location: Seven Kings, London UK
- Contact:
Re: Context-sensitive Substitution
In the OpenType Designer, click on the first button on the toolbar to Generate and Update OpenType Features. Add Historical Ligatures and Historical Forms. (Click the All checkbox to clear all unwanted features).
-
- Moderator
- Posts: 11472
- Joined: Fri Oct 04, 2002 12:41 am
- Location: Bilthoven, The Netherlands
- Contact:
Re: Context-sensitive Substitution
Since OpenType layout features are processed in separate glyph runs, e.g. divided per script, it is not always guaranteed a space character is part of a glyph run as it is a common character, just like punctuation marks.westdale wrote: ↑Thu Dec 15, 2022 4:45 pm Apologies if already answered but I cannot see how to do this. Pointers welcome.
In one of my fonts it uses < f shaped s> . This should become< snake s > at the end of a word or in combination as a double s. That is if followed by space, period,s etc
I am failing to see how to express <fshaped s><period> => <snake s><period> and <fshaped s><space> => <snake s><period> etcetc.
Ordinary ligatures work fine where the target is a single glyph.
thanks
Gareth
It is therefor good practice to use a contextual substitution that starts with an exception that represents the default. This way it will also work at the end of a line.
Here is fea syntax that substitutes the fshapeds if it is not followed by another letter.
Code: Select all
languagesystem latn dflt; # Latin default
@letters = [A-Z a-z fshapeds];
lookup SingleSubstitution1 { # GSUB lookup type SingleSubstitution
sub fshapeds by snakes;
} SingleSubstitution1;
feature calt { # Contextual Alternates
ignore sub @letters' @letters;
sub @letters' lookup SingleSubstitution1;
} calt;
Re: Context-sensitive Substitution
Thank you - most helpful
Re: Context-sensitive Substitution
Hi
while I now understand the aim of this code, I have failed to get it to compile.
I had to make a couple of changes ...
I added the calt feature to the script features
I changed 'by' to '->' to match existing code that worked.
I removed trailing names after the '}' on the subroutines as the compiler objected to them.
I recognise that my version will not cope completely with 'ss' - but I'm starting with the basics.
as in the attached images....
case 1.
the layout editor does not expect the 'ignore' in the feature
case2.
I tried moving the exception into the lookup - as per the open cookbook Style Guide
and that failed as it was not expecting 'sub' after ignore.
I used to test software and know that it could be just a silly error - or a parser case missing.
I can't send the file as modified as it is not allowed to save it --- but any advice would be welcome.
Gareth
while I now understand the aim of this code, I have failed to get it to compile.
I had to make a couple of changes ...
I added the calt feature to the script features
I changed 'by' to '->' to match existing code that worked.
I removed trailing names after the '}' on the subroutines as the compiler objected to them.
I recognise that my version will not cope completely with 'ss' - but I'm starting with the basics.
as in the attached images....
case 1.
the layout editor does not expect the 'ignore' in the feature
case2.
I tried moving the exception into the lookup - as per the open cookbook Style Guide
and that failed as it was not expecting 'sub' after ignore.
I used to test software and know that it could be just a silly error - or a parser case missing.
I can't send the file as modified as it is not allowed to save it --- but any advice would be welcome.
Gareth
- Attachments
-
- Clipboard01.jpg (527.07 KiB) Viewed 1896 times
-
- Moderator
- Posts: 11472
- Joined: Fri Oct 04, 2002 12:41 am
- Location: Bilthoven, The Netherlands
- Contact:
Re: Context-sensitive Substitution
It seems you use an outdated version of FontCreator. It is strongly recommended to use the latest version, as that solves many issues, comes with numerous improvements, and has fea support, while your version seems to use the outdated OTLFD syntax.
Re: Context-sensitive Substitution
Many thanks Erwin. As a retired person who does the occasional specific job for charities, I can't justify the cost of an upgrade - especially as simple additional glyphs work fine in my current version. Thanks for your help and for taking the trouble to reply.
-
- Moderator
- Posts: 11472
- Joined: Fri Oct 04, 2002 12:41 am
- Location: Bilthoven, The Netherlands
- Contact:
Re: Context-sensitive Substitution
I understand. Not sure if this helps, but we do offer a 50% discount for non-profit and educational purposes.
Here is the feature code in OTLFD format:
Here is the feature code in OTLFD format:
Code: Select all
script latn {
feature ContextualAlternates;
}
class @letters [A-Z a-z fshapeds];
feature ContextualAlternates calt {
lookup ChainingContext1;
}
lookup ChainingContext1 {
ignore context @letters (@letters);
context @letters;
sub 0 SingleSubstitution1;
}
lookup SingleSubstitution1 {
sub fshapeds -> snakes;
}