# \texttt does not break in two lines

I use \texttt to format some text. I need to break it into two lines if it exceeds the line width. I use \justify but it does not always work. The script below shows two examples one works well and the other does not. Can you identify why \justify does not work in one case?

\documentclass[sigconf]{acmart}
\newcommand*\justify{%
\fontdimen2\font=0.4em% interword space
\fontdimen3\font=0.2em% interword stretch
\fontdimen4\font=0.1em% interword shrink
\fontdimen7\font=0.1em% extra space
\hyphenchar\font=\-% allowing hyphenation
}
\usepackage{lipsum}
\begin{document}
\title{Test}

\author{First Author}
\affiliation{%
\institution{First University}
\city{City}
\state{Country}
}
\email{mail@mail.com}

\author{Second Author}
\affiliation{%
\institution{Second University}
\city{City}
\state{Country}
}
\email{mail2@mail.com}
\begin{abstract}
Abstract here.
\end{abstract}
\maketitle
\section{Section}
\lipsum

\texttt{\justify{xxxx:xxxx;yyyyyyyyy:yy-yy-yyyy;zzzzzzz:zz-zz-zzzz;uuu-uuuuu:uuuuuu-uuuuuu;aaaaaaaaaaaaaaaa:a;cccccc:c;wwwwww:wwwwww@qqqq.qqq}}

\texttt{\justify{long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-}}

\end{document}

• Which one works? The second one? – Marco Jun 21 '18 at 6:53
• note you have defined \justify with no argument so should be \justify xxx... not \justify{xxx....} – David Carlisle Jun 21 '18 at 7:07
• Your first example has very few possible break points. – Andrew Swann Jun 21 '18 at 7:24

\RequirePackage[hyphens]{url}
\documentclass[sigconf]{acmart}

\usepackage{lipsum}
\begin{document}
\title{Test}

\author{First Author}
\affiliation{%
\institution{First University}
\city{City}
\state{Country}
}
\email{mail@mail.com}

\author{Second Author}
\affiliation{%
\institution{Second University}
\city{City}
\state{Country}
}
\email{mail2@mail.com}
\begin{abstract}
Abstract here.
\end{abstract}
\maketitle
\section{Section}
\lipsum

\begin{flushleft}

\path|xxxx:xxxx;yyyyyyyyy:yy-yy-yyyy;zzzzzzz:zz-zz-zzzz;uuu-uuuuu:uuuuuu-uuuuuu;aaaaaaaaaaaaaaaa:a;cccccc:c;wwwwww:wwwwww@qqqq.qqq|

\path|long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-long-text-|

\end{flushleft}

\end{document}
`