Liga substitution (non-script sensitive)

I have an issue with a very simple substitution of a greek beta with an alternate beta when it is in the beginning of a word (so I have the following substitution: sub space beta' by beta.alt; inside the liga feature) but I noticed that the substitution works only when the word before the space is also greek (e.g. δοκιμή βιϐλίο ― correct beta substitution) and doesn't work when the preceding word is not greek (e.g. test ϐιϐλίο ― no substitution at all). I don't define any specific script before the substitution (e.g. script DFLT; or script grek;). Any ideas why this is happening? Thanks in advance.

Comments

  • It most likely fails because you mix two scripts, and the space is the last character in the Latin run, while the Greek run starts with the beta. It will also fail if you start a new sentence with the Greek beta.
  • George Triantafyllakos
    edited September 2022
    Thank you Erwin, I understand that (even though it's weird that the space is part of one or another script since it's common in all scripts). Do you think there is a way to overcome this (programmatically, that is)?
  • John Hudson
    John Hudson Posts: 3,229
    edited September 2022
    You should do the substitution in the opposite direction: make β the default beta, and then substitute ϐ when preceded by any letter. This is much more robust than using the /space glyph in the substitution context, and will also apply the substitution at the beginning of lines, after tabs, after word-initial punctuation, after other kinds of spacing characters, etc.

    Yes, the space character is script=common, but for OpenType Layout purposes this means it gets rolled into the glyph run with preceding characters. It is not shared between glyph runs.
  • Setting your alternate up as a positional alternate with opentype ignore sub statements might avoid the trouble with the space you're having. It will also enable the substitution when the word wraps to a new line (which I guess you also want, but your current code won't handle). 
  • Thank you both. I will try your solutions out.
  • Well, Craig your solution worked, but only when space is not in the AllLetters class. When it is, the substitution occurs only when the preceding word is in latin (the opposite from what happened with the space substitution I tried at first...) Anyway, thank you again for the suggestions.
  • The most elegant way is probably to use Class 0, but there are not many tools that allow you to add such contextual lookup.
  • Yes, well, /space should not be included in @AllLetters, that should be reserved for, well, all letters!