Typophile

Toggle through 1 set of alternates

pascal6839

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

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.

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;

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

You're right: thanks for pointing that out.

Captured from web.archive.org on 2 Jul 2014. view this capture