You are correct that fontspec doesn't have proper support for Graphite fonts yet. However, I did once add the option to select the Graphite font renderer. Here's an example:
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\fontspec[
Renderer=Graphite,
RawFeature={
Special=Hide tone contour staves
}
]{Charis SIL}
foo
\end{document}
I've hardly worked at all with any Graphite fonts, however, and I don't know if this is sufficient (it's certainly not optimal in terms of user interface).
Update: here's an actual example that shows something useful:
\fontspec[Renderer=Graphite,RawFeature={1024=0}]{Charis SIL} Ŋ
\fontspec[Renderer=Graphite,RawFeature={1024=1}]{Charis SIL} Ŋ
\fontspec[Renderer=Graphite,RawFeature={Uppercase Eng alternates=Large eng on baseline}]{Charis SIL} Ŋ
\fontspec[Renderer=Graphite,RawFeature={1024=2}]{Charis SIL} Ŋ
\fontspec[Renderer=Graphite,RawFeature={1024=3}]{Charis SIL} Ŋ
Lines 2 and 3 are equivalent. To get a listing of what font features are available, you can use the ‘aat-info.tex’ file and use the following for the first two code lines:
\def\myfontname{Charis SIL/GR}
\font\testfont="\myfontname" at 10pt
The main difference between your requirements and the post you pointed at is that they changed the main font of the document with the \setmainfont
, \setsansfont
and \setmonofont
in their preamble and they then want to redefine these fonts mid document. It is indeed these three commands that define the document font not simply the use of fontspec
Your requirements, if I understand them correctly, are to have use the normal font throughout the document except in a few places where you want to use the TrueType font.
What fontspec
does, broadly, is facilitate the use of fonts within LaTeX using a new engine and compatible with XeTeX and LuaTeX. Fontspec
also replaces the fontenc
package (either use one or the other, not both, otherwise things might get rather funny.
What fontspec
also does it use by default OTF fonts instead of Type1 fonts and will default to the Latin Modern set which is basically the OTF equivalent of the Computer Modern type1 fonts.
From the information you have given it is hard to know exactly what you are after. Andale Mono is a monospaced font so one could interpret your question as "how do I replace the mono font?". In which case something like this should work for you:
\documentclass[12pt,preview]{standalone}
\usepackage{fontspec}
%\setmainfont{Latin Modern Roman} %this is not needed as this should be the default
%\setsansfont{Latin Modern Sans}
\setmonofont{Andale Mono}
\begin{document}
This text using the {\bfseries Latin} {\sffamily Modern} {\itshape Font}
{\ttfamily This text is using the \textbf{Andale} \textit{Mono} font}
The is now back to the latin Modern Font
\end{document}
Giving you:
note that the Andale Mono font does not come with the bold and italic glyphs so it reverts back to the normal glyphs instead. However fontspec
allows you to fake this using options to the font definition command:
\setmonofont[AutoFakeBold,AutoFakeSlant]{Andale Mono}
If on the other hand you wish to keep the default fonts (roman, sans and mono) to the default and add a paragraph or something in Andale Mono, then the approach is slightly different and you need to declare a new font family as your sample code does:
\documentclass[12pt,preview]{standalone}
\usepackage{fontspec}
\newfontfamily\codefamily[AutoFakeBold,AutoFakeSlant]{Andale Mono}
\DeclareTextFontCommand{\codefont}{\codefamily}
\begin{document}
This text using {\ttfamily the} {\bfseries Latin} {\sffamily Modern} {\itshape Font}
{\codefamily This text is using the \textbf{Andale} \textit{Mono} font}
The is now back to the latin Modern Font
\end{document}
Giving you:
Best Answer
The document @Sverre wrote, but with LuaLaTeX gives a correct output. However, as @UlrikeFischer said, it seems to be “wrong” in many ways.
EDIT:
If you want to be able to compile in pdfLaTeX without changing input you can
PS: I added the
fontenc
package that I missed before, and the document seems to work the same way as with OT1.