1

I have the following document, which uses fonts stored in a fonts/ directory (specifically several subdirectories of fonts/), as well as defined font subfamilies. I'm trying to compile it into a PDF using latexmk:

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=0.75in]{geometry}


\usepackage[colorlinks=true]{hyperref}
\usepackage{metalogo}

\usepackage{fontspec}
\setmainfont{FRABK.TTF}[
  ItalicFont = FRABKIT.TTF,
  BoldFont = FRAMD.TTF,
  BoldItalicFont = FRAMDIT.TTF,
  FontFace = {db}{n}{ Font = FRADM.TTF, Path = fonts/franklin-gothic/ },
  FontFace = {db}{i}{ Font = FRADMIT.TTF, Path = fonts/franklin-gothic/ },
  Path = fonts/franklin-gothic/
]
\setsansfont{CGOR45W.TTF}[
  ItalicFont=CGOR46W.TTF,
  BoldFont=CGOR65W.TTF,
  BoldItalicFont=CGOR66W.TTF,
  Path = fonts/cg-omega/
]
\setmonofont{CONSOLA.TTF}[
  ItalicFont=CONSOLAI.TTF,
  BoldFont=CONSOLAB.TTF,
  BoldItalicFont=CONSOLAZ.TTF,
  Path = fonts/consolas/
]
\newcommand{\lmr}{\fontfamily{lmr}\selectfont} % Latin Modern Roman
\newcommand{\lmss}{\fontfamily{lmss}\selectfont} % Latin Modern Sans
\newcommand{\lmtt}{\fontfamily{lmtt}\selectfont} % Latin Modern Mono


\begin{document}


\section{Foo}
\fontseries{db}\selectfont
Demibold text \\
\normalfont
\textbf{Medium text} \\
Normal text


\noindent
  \hrulefill \par
\noindent
  \hypersetup{linkcolor=gray}
  \small
  \url{http://www.example.org/} \hfill \textbf{Date}


\end{document}

Since I'm using fontspec, this would require xelatex. However, when I run latexmk -pdf -xelatex main.tex, I receive:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! LaTeX error: "kernel/key-unknown"
!
! The key 'fontspec/Path' is unknown and is being ignored.
!
! See the LaTeX3 documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.17 ]

