summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xetex/fontspec/fontspec-example.tex
blob: 2aed92a6fc30b87682259aa20e387994fe440d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

\documentclass[12pt]{article}

\usepackage{euler,fontspec,graphicx}

\defaultfontfeatures{Scale=MatchLowercase ,Mapping=tex-text}
\setromanfont{Hoefler Text}
\setsansfont{Gill Sans}
\setmonofont{Lucida Sans Typewriter}

%% Define the \XeTeX logo:
\DeclareRobustCommand\XeTeX{%
  \mbox{\smash{%
    X\lower.5ex\hbox{\kern-.12em\reflectbox{E}}\kern-.1667em
    T\kern -.1667em\lower .5ex\hbox {E}\kern -.12em X}}\@}
%% The logo should be defined on a per-document basis
%% so that its parameters may be fine tuned for the fonts used.

\begin{document}
\pagestyle{empty}

\section{The basics of the \textsf{fontspec} package}

The \textsf{fontspec} package enables automatic font selection for \LaTeX{} documents typeset with \XeTeX{}. The basic command is\\
\indent \verb|\fontspec[font features]{Mac OS X font display name}|.\\
As an example:

\begin{center}
  \Large
  \fontspec[
      Colour           = 0000CC,
      Numbers          = OldStyle,
      VerticalPosition = Ordinal,
      Variant          = 2
           ]{Apple Chancery}
  My 1st example of Apple Chancery
\end{center}

The default roman, sans serif, and typewriter fonts may be set with the \verb|\setromanfont|, \verb|\setsansfont| and \verb|\setmonofont| commands, respectively, as shown in the preamble. They take the same syntax as the \verb|\fontspec| package. All expected font shapes are available:

\begin{center}
  {\scshape Small caps and \itshape small caps italic\dots}\\
  {\sffamily\bfseries Bold sans serif and \itshape bold italic sans serif\dots}
\end{center}

With the roman and sans serif fonts set in the preamble, text fonts in math mode are also changed: $\cos(n\pi)=\pm 1$. The maths typeface `Euler' has been used in this document (with the \textsf{euler} package---note that the \textsf{eulervm} package will not work in \XeTeX{} because it uses virtual fonts), since the default Computer Modern maths font is rather light.
\[
  \mathcal F(s) = \int^\infty_0\! f(t) e^{-st}\,\mathrm{d}t
\]

You'll also notice the \verb|\defaultfontfeatures| command in the preamble. This command takes a single argument of font features that are then applied to every subsequent instance of font selection. The first argument in this case, \verb|Mapping=tex-text|, enables regular \TeX{} ligatures like \verb|``---''| for ``---''. The second automatically scales the fonts to the same x-height.

Please see the documentation for font feature explanation and further package niceties.

\end{document}