OpenType alternate substitutions (FLab)

porky's picture

I have a feeling this is either very easy or very hard/impossible.

I am in the middle of building a unicase typeface that is designed to use alternative adjacent characters. Currently, Set 1 is mapped to the uppercase and Set 2 is lowercase, but they will need to be re-ordered for the system to work correctly.

What I would like to be able to achieve in FontLab is to be able to alternate these on the fly, rather than the user having to swap on the fly by hand.

So, if I type "Thomas Phinney may know", then the substitutions would be "ThOmAs PhInNeY mAy KnOw" - the very first character is the 'seed', so to speak, and all characters after that alternate.

I'm a tad out of my depth. After reading the manual and consulting with a very nice Frenchman, it seems likely that I need to set up a context-dependent substitution - the FLab manual gives the example of replacing a smallcap with a lowercase letter if preceeded by a capital, but that technique isn't 'chaining' (for want of a better word) a whole series of substitutions.

Can anyone help? Is this even possible?

Thomas Phinney's picture

This is actually not very hard at all to program, although (in my quick formulation at least) it requires you use placeholder glyphs for intermediate processing, and multiple lookups. Actually, FontLab will automatically break this into multiple lookups if you don't, so you can ignore that part in my sample code; I just put it in there for those who need/want to understand an extra level "under the hood."

So here's my solution, expressed in FontLab/FDK syntax. I tested a first version of this, so I'm pretty sure it works. The only thing that needs to be done is define and add a set of placeholder glyphs and enumerate them, where I have referred to [@placeholders].

feature calt { # Connection Forms
# Latin

lookup calt1 {

sub [A-Z] [A-Z]' by [@placeholders] ;
sub [a-z] [a-z]' by [A-Z] ;

} calt1;

lookup calt2 {

sub [@placeholders] by [a-z];

} calt2;

} calt;

porky's picture

You are truly a king amongst men, Thomas. My laptop's battery is dead so I'm going to run to Piccadilly Circus tube to get home as soon as possible and try this out.

Many many many thanks!

David

Syndicate content Syndicate content