I followed the solution given in this question in order to change the font for a few sections of the text I am writing. However, the text does not get justified and it exceeds the set width of the text. How can I fix this? See, e.g., the following code:
\documentclass[10pt]{article}
\pdfoutput=1
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[english]{babel}
\newcommand*{\myfont}{\fontfamily{pcr}\slshape\footnotesize\selectfont}
\DeclareTextFontCommand{\textmyfont}{\myfont}
\begin{document}
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into stiff sections. This is \textmyfont{just dummy text}. The bedding was hardly able to cover it and seemed ready to slide off any moment. His many legs, pitifully thin compared with the size of the rest of him, waved about helplessly as he looked.
\begin{myfont}
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia.
\end{myfont}
\end{document}
\raggedright
also as you have a size change you need to leave a blank line before\end{myfont}
othewise the baseline spacing will be wrong.\hbox
" and "overfull\hbox
" in the same line?