[Tex/LaTex] Specify italic font for PDFlaTeX

fonts

For my PDFlaTeX document I`d like to use roboto slab light for the main text and roboto in titles. I am having the following problems:

  1. if I set roboto slab light as main font, then I do not know how to set roboto for titles only. I try to do that with \sffamily, but it does not work. What I get is a document written completely in roboto slab light (incl. titles)
  2. roboto slab light is that it does not have italics – how to specify a different font (e.g. roboto) to be used with \textit and \emph{}?

Here an example:

\documentclass[a4paper, 12pt, english]{report}
\usepackage[rm, light]{roboto} %this makes roboto slab light the main document font
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{titling}
\titleformat*{\section}{\sffamily\Large} %with sffamily I try to set roboto regular as section title font

\begin{document}
\section{I need to be in roboto font}
I am normal text and need to be in roboto slab light font.
\textit{I am in italics and need a different font, e.g. roboto}
\end{document}

Best Answer

Explicitly load the font definition file, so you'll be able to add some declarations afterwards.

For the section titles, specify the Roboto-LF family.

\documentclass{report}
\usepackage[T1]{fontenc}

\usepackage[rm,light]{roboto}
\usepackage{titlesec}

\makeatletter
\input{\encodingdefault RobotoSlab-TLF.fd}
\DeclareFontShape{\encodingdefault}{\familydefault}{l}{it}{
 <->ssub*Roboto-TLF/l/it
}{}
\makeatother

\titleformat*{\section}{\fontfamily{Roboto-LF}\fontseries{m}\Large}

\begin{document}

\section{I need to be in roboto font}


I am normal text and need to be in roboto slab light font.
\textit{I am in italics and need a different font, e.g. roboto}
\end{document}

enter image description here