[Tex/LaTex] Consolas: Straight Quotes

listingstypewriterxetex

I am using the listings-Package to display code. As I am using The Consolas Font as the Monotype-Default I expected straight quotes which isn't the case (check my MWE)

 \documentclass[a4paper]{article}
 \usepackage{listings}
 \usepackage{polyglossia}
 \setdefaultlanguage[]{english}

 \setmonofont[Ligatures=TeX]{Consolas}

  \lstset{frame=single}

  \begin{document}
  \begin{lstlisting}
  "some code to try"
  \end{lstlisting}

  \end{document}

Can Anyone help How to get straight quotes?
enter image description here

Best Answer

This is actually caused by Ligatures=TeX, which causes fontspec to automatically convert a " to curly quotes, it appears. Further, as I mentioned in a comment, listings does not use the monotype font by default, so to actually use Consolas in the listings, add basicstyle=\ttfamily to lstset.

\documentclass[a4paper]{article}
\usepackage{listings}
\usepackage{polyglossia}
\setdefaultlanguage[]{english}

\setmonofont{Consolas}

\lstset{frame=single,basicstyle=\ttfamily}

\begin{document}
\begin{lstlisting}
"some code to try"
\end{lstlisting}
\end{document}

enter image description here