summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xelatex/fontspec/fontspec-example.ltx
blob: 6289e83ce9716a0682111f1270950ba0acf5d191 (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
\documentclass{article}

\usepackage{euler}
\usepackage[cm-default]{fontspec}
\usepackage{xltxtra}

\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text}
\setmainfont[Numbers=Lowercase]{FPL Neu}
\setsansfont{Lucida Sans}
\setmonofont{Lucida Sans Typewriter}

\frenchspacing % TeX's default is a little old-fashioned...

\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]{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, sans serif, and typewriter fonts may be set with the \verb|\setmainfont|, \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}
  {\itshape Italics and \scshape small caps\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---or the \textsf{eulervm} package if the |xpdfdvimx| driver is being used), since the default Computer Modern maths font is rather light.
\[
  \mathcal F(s) = \int^\infty_0 f(t) \exp(-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}