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

tex-gyre: init at ~2.005 #35028

Merged
merged 1 commit into from Feb 17, 2018
Merged

tex-gyre: init at ~2.005 #35028

merged 1 commit into from Feb 17, 2018

Conversation

jtojnar
Copy link
Contributor

@jtojnar jtojnar commented Feb 16, 2018

Motivation for this change

For some reason, TeX Gyre Pagella is not recognized by texlive.fithesis when texlive.tex-gyre is used.

cc @siddharthist who maintains the Math variants.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@langston-barrett
Copy link
Contributor

@jtojnar Are these the OTF versions? Are you hoping to use these with fontspec + XeLaTeX/LuaLaTeX?

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 16, 2018

Yes, they are. Yes, I am using them with fontspec and XeLaTex.

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 16, 2018

{ nixpkgs ? (import <nixpkgs> {}) }:

with nixpkgs;
let
  tex-deps = {
    inherit (texlive) collection-bibtexextra collection-latexextra latexmk scheme-small tex-gyre-math;
  };

  src = writeText "thesis" ''
    \documentclass{fithesis3}
    \thesissetup{
      date = \the\year/\the\month/\the\day,
    }
    \begin{document}
      Test
    \end{document}
  '';

  buildPhase = ''
    latexmk -xelatex -shell-escape -view=pdf "${src}"
    install -Dt $out *-thesis.pdf
  '';

in {
  bad = runCommandNoCC "thesis-bad" {
    # TeX Gyre Pagella from texlive.tex-gyre is not recognized
    buildInputs = [ (texlive.combine (tex-deps // { inherit (texlive) tex-gyre; })) ];
  } buildPhase;

  good = runCommandNoCC "thesis-good" {
    buildInputs = [ (texlive.combine tex-deps) ];

    # Using OTF font from the pull request works
    FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ tex-gyre.pagella ]; };
  } buildPhase;
}
$ nix-build tex-gyre.nix -A good
[…]
Latexmk: All targets (3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.pdf 3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.xdv) are up-to-date
$ nix-build tex-gyre.nix -A bad
[…]
tex/latex/unicode-math/unicode-math-table.tex)))kpathsea:make_tex: Invalid fontname `TeX Gyre Pagella', contains ' '


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "TeX Gyre Pagella" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.116 ...mainfont[Ligatures=TeX]{TeX Gyre Pagella}

?
! Emergency stop.
!...............................................

l.116 ...mainfont[Ligatures=TeX]{TeX Gyre Pagella}

No pages of output.
Transcript written on 3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.log.
Collected error summary (may duplicate other messages):
  xelatex: Command for 'xelatex' gave return code 1
      Refer to '3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.
=== TeX engine is 'XeTeX'
Latexmk: Errors, so I did not complete making targets

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 16, 2018

Interestingly enough, fithesis does not like OTF package of the Math variants and requires texlive.tex-gyre-math.

tex/latex/unicode-math/unicode-math-table.tex)))kpathsea:make_tex: Invalid fontname `[texgyrepagella-math.otf]/OT', contains '['


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "texgyrepagella-math" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.117 ...,bold-style=ISO]{texgyrepagella-math.otf}

?
! Emergency stop.
!...............................................

l.117 ...,bold-style=ISO]{texgyrepagella-math.otf}

No pages of output.
Transcript written on 3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.log.
Collected error summary (may duplicate other messages):
  xelatex: Command for 'xelatex' gave return code 1
      Refer to '3bpbqyzchjg759snvaz5zr8dhjy162gz-thesis.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.
=== TeX engine is 'XeTeX'
Latexmk: Errors, so I did not complete making targets

@langston-barrett
Copy link
Contributor

The second issue you mention is a little bizzare.

The first issue, that texlive.tex-gyre doesn't include OTF versions, makes sense to me and I think the addition of this package is a good move.

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 16, 2018

It does include OTF on CTAN: https://www.ctan.org/texarchive/fonts/tex-gyre/fonts/opentype/public/tex-gyre.

Edit: So does nixpkgs:

