Opentype: detect first glyph of line

It’s relatively easy to detect an opening or closing glyph for say swapping out with swash alternates. Does anyone know if it’s possible to detect a first letter of a line? Theoretically you could substitute linebreak+glyph for glyph.alt. I can’t find anything to suggest this is possible. Anyone considered this?

1 Like

You can try ignoring preceding letters and spaces in the lookup.

Depends on how the engine of the respective app keeps the character stream available for GSUB features. An OT feature needs a glyph to substitute. If the engine does not take your CR glyph for it, but renderers it simply without it, you’re out of luck. You can try it. But it is very unlikely it will work in most, let alone all renderers. Pretty sure this will not work in Adobe apps.

Thanks for that - lots to consider.

Normally, the substitutions are applied for each line individually. And on top of this, each format or font change will make a new context. So your substitution that normally will only be applied at the beginning if the line will show up if there is something in Italic in the line.

Actually its quite easy:
You need a few classes: 1 for all the glyphs, 1 for the uppercases you want to replace, and 1 for the swashes (or whatever effect you want to activate).
Then you can do:
ignore sub [@all @effect] @all'; sub @caps' by @effect;
And you get this:

It’s pretty cool, but I’m not sure it will be useful for the users…

But then change the formatting just before a word in the middle of the line (set the ‘space’ before ‘Open’ to a different font or size)