I am trying to use a display font for special headers — it is Anton in truetype format, but to continue to use normal Latex fonts for the rest of the document. I thought this would be achieved by
\usepackage{droid}
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX} % To support LaTeX quoting style
\newfontfamily\headerfont{Anton}
\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\fi
but if this is compiled by xelatex, the droid package is ignored, and if by pdflatex, the Anton font is not available. Is there a way round this problem?
Best Answer
\ifxetex
detects whether you are compiling with XeTeX or not. If you are, it executes theif
bit. If not, it executes theelse
bit. Moreover, you cannot useinputenc
with XeTeX (so it is good, really, that that code is never read).You can use 'normal LaTeX fonts' for the rest of the document, though. Just use the three lines of code from
\usepackage{fontspec}
and put\usepackage{droid}
configuration afterwards, as loadingfontspec
sets the default families to Latin Modern.However, you may prefer to use the Droid fonts in opentype/truetype format to take full advantage of XeTeX.
Note that I changed the value of
\headerfont
to prevent XeLaTeX hanging forever since I don't have the font you are using.