# Wrong glyph and wrong ligature with FiraMono and listings

Consider the following MWE:

% Compile with pdfLaTeX
\documentclass{article}
\usepackage{FiraMono}
\usepackage{listings}
\lstset{
language=[LaTeX]TeX,
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true
}
\begin{document}
\begin{lstlisting}
\ifx\foo\baz
\fi
\end{lstlisting}
\end{document}


Why is the backslash rendered as double-quote? And how to disable the fi ligature? Note that these two problems disappear if one compiles the above MWE with XeLaTeX.

Reasons for columns=fullflexible: The default columns=fixed puts each character in a box of fixed width 0.6em. Coincidentally, 0.6em happens to be the width of a character from Fira Mono. But for other typefaces, the widths differ. The option columns=fullflexible sets each character to its natural width, which is desired.

You can use the microtype package to disable ligatures for all tt fonts. This will also disable kerning for that particular font, but that's usually unwanted for typewriter text anyway.

For the backslash, the default OT1 encoding does not have enough slots, so it is not mapped. Using T1 encoding fixes the problem.

% Compile with pdfLaTeX
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{FiraMono}
\usepackage{listings}
\lstset{
language=[LaTeX]TeX,
basicstyle=\ttfamily,
columns=fullflexible,
keepspaces=true
}
\DisableLigatures{encoding = *, family = tt* }
\begin{document}
\begin{lstlisting}
\ifx\foo\baz
\fi
\end{lstlisting}
\end{document}