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.
Path=./fonts/Roboto
? Where is thefonts
directory located?UprightFont = *-Regular
as shown in the MWE it doesn't throw errors but only warning.FontFace={..}{...}{Font=*-...}
. I checked the last brackets and all the files have the correct name. For the first two brackets I used the values in Tables A.1 and A.3 of font installation guide as suggested by the fontspec documentation.\setsansfont
if you want Roboto for sans serif