Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New release of fontspec breaks \babelfont in xelatex #513

Closed
3 of 4 tasks
borisveytsman opened this issue Apr 30, 2024 · 10 comments
Closed
3 of 4 tasks

New release of fontspec breaks \babelfont in xelatex #513

borisveytsman opened this issue Apr 30, 2024 · 10 comments

Comments

@borisveytsman
Copy link

Description

The new release (71101 in TeXLive) breaks \babelfont command in xelatex, but not lualtex

Check/indicate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage[english]{babel}
\babelfont[chinese]{rm}[
  Extension=.otf,
  UprightFont=*-Regular,
  BoldFont=*-Bold
]{FandolHei}
\begin{document}
\foreignlanguage{chinese}{你好世界}
\end{document}

Further details

This document fails the recent xelatex with the message

) (/usr/local/texlive/2024/texmf-dist/tex/latex/base/ts1cmr.fd)
! Illegal parameter number in definition of \l__exp_internal_tl.
<to be read again> 
                   1
l.9 \foreignlanguage{chinese}{你好世界}

It compiles in lualatex. It also compiles in xelatex and the previous version of fontspec (after sudo tlmgr restore fontspec 69833)

@jpcirrus
Copy link

Just to add that the new fontspec 2.9b release is preventing document compilation here using lualatex (does with xelatex) when the document changes language from the default of en-NZ. Let me know if you want me to raise a separate issue.

Error message:

 Illegal parameter number in definition of \l__exp_internal_tl.
<to be read again> 
1
l.561 \begin{otherlanguage}{arabic}

@wspr
Copy link
Collaborator

wspr commented May 1, 2024

@jpcirrus — thanks John, a separate issue isn't required I think but could you provide a minimal example of what is failing for you? (Similar to Boris's example above)

@jpcirrus
Copy link

jpcirrus commented May 1, 2024

In reducing the complex document where I experienced the compilation error to a MWE, I found that both xelatex and lualatex are affected. This issue is that for every font-family declared with \babelfont for the main language, the corresponding \babelfont[language-list] font-family has also to be declared, even if never used, which prior to fontspec 2.9b was not the case.

\documentclass{article}
\usepackage[english]{babel}
\babelfont{rm}{Latin Modern Roman}
\babelfont{sf}{Latin Modern Sans}
% \babelfont{tt}{Latin Modern Mono}
\babelfont[arabic]{rm}{FreeSerif}
% \babelfont[arabic]{sf}{FreeSerif}
% \babelfont[arabic]{tt}{FreeSerif}
\begin{document}
\foreignlanguage{arabic}{آليات}
\end{document}

The reason I had previously thought it was lualatex only was that I was using the command \babelprovide[onchar=fonts ids]{arabic} without actually marking up the language changes, which compiled with xelatex, but on more rigorous inspection wasn't using the specified font.

@u-fischer
Copy link
Member

@wspr the code in \cs_new:Nn \fontspec_new_lang:nn looks definitively wrong. You seem to have copy code from \fontspec_new_script:nn but it has not been adapted to lang:

   \exp_args:Noo \@@_check_script:NnF \l_@@_fontface_cs_tl \l_@@_script_tl
              {
                \tl_set:Nn \l_@@_script_name_tl {#1}
                \int_set:Nn \l_@@_language_int {\l_@@_strnum_int}
                \tl_gset:Nx \g_@@_single_feat_tl { language=####1 }
              }

@u-fischer
Copy link
Member

and an example without babel is

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\fontspec[Script=Cyrillic,Language=Russian]{opensans}

\end{document}

@u-fischer
Copy link
Member

If I change the code to this it compiles again (but I'm not completely sure that the logic is right (and why script stores both the name and the internal tag and the lang doesn't).

\cs_new:Nn \fontspec_new_lang:nn
  {
    \keys_define:nn {fontspec-opentype} { Language / #1 .code:n =
      {
        \bool_set_false:N \l__fontspec_scriptlang_exist_bool
        \clist_map_inline:nn {#2}
          {
            \exp_args:No \__fontspec_check_lang:NnTF \l__fontspec_fontface_cs_tl {####1}
              {
                \tl_set:Nn \l__fontspec_lang_tl {####1}
                \int_set:Nn \l__fontspec_language_int {\l__fontspec_strnum_int}
                \tl_gset:Nx \g__fontspec_single_feat_tl { language=####1 }
                \bool_set_true:N \l__fontspec_scriptlang_exist_bool
                \clist_map_break:
              }
          }
% exchange this part so that is handles lang not script.
        \bool_if:NF \l__fontspec_scriptlang_exist_bool
          {
            \__fontspec_warning:nx {language-not-exist} {#1}
            \clist_set:Nn \l_tmpa_clist {#2}
            \clist_get:NN \l_tmpa_clist \l__fontspec_lang_tl
            \exp_args:Noo \__fontspec_check_lang:NnTF \l__fontspec_fontface_cs_tl 
            \l__fontspec_lang_tl
              {} % F variant of conditional missing, must be added 
              {
                \int_set:Nn \l__fontspec_language_int {\l__fontspec_strnum_int}                
                \tl_gset:Nx \g__fontspec_single_feat_tl { language=\l__fontspec_lang_tl }               
              }
          }
      }
    }
  }

@nplatis
Copy link

nplatis commented May 1, 2024

If it is of any importance, a document similar to the one of @borisveytsman produces the error only for some fonts on my system; for example, Arial gives an error, whereas Calibri does not.

@wspr wspr closed this as completed in 505ff04 May 2, 2024
@u-fischer
Copy link
Member

@wspr there should be imho an update soon, various people have already commented about the issue e.g. on the texlive list.

@wspr
Copy link
Collaborator

wspr commented May 3, 2024

@wspr there should be imho an update soon, various people have already commented about the issue e.g. on the texlive list.

I agree -- can anyone confirm if the current develop branch now fixes all the issues, or do Nikos/John's examples above show different problems?

@u-fischer
Copy link
Member

@wspr I checked all the examples and see no problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants