13

The new version of fontspec (February 1, 2016, version 2.5a) gives the following error (MacTeX2015):

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
./mathcal2016.tex:17: fontspec error: "not-in-addfontfeatures"
! 
! The "WordSpace" font feature cannot be used in \addfontfeatures.
! 
! See the fontspec documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

What changed? Is there a workaround, or a better way of using fontspec.sty?

sgmoye
  • 8,586

1 Answers1

14

In the new version, the code for the option is (from fontspec-keyval.dtx)

% \paragraph{Inter-word space}
% These options set the relevant \cmd\fontdimen s for the
% font being loaded.
%    \begin{macrocode}
\@@_keys_define_code:nnn {fontspec} {WordSpace}
 {
  \bool_if:NF \l_@@_firsttime_bool
   { \_fontspec_parse_wordspace:w #1,,,\q_stop }
 }
\@@_aff_error:n {WordSpace}
%    \end{macrocode}

and it is similar to the code for HyphenChar and PunctuationSpace. The problem is that these options act globally on a font and cannot be undone by simply closing a group. See WordSpace factor does not increase again for an example.

For completeness, here's the code for aff_error:

% For catching features that cannot be used in |\addfontfeatures|:
%    \begin{macrocode}
\cs_new:Nn \@@_aff_error:n
  {
    \@@_keys_define_code:nnn {fontspec-addfeatures} {#1}
      { \@@_error:nx {not-in-addfontfeatures} {#1} }
  }
%    \end{macrocode}

If you want different interword space in some part of your document, you are better to define a specific font family:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Linux Libertine O}

\newfontfamily{\morespace}{Linux Libertine O}[
  WordSpace={2, 2, 2}
]

\begin{document}

Some text. Some text.

{\morespace Some text. Some text.}

Some text. Some text.

\end{document}

enter image description here

Of course, the change should be mentioned in the documentation.

egreg
  • 1,121,712
  • 2
    Thanks egreg. If you really wanted to work around the new restriction, I guess it would work to write \ExplSyntaxOn\__fontspec_keys_define_code:nnn {fontspec-addfeatures} {WordSpace} {}\ExplSyntaxOff after loading fontspec. – Will Robertson Feb 04 '16 at 01:16
  • Thanks for the pointer, but probably better to do the right thing in the first place, as you did. I cleaned up a lot of code this afternoon. Harumph. – sgmoye Feb 04 '16 at 01:54