This is great. Thanks a lot, Hans!
I tested the idea with all context math fonts. TeX Gyre, DejaVu, Modern, STIX Two, Libertinus, XCharter, Kp Fonts, EB Garamond, Concrete, and Erewhon work with different fallback fonts I tried.
On the other hand, I couldn't get Kurier and Plex to work (not important, just reporting). See note about Pennstander below.
My typescript looks something like this:
%%% beginning of demo
%%%
%%% some definitions for vazir, sahel and vazircode to set up rm, ss, mm
%%% followed by the following for math
% SEC A: fallback
\starttypescript [math] [fall:vazir] [name]
\definefontfallback [mathdig] [vazirregular] [digitsextendedarabicindic] [check=yes,force=yes,offset=digitsnormal]
\definefontfallback [mathdig] [vazirbold] [digitsextendedarabicindic] [check=yes,force=yes,offset=digitsbold]
% I use the following to remap some other characters like Arabic decimal separator, etc.
\definefontfallback [mathdig] [vazirregular] [arabic] [check=yes,force=yes]
\stoptypescript
% SEC B: base
\starttypescript [math] [main:modern] [name]
\definefontsynonym[MathRoman] [file:latinmodern-math][features={math\mathsizesuffix,lm:mathextra,lm-math},goodies=modern-math,fallbacks=mathdig]
\definefontsynonym[MathRomanBold][file:latinmodern-math][features={math\mathsizesuffix,lm:mathextra,lm-math-bold,lm-math},goodies=modern-math,fallbacks=mathdig]
\stoptypescript
% SEC C: combination
\starttypescript [myfont]
\definetypeface [\typescriptone][rm] [serif][sahel] [default]
\definetypeface [\typescriptone][ss] [sans] [vazir] [default]
\definetypeface [\typescriptone][tt] [mono] [vazircode][default]
%\definetypeface [\typescriptone][mm] [math] [modern] [default]
\definetypeface [\typescriptone][mm] [math] [fall:vazir,main:modern] [default]
\stoptypescript
%%% end of demo
Still unresolved (less important mostly out of curiosity):
1. I'd have preferred something like "[math] [fall] [vazir] [default]" and "[math] [base] [modern] [default]" but couldn't get it to work. Is there any other way to make the above more readable? In my setup, I have copies of SEC A for each fallback font and a copy of SEC B for each base math font.
2. I don't understand how \definefontsynonym works. Does it have to be within a typescript? When (and how many times) are the definitions inside "executed"?
3. I couldn't get synonyms to work in the second argument of \definefontfallback.
4. Can we pass multiple fallbacks to \definefontsynonym definition like fallbacks={a,b}. I couldn't get this to work.
5. Can we do transitive definefontsynonyms and add features and fallback iteratively? I mean, define B from A with some features and fallbacks, and then C from B with some additional features and fallbacks.
6. I see that we have digitsnormal and digitsbold in the normal (non-bold) math font. Do we have the bold version of every character in there?
7. When I tried to apply fallback on Pennstander (
https://github.com/juliusross1/Pennstander) I discovered that the fallback does not take effect unless I add "presets.fallbacks {}," instead of the tweaks of the goodies file.
8. What is a "font class". I couldn't make much sense of the magical code for \definefontsynonym, etc. though something I found there was that there exists a class fallbacks and a (non-class?) fallback for each font. In the logs, I always saw the class one output as empty.
--Mohammad