ls (find (nix-build -E 'with import <nixpkgs> {}; texlive.combine { inherit (texlive) scheme-basic tex-gyre tex-gyre-math; }') -name opentype)/public/*
/nix/store/77iffrgw53vkwpb92lg0abzl1kc3bv6f-texlive-combined-2017/share/texmf/fonts/opentype/public/tex-gyre:
texgyreadventor-bolditalic.otf  texgyrebonum-bold.otf           texgyrecursor-bold.otf       texgyreheroscn-bolditalic.otf  texgyreheros-regular.otf       texgyreschola-bolditalic.otf  texgyretermes-bold.otf
texgyreadventor-bold.otf        texgyrebonum-italic.otf         texgyrecursor-italic.otf     texgyreheroscn-bold.otf        texgyrepagella-bolditalic.otf  texgyreschola-bold.otf        texgyretermes-italic.otf
texgyreadventor-italic.otf      texgyrebonum-regular.otf        texgyrecursor-regular.otf    texgyreheroscn-italic.otf      texgyrepagella-bold.otf        texgyreschola-italic.otf      texgyretermes-regular.otf
texgyreadventor-regular.otf     texgyrechorus-mediumitalic.otf  texgyreheros-bolditalic.otf  texgyreheroscn-regular.otf     texgyrepagella-italic.otf      texgyreschola-regular.otf
texgyrebonum-bolditalic.otf     texgyrecursor-bolditalic.otf    texgyreheros-bold.otf        texgyreheros-italic.otf        texgyrepagella-regular.otf     texgyretermes-bolditalic.otf

/nix/store/77iffrgw53vkwpb92lg0abzl1kc3bv6f-texlive-combined-2017/share/texmf/fonts/opentype/public/tex-gyre-math:
texgyrebonum-math.otf  texgyredejavu-math.otf  texgyrepagella-math.otf  texgyreschola-math.otf  texgyretermes-math.otf

And the font names seem to match:

ExifTool Version Number         : 10.60
File Name                       : texgyrepagella-regular.otf
Directory                       : /nix/store/77iffrgw53vkwpb92lg0abzl1kc3bv6f-texlive-combined-2017/share/texmf/fonts/opentype/public/tex-gyre
File Size                       : 141 kB
File Modification Date/Time     : 1970:01:01 01:00:01+01:00
File Access Date/Time           : 2018:02:16 22:43:29+01:00
File Inode Change Date/Time     : 2018:02:16 22:43:29+01:00
File Permissions                : r--r--r--
File Type                       : OTF
File Type Extension             : otf
MIME Type                       : application/x-font-otf
Copyright                       : Copyright 2006, 2009 for TeX Gyre extensions by B. Jackowski and J.M. Nowacki (on behalf of TeX users groups). This work is released under the GUST Font License --  see http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt for details.
Font Family                     : TeX Gyre Pagella
Font Subfamily                  : Regular
Font Subfamily ID               : 2.004;UKWN;TeXGyrePagella-Regular
Font Name                       : TeX Gyre Pagella
Name Table Version              : Version 2.004;PS 2.004;hotconv 1.0.49;makeotf.lib2.0.14853
PostScript Font Name            : TeXGyrePagella-Regular
Trademark                       : Please refer to the Copyright section for the font trademark attribution notices.
Copyright (en-US)               : Copyright 2006, 2009 for TeX Gyre extensions by B. Jackowski and J.M. Nowacki (on behalf of TeX users groups). This work is released under the GUST Font License --  see http://tug.org/fonts/licenses/GUST-FONT-LICENSE.txt for details.
Font Family (en-US)             : TeXGyrePagella
Font Subfamily (en-US)          : Regular
Font Subfamily ID (en-US)       : 2.004;UKWN;TeXGyrePagella-Regular
Font Name (en-US)               : TeXGyrePagella-Regular
Name Table Version (en-US)      : Version 2.004;PS 2.004;hotconv 1.0.49;makeotf.lib2.0.14853
Post Script Font Name (en-US)   : TeXGyrePagella-Regular
Trademark (en-US)               : Please refer to the Copyright section for the font trademark attribution notices.
Preferred Family (en-US)        : TeX Gyre Pagella

I would understand if it could not load the OTF files not in fontconfig but it can still find texlive.tex-gyre-math.

Maybe @Witiko will know something more? Witiko/fithesis@79ce60c#diff-15fec5e8e22ba5674ee44b51beba6c3aR176

@Witiko
Copy link

Witiko commented Feb 16, 2018

There is a difference between XeLaTeX and LuaLaTeX in how they handle OpenType font files. LuaTeX features its own font loader, whereas XeLaTeX defers to the system font loader (e.g. Fontconfig on Linux). Therefore, it is not enough for XeLaTeX to include the otf files in the TeX Live installation, the system font loader needs to be aware of these files as well.

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 16, 2018

@Witiko That makes sense, except for that it works for texgyrepagella-math.otf. How can that be?

@Witiko
Copy link

Witiko commented Feb 17, 2018

I am not sure I completely understand the report, but to me the issue seems to be the following:

  1. Fontconfig is used by XeLaTeX to translate the TeX Gyre Pagella font name to the full pathname. On Debian 9, this works:
    $ fc-list | grep -F texgyrepagella
    /usr/share/texmf/fonts/opentype/public/tex-gyre-math/texgyrepagella-math.otf: TeX Gyre Pagella Math:style=Regular
    /usr/share/texmf/fonts/opentype/public/tex-gyre/texgyrepagella-bolditalic.otf: TeX Gyre Pagella:style=Bold Italic
    /usr/share/texmf/fonts/opentype/public/tex-gyre/texgyrepagella-italic.otf: TeX Gyre Pagella:style=Italic
    /usr/share/texmf/fonts/opentype/public/tex-gyre/texgyrepagella-regular.otf: TeX Gyre Pagella:style=Regular
    /usr/share/texmf/fonts/opentype/public/tex-gyre/texgyrepagella-bold.otf: TeX Gyre Pagella:style=Bold
    
    because Debian's TeX Live package includes Fontconfig mappings:
    $ grep tex /etc/fonts/conf.d/*
    /etc/fonts/conf.d/65-fonts-lmodern.conf: <dir>/usr/share/texmf/fonts/opentype/public/lm</dir>
    /etc/fonts/conf.d/65-fonts-lmodern.conf: <dir>/usr/share/texmf/fonts/opentype/public/lm-math</dir>
    /etc/fonts/conf.d/65-fonts-texgyre.conf: <dir>/usr/share/texmf/fonts/opentype/public/tex-gyre</dir>
    /etc/fonts/conf.d/65-fonts-texgyre.conf: <dir>/usr/share/texmf/fonts/opentype/public/tex-gyre-math</dir>
    
    I suppose that you lack these mappings. I can make future versions of fithesis robust against this by manually loading the TeX Gyre Pagella OpenType files by file name and not rely on Fontconfig.
  2. Since the file name (texgyrepagella-math.otf) rather than font name is specified, Fontconfig is not invoked and the font is loaded directly from the TeX Live installation.

For more information on the font loader, please refer to sections 1.1 and 1.2 of the fontspec package manual.

@jtojnar
Copy link
Contributor Author

jtojnar commented Feb 17, 2018

  1. Since the file name (texgyrepagella-math.otf) rather than font name is specified, Fontconfig is not invoked and the font is loaded directly from the TeX Live installation.

This is the piece I was missing. Now it makes sense.

I would actually prefer to use Fontconfig even for the Math fonts, since that is how I handle all other fonts. Would it be possible to change the file name to the TeX Gyre Pagella Math font name?

@jtojnar jtojnar merged commit 327a847 into NixOS:master Feb 17, 2018
@jtojnar jtojnar deleted the tex-gyre branch February 17, 2018 00:38
@Witiko
Copy link

Witiko commented Feb 17, 2018

Would it be possible to change the file name to the TeX Gyre Pagella Math font name?

Actually, I would much rather circumvent Fontconfig altogether and load even the text fonts by their file names. The CTAN font file names rarely change, but the font loader can be easily broken (e.g. by removing the /etc/fonts/conf.d mappings) and differs between various operating systems. It is an additional level of indirection that makes fithesis more fragile. Would this change make things more difficult for you?

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

Successfully merging this pull request may close these issues.

None yet

4 participants