Toggle through 1 set of alternates

Primary tabs

5 posts / 0 new
Last post
Pascal Barry's picture
Offline
Joined: 6 May 2014 - 12:03pm
Toggle through 1 set of alternates
0

Hi there

I'm looking to add a simple alternate feature to a font. The font is purely uppercase but in the lowercase glyphs the font has one set of of alternates (also uppercase design).

We're not after any cutting edge attempts at randomisation, just a simple toggle effect, cycling through so every other time you type a letter the alternate displays. So typing "aaaa" will pull out "aAaA" from the glyphs.

I have looked through a lot of posts and articles and have found much useful information, but can't quite pin down the exact code. I understand it's quite simple and I'm almost there I think. I have created two classes - class1 (uppercase) and class2 (lowercase).

Now I believe I just need a simple piece of code to place here in the opentype panel:

feature xxxx {
sub by ;
} xxxx;

I just can't find anything that has an example of the code, just the effect I'm after described in general terms. If anyone could help me out here, I would be extremely grateful.

Many thanks

Pascal

Reynir Heiðberg Stefánsson's picture
Joined: 19 Nov 2010 - 11:15am
0

If you want/need the toggle only in runs of a character...

sub a a' by a.alt;

might work. The apostrophe, incidentally, points out which character is to be swapped out for the new one.

Nick Curtis's picture
Offline
Joined: 21 Apr 2005 - 8:16am
0

This works for me (code courtesy of Paul Hunt)...

@All=[ 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 œ æ ð ø þ lslash];
@Allalt=[ 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 Œ Æ Ð Ø Þ Lslash];

feature calt {
sub @All @All' by @Allalt ;
} calt;

Christoph Päper's picture
Joined: 25 Apr 2014 - 9:12am
0

Oldnick, that should work except for “œ æ ð ø þ”, because the regular expression to match [[http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.htm...|valid glyph names]] (in AFDKO syntax) is (\\?[A-z_][A-z0-9_.]*|\.notdef). Sorry for nitpicking.

Nick Curtis's picture
Offline
Joined: 21 Apr 2005 - 8:16am
0

You're right: thanks for pointing that out.