summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xelatex/fontspec/fontspec-example.ltx
blob: 28b9907a7d92af05ceb1823107a363ae55a4f129 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%%
%% This is file `fontspec-example.ltx',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fontspec.dtx  (with options: `example')
%% 
%%   ________________________________
%%   The fontspec package for XeLaTeX
%%   (C) 2004--2008    Will Robertson
%% 
%%   License information appended.
%% 
\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}
%% 
%% Copyright 2004--2008 by Will Robertson <wspr81@gmail.com>
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status)
%% by Will Robertson.
%% 
%% This work consists of this file  fontspec.dtx
%%           and the derived files fontspec.sty,
%%                                 fontspec.cfg,
%%                                 fontspec.ins,
%%                                 fontspec-example.ltx,
%%                             and fontspec.pdf.
%% 
%%
%% End of file `fontspec-example.ltx'.