[Tex/LaTex] Declare a new font shape

fonts

In my document \bfseries is defined to select the "semibold" shape, however the typewriter family (beramono) does not have a "semibold" shape. So I receive a warning:

LaTeX Font Warning: Font shape `T1/fvm/sb/n' undefined
(Font)              using `T1/fvm/m/n' instead on input line 250.

I tried the solution discussed here by using the follwoing command to declare a new font shape for typewriter family.

\DeclareFontShape{T1}{fvm}{sb}{n}{<->ssub*fvm/b/n}{}

or

\DeclareFontShape{\encodingdefault}{\ttdefault}{sb}{n}{<->ssub*\ttdefault/b/n}{}

And for both commands I received the follwoing error:

! LaTeX Error: Font family `T1+fvm' unknown.

A working example is:

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

\usepackage[oldstyle,semibold,type1]{libertine}
\usepackage[scaled=.85]{beramono}% typewriter font 

\DeclareFontShape{T1}{fvm}{sb}{n}{<->ssub * fvm/b/n}{}

\begin{document}

\ttfamily\bfseries Hello World!

\end{document}

Best Answer

LaTeX needs to see a \DeclareFontFamily declaration before a \DeclareFontShape command can be issued.

A simple way out is to add

\sbox0{\ttfamily X}

after \usepackage[<options>]{beramono}, which will cause the corresponding .fd file to be read in, which contains the appropriate \DeclareFontFamily command.