Typophile

Contextual Alternates: limit to massive use

Igor Freiberger

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.

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.

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

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.

Thanks again. I'll follow your advice!

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.

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?

Just with CALT on, using CS3 on Mac.

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.

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.

The roman numeral thing has been done before:

http://new.myfonts.com/fonts/ihof/p22-operina/

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.

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.

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.

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.

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!

@ 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.

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;

===========

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

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

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.

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.

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?

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.

@ 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.

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.

André

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:

@NUMBERS=[@ONE @TWO @THREE @FOUR @FIVE @SIX @SEVEN @EIGHT @NINE @ZERO];

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 one' @NUMBERS @NUMBERS @NUMBERS by M.sc;
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;
} THOUSANDS;
lookup HUNDREDS {
ignore substitute @NUMBERS' @NUMBERS @NUMBERS @NUMBERS;
sub one' @NUMBERS @NUMBERS by C.sc;
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 D.sc;
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;
} HUNDREDS;
lookup TENS {
ignore substitute @NUMBERS' @NUMBERS @NUMBERS;
sub one' @NUMBERS by X.sc;
sub two' @NUMBERS by twoten.rm;
sub three' @NUMBERS by threeten.rm;
sub four' @NUMBERS by fourten.rm;
sub five' @NUMBERS by L.sc;
sub six' @NUMBERS by sixten.rm;
sub seven' @NUMBERS by seventen.rm;
sub eight' @NUMBERS by eightten.rm;
sub nine' @NUMBERS by nineten.rm;
} TENS;
lookup UNITS {
ignore substitute @NUMBERS' @NUMBERS;
sub one' by I.sc;
sub two' by two.rm;
sub three' by three.rm;
sub four' by four.rm;
sub five' by V.sc;
sub six' by six.rm;
sub seven' by seven.rm;
sub eight' by eight.rm;
sub nine' by nine.rm;
} UNITS;
lookup ZEROS {
sub zero' by zero.rm;
} ZEROS;
} 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.

A PDF with code and comments is available here:
http://if.pro.br/RomanNumerals.pdf

A font for test, based on FreeFontPro, is here:
http://if.pro.br/FreeRoman.otf

Captured from web.archive.org on 20 Feb 2010. view this capture