4

I have updated my LaTeX recently and I am getting error when using \addfontfeatures

Here is my MWE (you can use any font)

 \documentclass{article}

\usepackage{polyglossia}

\setmainlanguage{english}

\setmainfont{MetaSerifPro-}[
    Extension = .otf,
    UprightFont = MetaSerifPro-Book,
    ItalicFont = MetaSerifPro-BookItalic,
    BoldFont = MetaSerifPro-Bold,
    BoldItalicFont = MetaSerifPro-BoldItalic,
%    Numbers = Uppercase
]


\begin{document}

    \addfontfeatures{Numbers = Uppercase}

    Hello 123

\end{document}

I get an error

luaotfload | aux : font no 34 (nil) defines no feature for script latn with lang
uage eng...texmf-dist/tex/luatex/luaotfload/luaotfload-features.lua:252: bad arg
ument #1 to 'stringgsub' (string expected, got boolean).
<to be read again> 
\scan_stop: 
l.20    \addfontfeature{Numbers = Uppercase}

? 
! Emergency stop.
<to be read again> 
\scan_stop: 
l.20    \addfontfeature{Numbers = Uppercase}

However if I uncomment Numbers = Uppercase in the preamble and comment out \addfontfeature line, everything works. I am getting this error with every font I try, so it seems that the porblem is with fontspec.

I use LuaLaTeX.

UPD: it seems that the bug has been fixed in the latest patch of fontspec (2.7f)

1

1 Answer 1

7

Update

fontspec 2020/01/26 v2.7g has resolved the problem. The work around is no longer needed

===================

You could try this work-around. It perhaps will set the language or the script wrong, but you could correct this then in the font declaration:

\documentclass{article}

\usepackage{polyglossia}

\setmainlanguage{english}

\setmainfont{TeXGyreHeros}[
     Numbers = Uppercase
]
\ExplSyntaxOn
\tl_set:Nn \l__fontspec_pre_feat_sclist
  {
    mode     = \l__fontspec_mode_tl   ;
    \tl_if_empty:NF \l__fontspec_shaper_tl
      {
        shaper = \l__fontspec_shaper_tl   ;
      }
    \tl_if_empty:NF \l__fontspec_script_tl
      {
        script   = \l__fontspec_script_tl ;
      }
    \tl_if_empty:NF \l__fontspec_lang_tl
     {
       language = \l__fontspec_lang_tl   ;
     }
  }
\ExplSyntaxOff

\begin{document}

    \addfontfeatures{Numbers = Uppercase}

    Hello 123

\end{document}
2
  • Trying to compile OPs code gives bad argument #1 to 'stringgsub' (string expected, got boolean). again, on MiKTeX with fontspec version 2.7i (so newer than g) and luatex 1.11.2.
    – Alex Povel
    Apr 20, 2020 at 16:08
  • 1
    @HansLollo Works fine for me. But my miktex has a newer luatex. Check also your luaotfload version. Apr 20, 2020 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .