Here is an extremely simplified version of my code from this answer, where I finally found a workaround to this problem:
\documentclass{article}
\tracinglostchars=3 % Panic if a font does not contain the character we need.
\usepackage{ luacode, luatexbase }
\usepackage{fontspec}
\begin{luacode}
fonts.handlers.otf.addfeature {
name = "xalt",
type = "chainsubstitution",
lookups = {
{
type = "substitution",
data = {
["sheva"] = "sheva_for_finalkaf",
["qamats"] = "qamats_for_finalkaf",
},
},
},
data = {
rules = {
{
before = { {"finalkaf"} },
current = { {"sheva", "qamats"} },
lookups = { 1 },
},
},
},
}
\end{luacode}
% Taamey Ashkenaz and other Culmus fonts with Taamim are available, libre, at:
% https://culmus.sourceforge.io/taamim/index.html
% If you want Hebrew letters that slant from left to right rather than right
% to left, replace the ItalicFont= and BoldItalicFont= features with
% AutoFakeSlant = 0.15
\defaultfontfeatures[TaameyAshkenaz]{
UprightFont = -Medium,
BoldFont = -Bold,
ItalicFont = -MediumOblique,
BoldItalicFont = -BoldOblique,
Extension = .ttf }
% Uncommenting this line enables RawFeature={+xalt}:
%\setmainfont{TaameyAshkenaz}
\setmainfont{Latin Modern Roman}
\newfontfamily\AshkenazCustom{TaameyAshkenaz}[Script=Hebrew, RawFeature={-ccmp, +xalt}]
\newfontfamily\AshkenazDefault{TaameyAshkenaz}[Script=Hebrew, RawFeature={+ccmp, -xalt}]
\begin{document}
\begingroup\noindent
\AshkenazCustom
^^^^05da^^^^05b0 ^^^^05da^^^^05b8
\endgroup
\begingroup\noindent
\AshkenazDefault
^^^^05da^^^^05b0 ^^^^05da^^^^05b8
\endgroup
\end{document}
The bottom row is correct. The xalt font feature is meant to replace some of the substitutions from the ccmp (contextual composition and decomposition) feature, which I needed to turn off.
However, xalt only works when the font is the first one that the document loads. It does not matter whether it is loaded as \setmainfont or \newfontfamily, or whether \setmainfont changes after it loaded, but the chainsubstitution feature only works if it is the first one loaded. The other feature types I tested with, ligature and pair, do not have this problem. Eta: but multiple does as well.
I wasn’t able to find any warning about this in the documentation I am aware of. Is this a bug, and if so, whose bug is it?

DavidandDavid Libregive different results under the same conditions, andAlefandFreeSerifidentical in all their permutations, but cannot rule out font design for the latter pair (meaning that the marks are halfway up the stems). ?Perhaps it depends on glyph anchor points. – Cicada Feb 05 '22 at 12:01