From 5f96aa94364effe057e59dbf4a11050c3403b8e9 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Tue, 25 Apr 2023 22:14:03 +0200 Subject: [PATCH 1/3] texlive.combine: wrap with FONTCONFIG_FILE This is neccessary for XeTeX to find the fonts distributed with TeXLive. The fontconfig file generated by makeFontsConf is almost identical to the one from the fontconfig package and /etc/fonts/fonts.conf on NixOS -- it only adds the specified font directories. In particular this means that all the actual configuration files in /etc/fonts/conf.d are still included and there also is a /usr/share/fonts font directory entry for use with non-NixOS linuxes, so it's unlikely that this breaks someone's setup. --- pkgs/tools/typesetting/tex/texlive/combine.nix | 8 +++++--- pkgs/tools/typesetting/tex/texlive/default.nix | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix index 80070cc6cfaa..22f644d9cb09 100644 --- a/pkgs/tools/typesetting/tex/texlive/combine.nix +++ b/pkgs/tools/typesetting/tex/texlive/combine.nix @@ -196,7 +196,11 @@ in (buildEnv { makeWrapper "$target" "$link" \ --prefix PATH : "${gnused}/bin:${gnugrep}/bin:${coreutils}/bin:$out/bin:${perl}/bin" \ --prefix PERL5LIB : "$PERL5LIB" \ - --set-default TEXMFCNF "$TEXMFCNF" + --set-default TEXMFCNF "$TEXMFCNF" \ + --set-default FONTCONFIG_FILE "${ + # neccessary for XeTeX to find the fonts distributed with texlive + makeFontsConf { fontDirectories = [ "${texmfroot}/texmf-dist/fonts" ]; } + }" # avoid using non-nix shebang in $target by calling interpreter if [[ "$(head -c 2 "$target")" = "#!" ]]; then @@ -311,5 +315,3 @@ in (buildEnv { '' ; }).overrideAttrs (_: { allowSubstitutes = true; }) -# TODO: make TeX fonts visible by fontconfig: it should be enough to install an appropriate file -# similarly, deal with xe(la)tex font visibility? diff --git a/pkgs/tools/typesetting/tex/texlive/default.nix b/pkgs/tools/typesetting/tex/texlive/default.nix index cbdedc9310c3..e46f6425b497 100644 --- a/pkgs/tools/typesetting/tex/texlive/default.nix +++ b/pkgs/tools/typesetting/tex/texlive/default.nix @@ -5,7 +5,7 @@ { stdenv, lib, fetchurl, runCommand, writeText, buildEnv , callPackage, ghostscript_headless, harfbuzz , makeWrapper, python3, ruby, perl, gnused, gnugrep, coreutils -, libfaketime +, libfaketime, makeFontsConf , useFixedHashes ? true , recurseIntoAttrs }: @@ -24,7 +24,7 @@ let # function for creating a working environment from a set of TL packages combine = import ./combine.nix { inherit bin combinePkgs buildEnv lib makeWrapper writeText - stdenv python3 ruby perl gnused gnugrep coreutils libfaketime; + stdenv python3 ruby perl gnused gnugrep coreutils libfaketime makeFontsConf; ghostscript = ghostscript_headless; }; From c5403f4505d77de2510cae3b7fc4b6cffed6c309 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Tue, 25 Apr 2023 22:21:42 +0200 Subject: [PATCH 2/3] texlive.combine: expose font directory via passthru This is for example useful for ncluding the texlive font directory in the `fonts.fonts` NixOS option. --- pkgs/tools/typesetting/tex/texlive/combine.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/combine.nix b/pkgs/tools/typesetting/tex/texlive/combine.nix index 22f644d9cb09..8bf807a140b6 100644 --- a/pkgs/tools/typesetting/tex/texlive/combine.nix +++ b/pkgs/tools/typesetting/tex/texlive/combine.nix @@ -82,8 +82,12 @@ in (buildEnv { nativeBuildInputs = [ makeWrapper libfaketime perl bin.texlinks ]; buildInputs = pkgList.extraInputs; - # This is set primarily to help find-tarballs.nix to do its job - passthru.packages = pkgList.all; + passthru = { + # This is set primarily to help find-tarballs.nix to do its job + packages = pkgList.all; + # useful for inclusion in the `fonts.fonts` nixos option or for use in devshells + fonts = "${texmfroot}/texmf-dist/fonts"; + }; postBuild = '' TEXMFROOT="${texmfroot}" From f2644470f9fb29bff1f677fe469e68468100f807 Mon Sep 17 00:00:00 2001 From: apfelkuchen06 Date: Thu, 27 Apr 2023 00:34:53 +0200 Subject: [PATCH 3/3] tests.texlive: also test xelatex in the opentype font test --- pkgs/test/texlive/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/test/texlive/default.nix b/pkgs/test/texlive/default.nix index cbfa0c45e8fc..91a894906cc7 100644 --- a/pkgs/test/texlive/default.nix +++ b/pkgs/test/texlive/default.nix @@ -11,11 +11,11 @@ diff -u "''${nixpkgsTlpdbNix}" "''${tlpdbNix}" | tee "$out/tlpdb.nix.patch" ''; - luaotfload-fonts = runCommand "texlive-test-lualatex" { + opentype-fonts = runCommand "texlive-test-opentype" { nativeBuildInputs = [ (with texlive; combine { inherit scheme-medium libertinus-fonts; }) ]; - input = builtins.toFile "lualatex-testfile.tex" '' + input = builtins.toFile "opentype-testfile.tex" '' \documentclass{article} \usepackage{fontspec} \setmainfont{Libertinus Serif} @@ -26,7 +26,13 @@ } '' export HOME="$(mktemp -d)" + # We use the same testfile to test two completely different + # font discovery mechanisms, both of which were once broken: + # - lualatex uses its own luaotfload script (#220228) + # - xelatex uses fontconfig (#228196) + # both of the following two commands need to succeed. lualatex -halt-on-error "$input" + xelatex -halt-on-error "$input" echo success > $out '';