[Tex/LaTex] \DeclareTextFontCommand and \textsl, \textbf,

boldcomputer-modernfontsslanted

I am working on a document, which uses the fontspec package to ensure the usage of company fonts for main font, sans-serif font and monospaced font. That is working fine.

\usepackage{fontspec}
\setmainfont[
    ItalicFont={Hoefler Text Regular Italic},
    SmallCapsFont={Hoefler Text Roman SC},
    BoldFeatures={
        SmallCapsFont={Hoefler Text Bold SC}
    },
    ItalicFeatures={
        SmallCapsFont={Hoefler Text Regular Italic SC}
    },
    BoldItalicFeatures={
        SmallCapsFont={Hoefler Text Bold Italic SC}
    },
]{Hoefler Text}

\usepackage{biolinum}
\setsansfont[
    Numbers=OldStyle,
    BoldFont={LinBiolinumOB},
    ItalicFont={LinBiolinumOI},
    BoldItalicFont={LinBiolinumOBO},
]{LinBiolinumO}

\usepackage{sourcecodepro}

The problem is, I also need passages being set in "Computer Modern" font. Therefore I added the following to my preamble:

\newcommand*{\computermodern}{\fontfamily{cmr}\selectfont}
\newenvironment{cmfont}{\fontfamily{cmr}\selectfont}{\par}
\DeclareTextFontCommand{\textcm}{\computermodern}

The passages, put between \begin{cmfont} and \end{cmfont} are set in Computer Modern font, but additional format information like italic, slanted, bold, etc. is ignored. How can I also achieve this?

Thanks in advance.

Best Answer

Using the Latin Modern, instead of Computer Modern font, solved the problem.

Just had to include the lmodern package \usepackage{lmodern} and changed the self introduced font commands to:

\newcommand*{\latinmodern}{\fontfamily{lmr}\selectfont}
\newenvironment{lmfont}{\fontfamily{lmr}\selectfont}{\par}
\DeclareTextFontCommand{\textlm}{\latinmodern}
\newcommand*{\latinmodernsans}{\fontfamily{lmss}\selectfont}
\newenvironment{lmsfont}{\fontfamily{lmss}\selectfont}{\par}
\DeclareTextFontCommand{\textlms}{\latinmodernsans}
\newcommand*{\latinmoderntype}{\fontfamily{lmtt}\selectfont}
\newenvironment{lmtfont}{\fontfamily{lmtt}\selectfont}{\par}
\DeclareTextFontCommand{\textlmt}{\latinmoderntype}

This makes it also possible to access Latin Modern font's sans-serif and typewriter face.