-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
texlive: xelatex doesn't see fonts #24485
Comments
XeLaTeX from I don’t know how to compile your document in a pure shell, but in an impure environment you can:
|
My main goal is to be able to create the output PDF with only |
I’m not sure how the nixpkgs philosophy is compatible with the fontconfig philosophy. Your problem boils down to the fact that the following does not work as we may expect; even on NixOS:
BTW you can use nix to resolve the fonts and do things like the following in your TeX file:
|
Disclaimer: I know almost nothing about fontconfig. However, the way I see it is I want my PDF to be built as a pure function of its inputs, which include a specific set of latex packages and some fonts. Why shouldn't that work? About that last example, that would almost be what I'm looking for except it seems really ugly that I would have to a) hardcode the value to the location in the nix store and b) if it somehow got updated that path would change and it would break? But if there was some reliable way to get the path to the nix store where my font is, that would be awesome. I was thinking about somehow setting environment variables from |
It might work with |
I can confirm the FONTCONFIG_FILE with makeFontConf, I've been using this to automate xelatex docs for months, seems to do the trick at least for my case. I also find it helpful to add that to the shellHook for use while editing and incremental builds. |
Snippet, although unsure of the accuracy of my comment just a note to myself :). let
# grab fonts we need, xetex wants them installed as system fonts
# There's a "fira" package in texlive, but I can't seem to get it to work with xetex or luatex,
# possibly a bug in how nixpkgs packages them (there's a TODO about font visibility).
fonts = makeFontsConf { fontDirectories = [ freefont_ttf fira fira-mono ]; };
in with import ./src.nix;
stdenv.mkDerivation {
name = "allvm-slides-${version}";
inherit version;
src = fetchgit srcinfo;
buildInputs = [ tex ghostscript pandoc ];
preBuild = ''
export FONTCONFIG_FILE=${fonts}
''; |
Amazing! I will post here my minimal working solution. Should there be something about this in the documentation for texlive on nixpkgs? { nixpkgs ? import <nixpkgs> {} }:
with nixpkgs.pkgs;
stdenv.mkDerivation {
name = "textest";
src = ./.;
buildInputs = [
(texlive.combine {
inherit (texlive) scheme-basic xetex xetex-def fontspec euenc;
})
];
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ lmodern ]; };
buildPhase = ''
xelatex test.tex
'';
installPhase = ''
mkdir -p $out
cp test.pdf $out
'';
} \documentclass{minimal}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\begin{document}
Hello
\end{document} Sent from my LGE Nexus 5X using FastHub |
It could be a subsection in the manual or perhaps a tutorial in the cookbook. |
@jbaum98 Hi, I tried your solution. And got this error
Thanks |
@srivathsanmurali confirmed. Put parenthesis around the |
@dtzWill Great. That worked :D |
I've updated my previous answer with this fix. Sent from my LGE Nexus 5X using FastHub |
Is there a way to use the built-in system fonts as well? It appears to break the purity but that's still pretty useful... |
I would expect that to work already – if you don't define |
Well, in my case it doesn't :(
|
The mentioned method only seems to work if mentioning a font by Name, not by filename
does not work.
does work Many LaTex packages like ( |
I used to build a book with pandoc and xelatex and it worked ok (note that I'm not building it in a pure environment). I haven't touched it in a while and now I found out it produces a PDF with no fonts. |
What do you mean by a PDF with no fonts? I build this derivation { stdenv, fetchgit, texlive, pandoc, makeFontsConf, lmodern }:
stdenv.mkDerivation rec {
name = "${pname}-${version}";
pname = "category-theory-for-programmers";
version = "0.4.0";
src = fetchgit {
url = "https://maxwell.ydns.eu/git/rnhmjoj/category-theory-for-programmers";
rev = "v${version}";
sha256 = "0z5bn5147b3r1937cd4ai5fmy44dcxjpwbr45v8mkfbkqpki0lg5";
};
buildInputs = [
(texlive.combine {
inherit (texlive) scheme-full;
})
pandoc
];
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ lmodern ]; };
patches = [ ./cat-theory.patch ];
buildPhase = ''
make all
'';
installPhase = ''
mkdir -p $out
cp ${pname}.pdf ${pname}.epub $out/
'';
} with this patch because diff --git a/makefile b/makefile
index c07ffc0..6f1fefe 100644
--- a/makefile
+++ b/makefile
@@ -12,10 +12,10 @@ $(title).pdf:
pandoc \
$(src)/init/preface.html \
$(chapters) \
- --smart \
+ --from html+smart \
--toc \
--number-section \
- --latex-engine=xelatex \
+ --pdf-engine=xelatex \
--data-dir=$(root)/pandoc \
-H $(root)/pandoc/options.tex \
-o $(root)/$(title).pdf
@@ -25,10 +25,10 @@ $(title).epub:
pandoc \
$(src)/init/preface.html \
$(chapters) \
- --smart \
+ --from html+smart \
--toc \
--number-section \
- --epub-stylesheet=$(root)/pandoc/style.css \
+ --css=$(root)/pandoc/style.css \
--epub-cover-image=$(root)/pandoc/cover.png \
--epub-embed-font='$(src)/fonts/*.woff' \
-o $(root)/$(title).epub and I get a pdf that looks fine, but it produces a lot of warnings about missing symbols.Does it look right? Do you know what the fonts are supposed to be? The warnings look like this:
|
@jbaum98 The PDF you produced looks exactly like mine: this probably mean there is an issue with my PDF viewer or maybe my NixOS configuration. Here's what I see: |
Hmm so maybe the PDF being produce doesn't have the fonts embedded, but I have the fonts installed globally so its good for me. |
I used
So I'm not so sure what's going on. |
I tried opening it with a different PDF viewer (evince) and the fonts are displayed correctly so it must be something with zathura. I noticed when I scroll the PDF zathura floods the console with
I'll look into and maybe report it if it's not known already. Sorry for the noise. |
(triage) @jbaum98 any updates on this issue? From what I understand generating the pdf works now and the fonts are included, right? |
Yes, for me this issue is resolved, but it seems like @rnhmjoj is having some other issues. |
Hi guys, sorry to bump an old issue but this is the only place where I found a working example and an explanation on why fonts were not being found in the context of I'm trying to use fonts that should ship with
I was able to create a working environment by adding:
however due to the way texlive fonts are packaged I need to append Question is, should this be necessary in the first place given that I'm using The derivation now looks like:
|
@unode I suppose the internals of the texlive packages were not designed to be a part of the public API, so they are not very convenient to use. The If you have some specific ideas about how to improve the situation, feel free to open a new issue. |
There doesn't seem to be an answer anywhere in this thread, and I just ran into this issue. The fix is very simple - add the system font directories to {
FONTCONFIG_FILE = pkgs.makeFontsConf { fontDirectories = [
"/Library/Fonts"
"/System/Library/Fonts"
"/Users/USER/Library/Fonts"
pkgs.lmodern
]; };
} |
This should not be needed after #228196 (i.e. will be fixed in 23.05) |
Issue description
On Darwin, texlive does not system or nixpkgs installed fonts.
Steps to reproduce
Technical details
The text was updated successfully, but these errors were encountered: