Problem with Greek letters messing up OpenType feature code in TextEdit

Hey there,

I am working on a feature for a handwriting font that is about detecting if a glyph is entered in a mathematical context and then should replace the glyph with a mathematical not connected version of the glyph.

This is the formula I am trying to write:

x=α1xy+α2(x2-y2)+x

The code renders correctly in InDesign which looks like this:

In TextEdit the same formula renders like this:

It seems to me TextEdit does not recognise the alpha, and renders the connected letter form instead of the desired isolated letter form.

The feature code I use to process this is placed in the calt feature

sub @MathIndicators @MathLettersToBeReplaced@Mathindicators by @MathLetters;

When I replace the alpha with a any other letter for example a “c”, TextEdit renders correctly the isolated form and not the connected form:

Also I have noticed that I can enter as many spaces and numbers as I want, the first time after a greek letter the feature will not work, until another two @MathIndicator’s are entered (for example space or number).

So far I have tried to put the alpha at another code point MATHEMATICAL ITALIC SMALL ALPHA (u+1D6FC) vs. Greek small letter alpha (u+03B1) - with the same result. I have looked into the .rtf file and the glyphs are indicated in the rtf code with correct code points /945 and /120572.

Thank you very much for your help!

The context for the OpenType features sometimes is separated by script. So the alpha is a separate string and has no math indicators around it. Different implementation handle that differently.

One way to handle this is to have the not connected shapes as default and replace them in none math contexts with the connecting shapes.

Thank you for the information Georg.
I am not really sure if I understand what “separated by script” or a “separated string” means in this context.

This is what the .rtf code looks like:

{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
{\fonttbl\f0\fnil\fcharset0 AlbertEinstein1-029m-Regular;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww19520\viewh24800\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0  
\fs96 \uc0\u945 x\u945 }

Are you saying that the OpenType feature is separated in TextEdit by script because in the .rtf code is stored as \u945 x\u945 instead of αxα (alpha x alpha) ?

If so would there be another way to address the substitution rule i.e.:

sub \u945 x' \u945 by x.isol

Thank you for clarifying!

PS.: I just tested the code with Notepad on a PC and it shows the same results - however InDesign still renders the font as intended.

The OpenType layout engine divides the string for each script and only applies the features for each portion. Has nothing to do how it is stored in the file.