Fix compilation with Tectonic and xelatex (patch included)

Issue #202 open
Konrad Höffner created an issue

After cloning this repository, both tectonic ClassicThesis.tex and xelatex ClassicThesis.tex fail.

Tail of tectonic output:

error: classicthesis.sty:198: Package fontspec Error: The font "TeX Gyre Pagella" cannot be found.

For immediate help type H <return>
error: halted on potentially-recoverable error as specified

Tail of xelatex output:

! Package fontspec Error: The font "TeX Gyre Pagella" cannot be found.

For immediate help type H <return>.
 ...                                              

l.198    }

The following changes fix the compilation.

I do not have the rights to create a pull request so I can only share the changes in text form:

classicthesis$ git diff classicthesis.sty 
diff --git a/classicthesis.sty b/classicthesis.sty
index 0105d61..a840605 100644
--- a/classicthesis.sty
+++ b/classicthesis.sty
@@ -161,14 +161,17 @@
      \RequirePackage{fontspec}
      \ifthenelse{\boolean{ct@palatino}}% default
        {
-         \setmainfont[Ligatures=TeX,Numbers=OldStyle]{TeX Gyre Pagella} % Palatino clone
+         \setmainfont[Ligatures=TeX,Numbers=OldStyle,
+           BoldFont = texgyrepagella-bold.otf,
+           ItalicFont = texgyrepagella-italic.otf,
+           BoldItalicFont = texgyrepagella-bolditalic.otf]{texgyrepagella-regular.otf} % Palatino clone
          \linespread{1.05} % a bit more for Palatino
          \RequirePackage{unicode-math}
-         \setmathfont{TeX Gyre Pagella Math}
+         \setmathfont{texgyrepagella-math.otf}
        }{\relax} % use class' default font
      \ifthenelse{\boolean{ct@beramono}}%
-       {\setmonofont[Scale=0.85]{DejaVu Sans Mono}} % like Bera; Scale=MatchLowercase
-       {\setmonofont[Scale=1]{Latin Modern Mono}}
+       {\setmonofont[Scale=0.85]{DejaVuSansMono.ttf}} % like Bera; Scale=MatchLowercase
+          {\setmonofont[Scale=1]{lmmono10-regular.otf}}
      % font for the chapter numbers will be defined in the old way below
      % because there is no OpenType Euler font; this is how it should be done:
      %\newfontface\chapterNumber[Scale=7,Color=000000]{TeX Gyre Pagella Bold}

With those changes, it successfully compiles with all three of pdflatex (over latexmk -pdf), xelatex and tectonic.

However I’m usually just a LaTeX user not a package writer, so I can’t guarantee that there aren’t any side effects.

Environment

Linux archlinux 6.3.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 14 Jun 2023 20:10:31 +0000 x86_64 GNU/Linux

XeTeX 3.141592653-2.6-0.999995 (TeX Live 2023/Arch Linux)

Tectonic 0.14.1

texlive version 2023.66594-14 with installed packages texlive-: basic, bibtexextra, bin, binextra, fontsextra, fontsrecommended, langgerman, latex, latexextra, latexrecommended, mathscience, pictures

Comments (9)

  1. Ivo Pletikosić

    Thank you for reporting, @Konrad Höffner. I'm pretty sure I had the same problem and asked for solution somewhere, but I really can't remember where. I was told there's a smart way of finding fonts by these packages, which is what we're using, and that those sometimes fail. I think the issue was with how they made the font package. Try reporting to archlinux, and I'll try to find where I reported my problem (fedora linux). Unfortunately, the solution that worked for you might not work for others because fonts are named differently.

  2. Konrad Höffner reporter

    I am not a font expert, but according to Will Robertson (the author of fontspec?) in 2018, loading fonts by name is discouraged exactly because of those types of errors, see https://tug.org/TUGboat/tb39-2/tb122robertson-fontspec.pdf.

    He recommends loading fonts like this:

    \setmainfont{texgyrepagella}[
    Extension= .otf,
    UprightFont=*-regular,
    ItalicFont= *-italic,
    BoldFont= *-bold,
    BoldItalicFont = *-bolditalic,
    ]
    

    Tectonic also does not have the capability to load fonts by name at all, see https://github.com/tectonic-typesetting/tectonic/issues/1118.

    This it seems to me as if this is not the problem of Arch Linux itself and if the above solution is more portable and leads to less errors, I would ask you to reconsider this issue.

  3. Konrad Höffner reporter

    Thank you for reconsidering! Tectonic now successfully downloads and uses “TeX Gyre Pagella", however now it has another fontspec error with “DejaVuSansMono”, which requires similar treatment:

    diff --git a/classicthesis.sty b/classicthesis.sty
    index f680858..1970765 100644
    --- a/classicthesis.sty
    +++ b/classicthesis.sty
    @@ -182,7 +182,12 @@
              \setmathfont{texgyrepagella-math}[Extension= .otf]%
            }{\relax} % use class' default font
          \ifthenelse{\boolean{ct@beramono}}%
    -       {\setmonofont[Scale=0.85]{DejaVuSansMono}} % like Bera; Scale=MatchLowercase
    +       {\setmonofont[Scale=0.85]{DejaVuSansMono}[
    +        Extension      = .ttf,
    +        BoldFont       = *-Bold,
    +        ItalicFont     = *-Oblique,
    +        BoldItalicFont = *-BoldOblique
    +]} % like Bera; Scale=MatchLowercase
            {\setmonofont[Scale=1]{lmmono10-regular}[Extension= .otf]}  
          \ifthenelse{\boolean{ct@eulermath}}%
          {\PassOptionsToPackage{math-style=upright}{unicode-math}%
    

    After that, I still get errors with euler-math but when I set both “eulermath” and “eulerchapternumbers” to false then it compiles, is that working as intended?

    --- a/classicthesis-config.tex
    +++ b/classicthesis-config.tex
    @@ -32,9 +32,9 @@
       drafting=true,    % print version information on the bottom of the pages
       tocaligned=false, % the left column of the toc will be aligned (no indentation)
       dottedtoc=false,  % page numbers in ToC flushed right
    -  eulerchapternumbers=true, % use AMS Euler for chapter font (otherwise Palatino)
    +  eulerchapternumbers=false, % use AMS Euler for chapter font (otherwise Palatino)
       floatperchapter=true,     % numbering per chapter for all floats (i.e., Figure 1.1)
    -  eulermath=true,  % use awesome Euler fonts for mathematical formulae (only with pdfLaTeX)
    +  eulermath=false,  % use awesome Euler fonts for mathematical formulae (only with pdfLaTeX)
    

  4. Log in to comment