Contextual Alternates: limit to massive use

Igor Freiberger's picture

I'm designing my first typeface, a contemporary serif family with four weights. I'd like to use massive contextual alternates (as in Kinescope or Vesper), but I have doubts about the limits to use this feature.

I plan to adopt contextual alternates through stylistic sets for these situations:

1. beginnings and endings;
2. glyphs collisions and undesired optical effects;
3. typesetting special symbols as arrows and flourishes;
4. Roman numerals;
5. chess notation with figurines (unsure about this one);
6. mathematical symbols and expressions.

Besides this, there would also be optional variations in some glyphs (typically, Q, R, f, a) which could also be set with stylistic sets.

So, is there any problem to set dozens or even hundreds of contextual alternates in OT tables? This may cause poor performance?

I understand some of the situations I listed could be addressed with GREP styles in InDesign (as Roman numerals and chess notation), but it would be nice if the font had all these features.

weinziet's picture

There won't be any performance issues. Similarly, there could be, and usually are, tons of lookups in the GPOS kern feature which don't effect rendering performance.

Some of the alternates you plan to design may be better suited in other features, such as Stylistic Alternates and Discretionary Ligatures.

Igor Freiberger's picture

Thanks, Terrance.
Which features do you consider to be best defined as Stylistic Alternates or Discricionary Ligatutes?

weinziet's picture

Well, stylistic alternates are usually for the 'optional variations' as you described it, like a g, a, tail on Q, etc.

Be careful with ligatures too, try to resolve glyph collisions with sidebearings and kerning first.

Spend some time looking at the features and how they are used with other designs.

Igor Freiberger's picture

Thanks again. I'll follow your advice!

blank's picture

The only program I’ve run into that has problems with numerous lookups is Illustrator, which can lag as much as a second when I type in the characters from my font Black Monday. But in that case every single character is cycled by CALT.

Igor Freiberger's picture

James, this may be an issue. Do the Illustrator delay occurs just when Contextual Alternates are turned on? Which IL version are you using? Mac or Windows?

blank's picture

Just with CALT on, using CS3 on Mac.

Mark Simonson's picture

For what it's worth, I haven't noticed any performance hit on any of the fonts I've done that have "advanced" contextual stuff in them, in Illustrator or otherwise. They seem to display just as fast as any other font. Maybe they're not "advanced" enough.

Igor Freiberger's picture

Thanks again for these valuable inputs.

I still did not saw the use of CALT to substitute Arabic/Roman numbers. As the font is (also) designed to be used in legal texts, the idea is to typeset something like 48 and to have XLVIII in an automatic way. Maybe the idea is very much strange...

The possibility to combine chess figurines or typical computing itens (keyboard shortcuts, icons) seems also uncommon. Hope this would not be excessively out of CALT purpose.

Mark Simonson's picture

The roman numeral thing has been done before:

No idea how it works. P22 has done some unusual things with calt, including a font that answers questions sort of like a Magic 8 Ball.

Igor Freiberger's picture

It's really hard to be original these days. :-)

The feature P22 built is very smart. I believe they used nested lookups to achieve the substitution to any number, starting with units and adding set of ten, hundreds and thousands in a hierarchical way. Need to learn further about this.

Thanks for the tip, Mark.

Nick Shinn's picture

I put four versions of each character in Duffy Script, and they cycle character-by-character using the "calt" feature, for a pseudo-random effect. I did notice a slight delay when opening large multi-page documents, but not something that might be attributed specifically to a font. I should add that this an entirely subjective observation, I haven't made any measurements or calculations.

twardoch's picture

There is some performance hit, but very little, and mostly noticed on older computers and older computer systems.

In the Zapfino Extra LT Pro code that I developed in 2003, there are about 600+ contextual substitutions in about a dozen lookups. In applications such as InDesign CS2 and Notepad running on Windows XP, tested some 4-5 years ago, there was a performance hit, i.e. using a really long text (100 pages or so), it does take noticeably longer time to lay out the pages than when a "regular" font is used.

Though in InDesign, after the initial delay in laying out the pages, the performance is good, since InDesign caches the glyphs. In Notepad, such caching does not take place, so even scrolling up and down the pages was kind of slow.

But such complex fonts are rarely used for continuous text that has hundreds of pages. Plus, the computers and the applications have gotten faster in text processing. So the problem is going away. And the benefits of smart fonts are in my opinion worth paying the (small) price.

