7

I have just installed MacTex and I am running this simple program:

\documentclass[12pt]{article}

\usepackage{fontspec}
\usepackage{dejavu}

\begin{document}

\setsansfont{DejaVu Sans}
\setromanfont{DejaVu Serif}
\setmonofont{DejaVu Sans Mono}

\begin{abstract}
This is the paper's abstract \ldots
\end{abstract}

\section{Introduction}
This is time for all good men to come to the aid of their party!

\end{document}

When I run this command : xelatex simple.tex I get:

This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./simple.tex
LaTeX2e <2016/03/31>
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def))
(/usr/local/texlive/2016/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1enc.def)
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1lmr.fd))
(/usr/local/texlive/2016/texmf-dist/tex/xelatex/xunicode/xunicode.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3enc.def
(/usr/local/texlive/2016/texmf-dist/tex/latex/euenc/eu1lmss.fd))
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2016/texmf-dist/tex/xelatex/xetex-def/xetex.def
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2016/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))))
(/usr/local/texlive/2016/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2016/texmf-dist/tex/latex/dejavu/dejavu.sty
(/usr/local/texlive/2016/texmf-dist/tex/latex/dejavu/DejaVuSansMono.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/dejavu/DejaVuSans.sty)
(/usr/local/texlive/2016/texmf-dist/tex/latex/dejavu/DejaVuSerif.sty))
(./simple.aux) (/usr/local/texlive/2016/texmf-dist/tex/latex/tipa/t3cmr.fd)

LaTeX Font Warning: Font shape `EU1/DejaVuSerif-TLF/m/n' undefined
(Font)              using `EU1/lmr/m/n' instead on input line 6.

kpathsea:make_tex: Invalid fontname `DejaVu Sans', contains ' '

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

l.8 \setsansfont{DejaVu Sans}

I opened up my TexLive Utility to see if the dejavu package is installed and it is.

What is going on here?

1
  • I don’t have a copy to test, but creating DejaVuSerif.fontspec still works, right?
    – Davislor
    Oct 17, 2020 at 13:26

3 Answers 3

4

On Mac OS xetex + fontspec will not find OpenType fonts from the TeXLive tree if you use font names:

  • either use filenames,

  • or (simplest and recommended by some) copy over those fonts you need to a location recognized by MacOS, thus ~/Library/Fonts

  • or add a symlink inside ~/Library/Fonts, this is what I have done once and for all, I add two symlinks with targets respectively /Library/TeX/Root/texmf-dist/fonts/opentype and /Library/TeX/Root/texmf-dist/fonts/truetype. This assumes a "texdist" like structure is present. I understand it is now implemented via TeXLiveUtility in MacTeX, but as MacTeX has decided for TL2017 to drop MacOSes like Mavericks, I am not MacTeX user anymore hence I am not 100% sure these locations (themselves symlinks) exist under the above names. This set-up needs no yearly update. It does not create issues with LuaLaTeX either as the latter (via luaotfload) is (since some time, it wasn't though further back in the past) able to trim its database of fonts from duplicates originating in finding same fonts both in directly in TeXLive tree and indirectly via the two user added symlinks above to official MacOS location, targeting TeXLive tree repertories.

3

kpathsea:make_tex: Invalid fontname `DejaVu Sans', contains ' '

It says that your font name has space

For Ubuntu, if in case dejavu is indeed missing install it using:

sudo apt install fonts-dejavu*

Or install all texlive fonts

sudo apt install texlive-fonts-recommended
sudo apt install texlive-fonts-extra

I also found dejavu font here https://ctan.org/pkg/dejavu. I was able to download the zip file containing required files but I didn't install it because texlive-fonts-extra fixed the 'DejaVuSans.sty' missing issue on my computer. But if you want to install it check out this blog : https://nathanvan.wordpress.com/2012/06/14/managing-latex-packages-manually-in-ubuntu-12-04/

0

The following has just worked for me on macOS.

Downloading the dejavu package as a ZIP file from the package page: https://ctan.org/tex-archive/fonts/dejavu was the easiest way to fix this.

In the ZIP file, there is a dejavu folder that contains *.ttf files. I have opened the /Applications/Font Book.app application, clicked + and pointed it to the dejavu/truetype folder.

Here's my Sphinx configuration for Latex in the conf.py file:

...
'fontpkg': r'''
    \setmainfont{DejaVu Sans}
    \setsansfont{DejaVu Sans}
    \setmonofont{DejaVu Sans Mono}
''',

To make it work on Linux Ubuntu 20 I have used the apt install command as recommended by Sawan Vaidya.

You must log in to answer this question.