I am aware of the following questions and answers about font fallback in XeTeX (or LuaLaTeX):
- Unicode in XeTeX with automatic font substitution?
- Font substitution with XeLaTeX
- Define fallback font for specific Unicode characters in LuaLaTeX
- Setting a fallback font for non-Arabic charset not supported by a certain Arabic font
From these I learnt that:
- XeTeX can't automatically find a font that includes a given character, but ucharclasses can be used to assign fonts to specific unicode ranges
- XeTex can be set up to transition from one font to the next based on character classes (interchar tokens).
\newunicodecharcan be used to assign a font to a given character.
- Polyglossia can be used to mark sections of the text in various languages.
However, none of these covers the following question, as far as I can tell:
How do I tell XeTeX to use a specific font "A", but fall back to another font "B" when a character isn't available in "A" (and so on with "C", and "D", etc.)?
In other words, I know exactly which fonts I want to use, and in which priority order; I don't need XeTeX to look for a font on my system: I can tell it exactly which ones to use. And
ucharclasses won't work, because my font "A" covers parts of many classes, but for the rest of these classes I want to use "B".
From https://tug.org/pipermail/xetex/2011-November/022321.html, I know that it's possible to write a macro that detects whether a character is in a font. Thus, I can wrap each character in my document in this macro, test whether the character is in font "A", and use font "B" if it is not (and "C", and "D", until I find one in the list that contains the character).