Michael Hernan's picture

Careful with Roman numerals.
I had set these up as regular ligatures of numbers (there is probably another node advising against this).
It worked well - however inDesign seems to have ligatures switched on as default so all numbers above 9 became Roman numerals when entering in un-styled raw text.
I have since learned the lesson had have made into a Stylistic Set!

Igor Freiberger's picture

@ All: thank you very very much! It's an honor to receive advices from masters in type design. My plan is to use stylistic sets as this:

1. glyph alternates for lowercase (a, f, g, k, y);
2. glyph alternates for uppercase (G, K, R);
3. beginnings;
4. endings;
5. Roman numerals;
6. alternates for undesired optical effects;
7. arrows, flourishes and dingbats;
8. math symbols and alternates for math expressions;
9. figurine chess notation.

Of course, now I have to discover how to do the Roman numerals substitution for all numbers using OT lookups. The other I believe I already discovered how to (although I did not tested all this as the design is just beginning).

Again, thank you all.

Michael Hernan's picture

See if this suits you..
Note - I have added roman numerals upto 16 in my fonts as this is an expected usage of numbering of the 1st section in a book. ie 16 pages in a section.

I notice I have not updated the code to reflect this, but will post as is so I don't mess up what I have already.

Note # The order is important :
I think I found through trial and error that this order seemed to work.
I still need to retest this, but I think it works...

Note #testing if ligatures work in SS:
Self fulfilling prophesy! Here I am testing it.


feature ss05 {

# Romansmall
# Ligatures
# The order is important
sub one' zero' zero' zero' by onethousandroman;
sub one' zero' zero' by onehundredroman;
sub five' zero' zero' by fivehundredroman;
sub one' zero' by tenroman;
sub one' one' by elevenroman;
sub one' two' by twelveroman;
sub one' three' by thirteenroman;
sub one' four' by fourteenroman;
sub one' five' by fifteenroman;
sub five' zero' by fiftyroman;
sub one by oneroman;
sub two by tworoman;
sub three by threeroman;
sub four by fourroman;
sub five by fiveroman;
sub six by sixroman;
sub seven by sevenroman;
sub eight by eightroman;
sub nine by nineroman;

#testing if ligatures work in SS

} ss05;


here is my swap from lowercase to uppercase Roman numerals:
@roman1 being lowercase
@roman2 being the Caps version


feature ss03 {
# Stylist Set: Roman Large

sub @roman1 by @roman2;

} ss03;


Igor Freiberger's picture

Thank you, Michael. Wonderful help! I'll try it later and then bring you back the results.

Igor Freiberger's picture

One of my targets are legal texts. Brazilian Constitution has a sequence of itens numbered in Roman which goes until LXXVIII (!).

Michael Hernan's picture

When ordering the Stylistic sets the set changing from lowercase to Capital Roman numeral style needs to come last.

In my example above I have changed the order so that what was SS03 is now SS06.

Michael Hernan's picture

Actually converting a date like 2012 to a roman numerals as you are trying to do is difficult and will need further input.
I have settled for a compromise and am limiting use to automatically change two numbers to small roman numerals for folios, with an option to change the result to Large Roman Numerals.

I was considering a database or a modular approach but neither seemed workable.
If your usage was for current dates you could create glyphs for the next 10 years perhaps?

For me the limit is that OpenType allows for a string in, like f_f_l but can only out put a single glyph and not a composite of 2 or more glyphs (to my knowledge).
There might be a solution if you were able to set up conditions like "IF there are 4 numbers together treat the first one like this and the second like this... ex-cetera" but this is way beyond me.

Good luck.

riccard0's picture

One of my targets are legal texts. Brazilian Constitution has a sequence of itens numbered in Roman which goes until LXXVIII (!).

Shouldn't it be leaved to layout programs instead of fonts?

agisaak's picture

You can map a single character to multiple glyphs using AFDKO, but many applications don't currently recognise this type of substitution. Moreover, I agree with riccardO that this really is more appropriate for the application to implement rather than the font.

Igor Freiberger's picture

@ Michael: thanks again for the input.

@ Riccard0 and Agisaak: sure, you're right. As I stated above, features like Roman numerals may be best suited for InDesign GREP styles. But the possibility to have automatic number substitution through OT hooked me. At least, it's an opportunity to learn more about OT tables and features.

