XeLaTeX: WordInitial, Inner and WordFinal seem to match everywhere

I am creating a blackletter font and would like to use it with XeLaTeX. I try to use initial/medial/final substitution for letters, like s/ſ, but the context seems to match even when it should not.

For example, I try to execute substitution of s by ſ using the init and medi tables, but with fontspec and Contextuals={Inner}, word-initial and -final “s”es are replaced by “ſ”, too. The corresponding applies for all substitutions of initial and final forms.

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Script=Latin,Language=German,Contextuals=Inner}
\setmainfont{Jena1330.otf}
\begin{document}
smstsms
\end{document}


gives a document containing ſmſtſmſ in the correct font, instead of smſtſms, as I would expect.

Am I doing something wrong? How does XeLaTeX decide if a letter is initial, medial or final?

-
I ignored this problem now by making Jena1330 fit for vanilla pdfLaTeX, by using a manually generated pl/tfm file. (., , and so on are still considered part of the word there, though.) –  Anaphory Aug 11 '12 at 0:33
Most OpenType layout engine handle isol/init/medi/fina properly only for specific scripts (Arabic, Syriac, Mongolian, etc.), for other scripts they will apply them unconditionally, which seems to be the case with the ICU layout engine used by XeTeX. AFAIK, only some Adobe applications handle them for Latin script.
So for compatibility with both LuaLaTeX and XeLaTeX I have to implement them as both calt and init/medi/fina, since LuaLaTeX has a problem with calt, but supports the in-word contexts for Latin script. –  Anaphory May 12 '12 at 9:16
I'm surprised that they work with LuaLaTeX, AFAIK as I know it doesn’t, the calt issue might be a bug, but without the actual font I can’t help much. –  Khaled Hosny May 12 '12 at 9:47