? h
|'''''''''''''''''''''''''''''''''''''''''''''''
| The module 'fontspec' does not have a key called fontspec/Path'.
| Check that you have spelled the key name correctly.
|...............................................

Why is fontspec/Path unknown, and how can I get it to be recognized? Is my latexmk invocation incorrect, perhaps causing it not to use xelatex at a time when it should?

More generally, could this be alleviated by better methods of organizing the font definitions or how the document is compiled?

5
  • It looks as if you can't use the Path key inside the FontFace key. I'm not sure if this is intended and you should make a bug report github.com/wspr/fontspec/issues. But in your case it is probably not needed anyway. Commented Sep 9, 2015 at 7:31
  • Right. As long as you can copy or symlink the font file, you can work around it, but this doesn’t seem to let you declare a different path for a semibold or small-caps variant you downloaded separately. It doesn’t work inside BoldFeatures or ItalicFeatures, either. As a workaround, you should be able to stick symlinks in a directory fontspec can search.
    – Davislor
    Commented Sep 9, 2015 at 8:45
  • 1
    It's quite difficult internally to allow fontspec to choose fonts from different locations (unfortunately). You can blame my poor programming practises. Some testing indicates that this error occurs because fontspec CAN find the font, so if you just delete the nested Path = ... setting you might fix the problem. Commented Sep 21, 2015 at 3:00
  • 1
    Actually I mucked around a little more in fontspec and I think this will be fixed in the next CTAN release. Commented Sep 21, 2015 at 3:36
  • 1
    @WillRobertson I don't know why it hadn't occurred to me to simply assume it didn't need to be told twice. It works perfectly now! Commented Sep 22, 2015 at 6:42

2 Answers 2

2

Per Will Robertson's comment, actually, fontspec can find the font; it just doesn't need to be told the location twice. Applying the following diff got rid of the error:

-       FontFace = {db}{n}{ Font = FRADM.TTF, Path = fonts/franklin-gothic/ },
-       FontFace = {db}{i}{ Font = FRADMIT.TTF, Path = fonts/franklin-gothic/ }
+       FontFace = {db}{n}{ Font = FRADM.TTF },
+       FontFace = {db}{i}{ Font = FRADMIT.TTF }

Full example

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=0.75in]{geometry}


\usepackage[colorlinks=true]{hyperref}
\usepackage{metalogo}

\usepackage{fontspec}
\setmainfont{FRABK.TTF}[
  ItalicFont = FRABKIT.TTF,
  BoldFont = FRAMD.TTF,
  BoldItalicFont = FRAMDIT.TTF,
  FontFace = {db}{n}{ Font = FRADM.TTF },
  FontFace = {db}{i}{ Font = FRADMIT.TTF },
  Path = fonts/franklin-gothic/
]
\setsansfont{CGOR45W.TTF}[
  ItalicFont=CGOR46W.TTF,
  BoldFont=CGOR65W.TTF,
  BoldItalicFont=CGOR66W.TTF,
  Path = fonts/cg-omega/
]
\setmonofont{CONSOLA.TTF}[
  ItalicFont=CONSOLAI.TTF,
  BoldFont=CONSOLAB.TTF,
  BoldItalicFont=CONSOLAZ.TTF,
  Path = fonts/consolas/
]
\newcommand{\lmr}{\fontfamily{lmr}\selectfont} % Latin Modern Roman
\newcommand{\lmss}{\fontfamily{lmss}\selectfont} % Latin Modern Sans
\newcommand{\lmtt}{\fontfamily{lmtt}\selectfont} % Latin Modern Mono


\begin{document}


\section{Foo}
\fontseries{db}\selectfont
Demibold text \\
\normalfont
\textbf{Medium text} \\
Normal text


\noindent
  \hrulefill \par
\noindent
  \hypersetup{linkcolor=gray}
  \small
  \url{http://www.example.org/} \hfill \textbf{Date}


\end{document}

Expected output

1

Simplest answer:

Copy the font files to ~/.fonts/, re-run fc-cache, then load them by their human-readable names.

More Comprehensive, Revised:

My first answer missed that your problem was your demibold fonts not working. Here’s how you do that. To test this, I put symlinks for all the Libertine fonts with slightly-altered names in a fonts/ directory so that there would be no possibility of XeLaTeX or LuaLaTeX finding them in their original locations.

\documentclass{article}
\usepackage{iftex}

\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{cmbright}
%% Load without Biolinum, or it will replace CM Bright,
%% and without sb, or it will replace bold:
\usepackage[libertine]{libertine}

\else % Assume a Unicode engine.
\usepackage{fontspec}

%% COPY and RENAME the Libertine files to test the engine's ability to find them.
\setmainfont{Libertine_R.otf}[
              Path = fonts/,
              FontFace = {sb}{n}{ Font = Libertine_RZ.otf},
              FontFace = {sb}{it}{ Font = Libertine_RZI.otf},
              BoldFont = {Libertine_RB.otf},
              ItalicFont = {Libertine_RI.otf},
              BoldItalicFont = {Libertine_RBI.otf},
            ]
\defaultfontfeatures{Scale=MatchLowercase}
\setsansfont[ FontFace = {sb}{n}{CMU Bright SemiBold},
              FontFace = {sb}{it}{CMU Bright SemiBold Oblique},
            ]{CMU Bright}

\fi         % \ifPDFTeX

\DeclareOldFontCommand{\sbseries}{\fontseries{sb}\selectfont}{\mathbf}
\DeclareTextFontCommand{\textsb}{\sbseries}

\begin{document}

\framebox[10cm][s]{
\rmfamily \makebox[2.5cm][c]{Normal} \makebox[2.5cm][c]{\mdseries Medium} \makebox[2.5cm][c]{\sbseries Semibold} \makebox[2.5cm][c]{\bfseries Bold} \normalfont
} \par
\framebox[10cm][s]{
\makebox[2.5cm][c]{\textsf{Normal}} \makebox[2.5cm][c]{\textsf{\textmd{Medium}}}\makebox[2.5cm][c]{\textsf{\textsb{Semibold}}} \makebox[2.5cm][c]{\textsf{\textbf{Bold}}}
}

\end{document}

Note that there’s no need to declare \inputenc in either, because they accept UTF-8 by default, and \newfontfamily exists to do what you wanted with \lmr. Also, the usual series name for semibold fonts is {sb}.

Normal Medium Bold Semibold output

Additional Notes

There are a few differences from your example, but they're minor. As in the original, this solution puts the custom fonts in a fonts/ subdirectory. The \ifPDFTeX block is only there so the example will compile on PDFLaTeX and provide reference output. Finally, the \defaultfontfeatures command has the cosmetic effect of scaling all the fonts loaded by fontspec to the same x-height.

8
  • Options can go after the filename in a current fontspec. The manual is correct. This is rather useful if you have longuish options - the fontname is nearer to the setmainfont command. Commented Sep 9, 2015 at 7:33
  • ? What do mean by bugged? It's the decision of the author how the syntax of a command should look and there is no law that optional arguments should be before the mandatory arguments. Commented Sep 9, 2015 at 7:47
  • Huh. I try it again and it worked.
    – Davislor
    Commented Sep 9, 2015 at 7:50
  • I was initially thinking that the cause of the problem was the arguments after the fontname not working, but after testing again, I was mistaken. Will edit.
    – Davislor
    Commented Sep 9, 2015 at 7:51
  • All right, new answer that fixes his actual problem.
    – Davislor
    Commented Sep 9, 2015 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .