A minimal document that uses an OTF font from your PC can look like this:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Constantia}
\begin{document}
This is a text.
\end{document}
Assuming that you have the font “Constantia” installed (included in current versions of Windows and Microsoft Office). You can of course use any other font.
To build the document, all you need to do is change the build command from latex
(or pdflatex
) to xelatex
.
I don’t know how to do this in TeXnicCenter but it should be very straightforward – consult the help file.
Finally, have a look at the documentation of fontspec
. This is the package that controls loading of TTF and OTF fonts.
There is one rather important caveat: XeTeX assumes that your document is saved using the character encoding UTF-8. This controls how extended characters (á, ö, ß …) are represented in the file. Unfortunately, TeXnicCenter still has no support for UTF-8, which is a crying shame. However, as long as you only use the normal American alphabet, there should be no problems. If you need extended characters, you must unfortunately switch to a better editor.
As shown at page 28 of the manual, adding the option
basicstyle=\ttfamily
to the \lstset{}
command would make what you ask.
Keep in mind to always read the packages documentation on your machine before posting.
Best Answer
Have you tried using
\setmonofont[<options>]{<font name>}
withfontspec
?