Typophile

Advanced opentype question

Frode Bo Helland

If I select a portion of text and apply an opentype feature, is it possible to only make changes to the last [insert number] characters? I’d have to count backwards from the last character in the selection.

Edit: Fixed typo in title.

And another related question: Can OT count the number of characters selected?

OT doesn't work on characters; it works on glyphs. There is no concept in OTL of 'end of selection'.

Are you actually trying to reduce the size of the glyphs, as shown in your example, or is this just an illustration? In order to achieve this appearance using OTL, you font would need to contain sized alternates: you can't actually change the font size via OTL, and in any case a change of text size normally terminates a glyph run for OTL processing.

I am trying to reduce the size. Someone asked me if it was possible to have an effect like this in an OT feature. If so, I would have drawn four or five sets of sized alternates and substituted them counting backwards from “end of selection”.

You’ve answered my question and obviously it can’t be done this way.

Thanks.

You could do it with a trigger glyph. So rather than having the context run backwards from the end of the selection you would insert the trigger glyph at the end of the selection and use that as the first context glyph. You would use a series of contextual lookups, something like this (using VOLT syntax; sorry, I don't do AFKDO):

letter -> letter.smallest
| trigger

letter -> letter.smallerstill
| letter.smallest

letter -> letter.smaller
| letter.smallerstill

letter -> letter.small
| letter.smaller

and finally you would remove the trigger glyph from the string like this:

letter.smallest trigger -> letter.smallest

I don’t get the syntax yet, but I think I get the concept. Thanks John!

Say I’d set this up with “]” as the trigger glyph, could I write “]5” and somehow use the number to determine how many letters my feature would affect?

if “]1” — run feature one step
if “]2” — run feature two steps
if “]3” — run feature three steps
if “]4” — run feature four steps
if “]5” — run feature five steps
if “]6” — run feature six steps
if “]7” — run feature seven steps
if “]8” — run feature eight steps
if “]9” — run feature nine steps

Or better yet: Could I determine the number of glyphs in the textbox?

I don't see a way to do this with OT. But you can get this effect with InDesign GREP styles – and thus no need to create a set of different sized glyphs.

Even if I could tell, it doesn’t seem to be any way to divide that number by X to get the length of my steps.

You could hack a trigger for context length like this:

letter -> letter.small
| J 4

followed by

letter -> letter.smaller
letter.small |

letter -> letter.smallerstill
letter.smaller |

letter -> letter.smallest
letter.smallerstill |

and then

letter.smallest J 4 -> letter.smallest

to remove the trigger glyphs.

But just because it might be possible doesn't mean it's a good idea.

True. The number of alternates alone — and that’s even before I consider the contextual alternates and ligatures involved in the base font — is daunting.

Captured from web.archive.org on 8 Jul 2010. view this capture