I'm testing a way to have this substitution for almost all numbers. Of course, this is just useful if does not cause hundreds of lines of code. If I get it done, I'll share here.

agisaak's picture

Well, without using one to many substitutions, this would be fairly straightforward provided you included ligatures for roman numerals 2, 3, 4, 6, 7, 8, 9, 20, 30, 40, 60 and 70 (assuming you only want to go as high as LXXVIII). To produce larger numbers you'd need more ligatures, but it would remain manageable. A simple ignore statement could be used to prevent the feature from applying to numbers which fall outside of the range.

I'll leave the actual code as an exercise for the reader.


Igor Freiberger's picture

Automatic Roman numerals from Arabic ones

I created a code to apply automatic substitution to any number from 1 to 9999. With just 37 substitutions, the code seems to be fair. But as I'm a novice, it may be improved by more experienced designers.

To proceed all substitutions, the font needs 30 additional glyphs. And the principle behind all these substitution could be used in other similar procedures.

Firstly, you need a class which brings together all numeric figures in the font:


Then, you create a Stylistic Set with four lookups of substitutions, ordened this way: thousands, hundreds, sets fo ten and units:

feature ss09 {
lookup THOUSANDS {
sub two' @NUMBERS @NUMBERS @NUMBERS by twothousand.rm;
sub three' @NUMBERS @NUMBERS @NUMBERS by threethousand.rm;
sub four' @NUMBERS @NUMBERS @NUMBERS by fourthousand.rm;
sub five' @NUMBERS @NUMBERS @NUMBERS by fivethousand.rm;
sub six' @NUMBERS @NUMBERS @NUMBERS by sixthousand.rm;
sub seven' @NUMBERS @NUMBERS @NUMBERS by seventhousand.rm;
sub eight' @NUMBERS @NUMBERS @NUMBERS by eightthousand.rm;
sub nine' @NUMBERS @NUMBERS @NUMBERS by ninethousand.rm;
lookup HUNDREDS {
sub one' @NUMBERS @NUMBERS by;
sub two' @NUMBERS @NUMBERS by twohundred.rm;
sub three' @NUMBERS @NUMBERS by threehundred.rm;
sub four' @NUMBERS @NUMBERS by fourhundred.rm;
sub five' @NUMBERS @NUMBERS by;
sub six' @NUMBERS @NUMBERS by sixhundred.rm;
sub seven' @NUMBERS @NUMBERS by sevenhundred.rm;
sub eight' @NUMBERS @NUMBERS by eighthundred.rm;
sub nine' @NUMBERS @NUMBERS by ninehundred.rm;
lookup TENS {
ignore substitute @NUMBERS' @NUMBERS @NUMBERS;
sub one' @NUMBERS by;
sub two' @NUMBERS by twoten.rm;
sub three' @NUMBERS by threeten.rm;
sub four' @NUMBERS by fourten.rm;
sub five' @NUMBERS by;
sub six' @NUMBERS by sixten.rm;
sub seven' @NUMBERS by seventen.rm;
sub eight' @NUMBERS by eightten.rm;
sub nine' @NUMBERS by nineten.rm;
lookup UNITS {
ignore substitute @NUMBERS' @NUMBERS;
sub one' by;
sub two' by two.rm;
sub three' by three.rm;
sub four' by four.rm;
sub five' by;
sub six' by six.rm;
sub seven' by seven.rm;
sub eight' by eight.rm;
sub nine' by nine.rm;
lookup ZEROS {
sub zero' by zero.rm;
} ss09;

Note the last lookup is a trick: to remove the zeros I applied a general substitution to a glyph zamed zero.rm. This glyph is empty and has zero width. So, all the zeros are hidden.

It's running OK in the tests I made.

Igor Freiberger's picture

A PDF with code and comments is available here:

A font for test, based on FreeFontPro, is here:

Igor Freiberger's picture

The serif project I did mention could be previewd in the Critique section:

Michael Hernan's picture

@riccard0 and @agisaak
You are both right in saying this *should* be managed through the software. [I'm not aware that it is currently available] Please write to Adobe and request it!
Until that time, I am pretty hyped by this solution.

@Freiberger. I got back on this today. Perhaps I can push this on a little further?

I notice that the code in your pdf and the code in the Font are handled slightly differently. Both will work I believe.

Keeping close to what was used in the font and therefore relying on the @ordn1 rather than @numbers I did the following - but updated the naming of the glyphs to reflect the fact that I see this code for the capitalised versions of the Roman Numerals.
Also because there are existing names and unicodes for some of the Roman Numerals – I am using these.

Though using small caps letters is an elegant shortcut, I have decided to have actual numbers used. Traditionally Roman numerals are not letters but are their own expression, I am creating new glyphs for the M, C, L and D.

feature ss09 { # Stylistic Set 9
# Latin
# Advanced Roman Numerals Converter
# 1-9999

lookup THOUSANDS {
sub one' @ordn1 @ordn1 @ordn1 by Onethousandroman;
sub two' @ordn1 @ordn1 @ordn1 by Twothousandroman;
sub three' @ordn1 @ordn1 @ordn1 by Threethousandroman;
sub four' @ordn1 @ordn1 @ordn1 by Fourthousandroman;
sub five' @ordn1 @ordn1 @ordn1 by Fivethousandroman;
sub six' @ordn1 @ordn1 @ordn1 by Sixthousandroman;
sub seven' @ordn1 @ordn1 @ordn1 by Seventhousandroman;
sub eight' @ordn1 @ordn1 @ordn1 by Eightthousandroman;
sub nine' @ordn1 @ordn1 @ordn1 by Ninethousandroman;
lookup HUNDREDS {
ignore sub @ordn1' @ordn1 @ordn1 @ordn1;
sub one' @ordn1 @ordn1 by Onehundredroman;
sub two' @ordn1 @ordn1 by Twohundredroman;
sub three' @ordn1 @ordn1 by Threehundredroman;
sub four' @ordn1 @ordn1 by Fourhundredroman;
sub five' @ordn1 @ordn1 by Fivehundredroman;
sub six' @ordn1 @ordn1 by Sixhundredroman;
sub seven' @ordn1 @ordn1 by Sevenhundredroman;
sub eight' @ordn1 @ordn1 by Eighthundredroman;
sub nine' @ordn1 @ordn1 by Ninehundredroman;
lookup TENS {
ignore sub @ordn1' @ordn1 @ordn1;
sub one' @ordn1 by Tenroman;
sub two' @ordn1 by Twentyroman;
sub three' @ordn1 by Thirtyroman;
sub four' @ordn1 by Fourtyroman;
sub five' @ordn1 by Fiftyroman;
sub six' @ordn1 by Sixtyroman;
sub seven' @ordn1 by Seventyroman;
sub eight' @ordn1 by Eightyroman;
sub nine' @ordn1 by Nintyroman;
lookup UNITS {
ignore sub @ordn1' @ordn1;
sub one' by Oneroman;
sub two' by Tworoman;
sub three' by Threeroman;
sub four' by Fourroman;
sub five' by Fiveroman;
sub six' by Sixroman;
sub seven' by Sevenroman;
sub eight' by Eightroman;
sub nine' by Nineroman;
lookup ZEROS {
sub zero' by zeroroman;
} ss09;

Igor Freiberger's picture


when I built up this solution I was unaware about Unicode glyphs to Roman Numerals. Of course, I think they must be used and also determines the name format to other glyphs created to Romans.

I'll remain to small caps instead of creating new glyphs to I, V, X, L, C, D and M. My choice is because the font has 1,600 glyphs now (and counting!), even without Greek and Cyrillic support. So I'm trying to keep it less huge.

As long as I can see, our code is the same. The difference resides on the class you used and the glyph naming criteria, no?

This Roman Numerals question gave me some other ideas – as to simulate ink variations found in old metal type prints. Probably I'll never use them (as the 'palimpsest project' is the only font I plan to create) but OT possibilities are great.

Nick Shinn's picture

A roman font should have no space character...or replace it with a centered period.

Igor Freiberger's picture

Sorry Nick, but I did not understand. No space character? Are you referring to Classic Latin, when word separation was made with centered periods and diamonds?

Michael Hernan's picture

@Freierger Again thanks for working on this. I have now dropped this in one of my fonts, which also has small roman ligatures from i to xvi (i.e to cover the first signature in a book).

Roman and Unicode: Check: Fileformat Unicode Page

Ink effect: interesting challenge!
Randomised characters are talked about elsewhere on this board in a couple of places. @Nick might know?

Syndicate content Syndicate content