This is almost a duplicate of but its answer doesn't work for me.
I downloaded the complete Roboto superfamily (Roboto, Roboto Condensed, Roboto Slab and Roboto Mono) and I want to use all the families, all the weights, widths, variants and styles inside my document. Of course mine is not a real need, but I want to understand clearly how the fontspec
package works.
All my .ttf files are located in a directory called fonts
, subdivided into directories with the name of the family (fonts/Roboto
, fonts/Roboto_Condensed
, etc…).
Inpired by XeLaTeX and font weight, the package documentation of fontspec
and the texdoc font installation guide I included the Roboto font in this way.
\setmainfont{Roboto}[
Path = fonts/Roboto/,
Extension = .ttf,
%-- Upright --%
FontFace={ul}{n}{Font=*-Thin},
FontFace={l}{n}{Font=*-Light},
FontFace={m}{n}{Font=*-Regular},
FontFace={mb}{n}{Font=*-Medium},
FontFace={b}{n}{Font=*-Bold},
FontFace={eb}{n}{Font=*-Black},
% %-- Italic --%
FontFace={ul}{it}{Font=*-ThinItalic},
FontFace={l}{it}{Font=*-LightItalic},
FontFace={m}{it}{Font=*-Italic},
FontFace={mb}{it}{Font=*-MediumItalic},
FontFace={b}{it}{Font=*-BoldItalic},
FontFace={eb}{it}{Font=*-BlackItalic},
]
But I obtain the following error:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "Roboto" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H .
!………………………………………..
But the path is right. In fact with this MWE
\documentclass[10pt]{article}
\usepackage{fontspec}
\setmainfont{Roboto}[
Path = fonts/Roboto/,
Extension = .ttf,
UprightFont = *-Regular,
%-- Upright --%
FontFace={ul}{n}{Font=*-Thin},
FontFace={l}{n}{Font=*-Light},
FontFace={m}{n}{Font=*-Regular},
FontFace={mb}{n}{Font=*-Medium},
FontFace={b}{n}{Font=*-Bold},
FontFace={eb}{n}{Font=*-Black},
% %-- Italic --%
FontFace={ul}{it}{Font=*-ThinItalic},
FontFace={l}{it}{Font=*-LightItalic},
FontFace={m}{it}{Font=*-Italic},
FontFace={mb}{it}{Font=*-MediumItalic},
FontFace={b}{it}{Font=*-BoldItalic},
FontFace={eb}{it}{Font=*-BlackItalic},
]
\DeclareRobustCommand{\ulseries}{\fontseries{ul}\selectfont}
\DeclareRobustCommand{\lseries}{\fontseries{l}\selectfont}
\DeclareRobustCommand{\mseries}{\fontseries{m}\selectfont}
\DeclareRobustCommand{\mbseries}{\fontseries{mb}\selectfont}
\DeclareRobustCommand{\bseries}{\fontseries{b}\selectfont}
\DeclareRobustCommand{\ebseries}{\fontseries{eb}\selectfont}
\DeclareTextFontCommand{\textul}{\ulseries}
\DeclareTextFontCommand{\textl}{\lseries}
\DeclareTextFontCommand{\textm}{\mseries}
\DeclareTextFontCommand{\textmb}{\mbseries}
\DeclareTextFontCommand{\textb}{\bseries}
\DeclareTextFontCommand{\texteb}{\ebseries}
\begin{document}
\sffamily
\textul{Abc Thin} {\ulseries Thin}
\textl{Abc Light} {\lseries Light}
\textm{Abc Light} {\mseries Light}
Abc Regular
\textmb{Abc SemiBold} {\mbseries SemiBold}
\textb{Abc Bold} {\bseries Bold}
\texteb{Abc ExtraBold} {\ebseries ExtraBold}
\end{document}
I obtain this warning
LaTeX Font Warning: Font shape
TU/lmss/ul/n' undefined (Font)
TU/lmss/m/n' instead on input line 53.
usingLaTeX Font Warning: Font shape
TU/lmss/l/n' undefined (Font)
TU/lmss/m/n' instead on input line 55.
usingLaTeX Font Warning: Font shape
TU/lmss/mb/n' undefined (Font)
TU/lmss/m/n' instead on input line 61.
usingLaTeX Font Warning: Font shape
TU/lmss/eb/n' undefined (Font)
TU/lmss/m/n' instead on input line 65.
using
And this result, that clearly is not what I want.
Best Answer
The problem was that I didn't select the roman font family but the sans serif one as pointed out by egreg in the comments. However an alone of mistery still remains in my opinion: why xelatex throw an error if I don't put
UprightFont = ...
?However, this is the final result
and this is the result.
Hope that it can be helpful to someone in the future.
If egreg want to put his comment as answer I'll gladly accept it.