latex3 / fontspec

Font selection in LaTeX for XeTeX and LuaTeX
http://latex3.github.io/fontspec/
LaTeX Project Public License v1.3c
276 stars 33 forks source link

luaotfload error as \l__fontspec_pre_feat_sclist is not correctly built #403

Closed u-fischer closed 4 years ago

u-fischer commented 4 years ago

Description

In the definition of \l__fontspec_pre_feat_sclist script and language are combined and set depending on the current value of \l__fontspec_script_tl:

\tl_if_empty:NF \l__fontspec_script_tl
      {
        script   = \l__fontspec_script_tl ;
        language = \l__fontspec_lang_tl   ;
      }

This implicitly assumes that if the script tl is non empty then also the lang tl. But actually it can happen that a non empty \l__fontspec_script_tl exists e.g. after a \fontspec_if_language:nTF call.

\l__fontspec_pre_feat_sclist then contains an empty language= and luaotfload doesn't like this ...

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Heros}
\begin{document}
\ExplSyntaxOn
\tl_show:N \l__fontspec_script_tl
\tl_show:N \l__fontspec_lang_tl
\fontspec_if_language:nTF {ENG}{}{}
\tl_show:N \l__fontspec_script_tl
\tl_show:N \l__fontspec_lang_tl

\tl_set:Nx \l_tmpa_tl {\l__fontspec_pre_feat_sclist }
\tl_show:N \l_tmpa_tl
\ExplSyntaxOff

%errors
%\font\test={file:texgyreheros-regular.otf:mode=node;script=latn;language=;} \test

\end{document}

Further details

I discovered the problem as polyglossia uses \fontspec_if_language:nTF and \addfontfeature suddently failed:

\documentclass{article}
\usepackage{polyglossia}
\setmainfont{CMU Serif}
\begin{document}
abc \addfontfeature {Script=Greek} τέμνω
\end{document}

I don't know if the non empty \l__fontspec_script_tl from the fontspec test has some other side effects.

u-fischer commented 4 years ago

Any news about this? It starts to hit more users, e.g. https://tex.stackexchange.com/questions/525598/addfontfeatures-not-working-after-update. I also already got reports by mail.