Fontlab OpenType newbie contextual alternates confusion

littletimmy's picture

hello...

I'm attempting to make a font with some OpenType features for the first time, using Fontlab, and, guess what - it's slightly confusing...

what I'd like OpenType to do is:
for lots of specific character pairs, substitute pairs of alternate characters

so, for example, if someone types 'AB' I'd like OpenType to substitute glyph A_2 followed by glyph B_2...

I was kind of thinking I could do this with a contextual alternate feature like

sub A' B' by A_2 B_2;

but that doesn't seem to compile

sub A B' by B_2;

compiles OK, but doesn't really do what I want...

does what I'm trying to do make any sense? is it possible?

would a better way be to make all my desired glyph combinations as ligature glyphs? (and also make all the individual alternate glyphs separately available)

any help would be great

John Hudson's picture

OpenType doesn't support many-to-many substitutions. So you need to do this as two steps:

A -> A.2
when followed by B

then

B -> B.2
when preceded by A.2

gargoyle's picture

In the AFDKO/FontLab syntax, that would translate to:

sub A' B by A.2;
sub A.2 B' by B.2;

For glyph names, underscores are customarily used to indicate ligatures between two characters, and periods to precede suffixes. Suffixes might also be more descriptive if you have different kinds of alternates– i.e. .alt[x] for general alternates, .swsh[x] for swashes, (where [x] is a numeric index), .smcp for small caps, etc.

Bob H's picture

OpenType doesn't support many-to-many substitutions.

Actually it seems to me that OpenType *does* permit m2m substitutions (using GSUB type 5 or 6 lookups) but none of the common tools (VOLT and AFDKO) provide a way to express these such rules.

So I've often wondered if rendering engines actually support m2m lookups or not?

Theunis de Jong's picture

I've often wondered if rendering engines actually support m2m lookups or not?

I should really double-check this, but I think InDesign does. I constructed a many-to-many translation with a TTX dump as intermediary.

charles ellertson's picture

For glyph names, underscores are customarily used to indicate ligatures between two characters

More than custom. IIRC, when generating a PDF, that's what the Adobe engine will assume & make happen. So, if you have a glyph named A_B in your font, that glyph will become the two characters A & B in a PDF text stream. (Or, I may not RC...)

A period is what you want; everything after the period is dropped. So, "A.(anything)" remains "A".

gargoyle's picture

Thanks for elaborating, Charles. That's my understanding as well, but was trying to stay succinct with the naming advice. No doubt the topic has been discussed here before at some point.

charles ellertson's picture

Publisher A decides to take a book out of print, and sell the rights to publisher B. They supply PDF files, without fonts, of course. Publisher B has to take the text stream & use it for the resetting.

And you're trying to be succinct? I've been involved in a few projects where recovering the text was, shall we say (amongst other choice words), expensive.

Or did you mean you wouldn't write the code that way, it was just for this example? Don't scare old people like me. Use a period, even in examples.

gargoyle's picture

Charles, perhaps I was not clear. I did use a period in my example code, then succinctly advised the original poster to use periods instead of underscores for suffixes, without fully elaborating on the matter. You explained the technical reasons behind this practice, so I thanked you for taking the time to do so (whereas, in my succinctness, I had not) and linked to a more detailed discussion on the topic. So I'm pretty sure we're in agreement.

littletimmy's picture

thanks everyone for your replies and the ensuing discussion... I've realised there was some illogic in what I was trying to do and, in figuring that out, and considering your contributions, I am now somewhat wiser!

Syndicate content Syndicate content