The TeXLive manual has a nice section on (Testing the installation). In step 8, the user is instructed to run
xetex opentype-info.tex
The file is part of the package xetexfontinfo
This command fails with the error:
āInvalid fontname āLatin Modern Roman/ICUāā¦ā,
The same manual covers this error in section 3.4.4.
It says there:
```
To facilitate this, when the xetex package is installed (either at initial installation or later), the necessary conļ¬guration ļ¬le is created in TEXMFSYSVAR/fonts/conf/texlive-fontconfig.conf.
To set up the TeX Live fonts for system-wide use (assuming you have suitable privileges), proceed as follows:
Copy the texlive-fontconfig.conf ļ¬le to /etc/fonts/conf.d/09-texlive.conf.
Run fc-cache -fsv.
If you do not have suļ¬cient privileges to carry out the steps above, or if you want to make the TeX Live fonts available to only one user, you can do the following:
Copy the texlive-fontconfig.conf ļ¬le to ~/.fonts.conf, where ~ is your home directory.
Run fc-cache -fv.
```
But even after installing the Full-scheme of TeXLive I was unable to locate the file texlive-fontconfig.conf as described in the manual.
Running fc-cache as root or user does not help.
Perhaps this can be fixed for TL2020 #91994
@veprbl
@TredwellGit
Thanks
Here is the code that makes the fontconfig file: https://www.tug.org/texlive//Contents/live/tlpkg/tlpostcode/xetex.pl
It looks like you need to add the directories in $texdir/texmf-dist/fonts to the font path list, config.fonts.fonts in NixOS:
for my $t (qw/opentype truetype type1/) {
print FONTSCONF " <dir>$texdir/texmf-dist/fonts/$t</dir>\n";
}
I think the solution by @Mathnerd314 is the correct one, you need to have the fonts installed to locate them by name instead of a path. So adding "${texlive.combined.scheme-full}/share/texmf/fonts" or lmodern to fonts.fonts should do the trick.
Thanks for the quick response. I will give it a try and let you know here if it worked. When it works I'll try to assemble my first PR from it.
Hi @Mathnerd314,
do you mean modification of the global environment, triggered by texlive installation? The fonts.fonts solution is NixOS-specific, how would one go about it on a non-NixOS system?
Thanks
_Aside: I tried skimming through fontconfig manuals in search for environment variables to modify search paths at runtime but had no luck_
From https://discourse.nixos.org/t/fonts-in-nix-installed-packages-on-a-non-nixos-system/5871/7 it seems the magic variable is FONTCONFIG_FILE.
@StefanSchroeder any luck trying it out?
@Mathnerd314 this is most amusing and has saved my day!
For the context, I'm using nix to build a LaTeX project, so I had a default.nix file with mkDerivation which would just produce a pdf file. I found a makeFontsConf function in nixpkgs, so the final modification required was:
# ...
let
myTexlive = with pkgs.texlive; (
combine { /* ... */ }
);
fontsConf = pkgs.makeFontsConf {
fontDirectories = [
"${myTexlive}/share/texmf/"
];
};
in
{
myPdf = stdenv.mkDerivation {
# ...
buildInputs = [ myTexlive ];
FONTCONFIG_FILE = fontsConf; # this sets an environment variable visible in buildPhase
# ...
};
}
@Mathnerd314 I'm on vacation right now with no access to anything else than my cell phone. Will let you know as soon as I return. Thank you for keeping the ball rolling.
@Mathnerd314 I confirm that the error is resolved by adding 'lmodern' to fonts.fonts in configuration.nix. I wonder if this could be implemented to be resolved automatically when installing the package xetexfontinfo which requires it. I haven't tried the suggestion by @newkozlukov, as the simple change did the job.