Substitute the first letter of a word using opentype?

Primary tabs

16 posts / 0 new
Last post
Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
Substitute the first letter of a word using opentype?
0

I'm trying to figure out if there's a way to substitute the first letter of a word for an alternate version. I don't want the rest of the s's in the word to swap also like how standard swashes would work. I'd like it to be automatic so you don't have to hit the alternates every time.

The only way I can think to do it is to substitute the s using the space before the word as a ligature. But that doesn't help when there is other punctuation going on.

Any ideas?

Eric Menninga's picture
Offline
Joined: 15 Jun 2007 - 4:45pm
0

This isn't a great option because it only works with InDesign CS3, but we started supporting the OpenType features 'init', 'fina', 'isol', and 'medi' which can be dynamically applied to characters. These correspond with "initial letter", "final letter", "isolated letter" and "medial letter". It is only semi-smart, but can handle punctuation around words for example.
A more universal approach involves some complex contextual processing which is why Thomas Phinney suggested adding support for the positional forms feature.

Chris Lozos's picture
Offline
Joined: 25 Feb 2004 - 11:00am
0

Are not positional forms required for proper Arabic anyway?

ChrisL

Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

Yeah, would prefer something that works in CS2 apps (AI, InDesign).

I may just have to resort to the manual swashes and the client will just have to use them at their leisure.

Matt

Mark Simonson's picture
Offline
Joined: 3 Dec 2001 - 11:00am
0

Create a class that contains all glyphs that are letters (or anything else you consider to be part of a word). Then, set up a contextual substitution in which if a glyph is not preceded by a member of that class, use the alternate.

Here's one way to do it. In the following code, the classes are defined thus:

@letter = any glyphs you consider part of a word;
@normal_letter = any glyphs that have a different form for the beginning of a word
@alternate_letter = the alternate versions of the glyphs in @normal_letter

The contextual substitution (to be placed in the calt feature):


   lookup beginnings {
      ignore sub @letter @normal_letter' ;
      sub @normal_letter' by @alternate_letter;
   } beginnings;

Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

Ahh, must be smarter than fontlab.

This looks like it should work, but I'm getting a weird "invalid token (text was "@")" error when I try to compile.

Mark Simonson's picture
Offline
Joined: 3 Dec 2001 - 11:00am
0

If you copied the text from here and pasted it in, you might get some trouble with the non-breaking spaces I used for the indents at the beginning of the lines. If not, then make sure you've got all your ticks and semicolons accounted for...

Eric Menninga's picture
Offline
Joined: 15 Jun 2007 - 4:45pm
0

To belatedly reply to Chris: yes, positional forms are required for some scripts (including Arabic) and are applied automatically by InDesign ME (all versions, not just CS3) but the new thing added in CS3 was adding positional forms as an option for non-ME InDesign.

Chris Lozos's picture
Offline
Joined: 25 Feb 2004 - 11:00am
0

Oh, I see. Prior to that, an ME version was required. Thanks!

ChrisL

Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

OK, got rid of the error. Now I got this script to work with one letter substitution... What If I have dupes for all 26 letters? Do I need to make classes for each letter?

Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

Never mind. I'm dim sometimes. It was replacing the letters with the blank spots I had for all of the glyphs. D'oh, it's beer time.

Thanks a ton Mark!!!

Göran Söderström's picture
Joined: 15 Feb 2006 - 2:53am
0

I was just looking for that kind of thing, thanks for a quick way of describing it.

Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

Paging Mark Simonson!

I understand how this method works now.
Is there a way to use this same technique for replacing the end letter of a word?

I am just no good at making the code do what I want it to do...

paul d hunt's picture
Offline
Joined: 5 May 2005 - 8:44pm
0
Matthew Desmond's picture
Offline
Joined: 27 Jul 2000 - 11:00am
0

After reading that other thread, I got it. Thanks Paul.

paul d hunt's picture
Offline
Joined: 5 May 2005 - 8:44pm
0

sorry i didn't link to it earlier. :^p