Debian Codegraph @

texmf-dist/source/latex/fontspec/fontspec-doc-intro.tex

raw
1 %%^^A%% fontspec-doc-intro.tex -- part of FONTSPEC <latex3.github.io/fontspec>
2
3 \documentclass[a4paper]{l3doc}
4 \usepackage{fontspec-doc-style}
5 \showexamplesfalse
6 \begin{document}
7
8 \part{Getting started}
9
10 \section{History}
11
12 This package began life as a \LaTeX\ interface to select system-installed
13 \MacOSX\ fonts in \name{Jonathan Kew}'s \XeTeX, the first widely-used
14 Unicode extension to \TeX. Over time, \XeTeX\ was extended to support OpenType
15 fonts and then was ported into a cross-platform program to run also on Windows
16 and Linux.
17
18 More recently, \LuaTeX\ is fast becoming the \TeX\ engine of the day; it
19 supports Unicode encodings and OpenType fonts and opens up the internals of
20 \TeX\ via the Lua programming language. Hans Hagen's Con\TeX t Mk.\,IV is a
21 re-write of his powerful typesetting system, taking full advantage of
22 \LuaTeX's features including font support; a kernel of his work in this area
23 has been extracted to be useful for other \TeX\ macro systems as well, and
24 this has enabled \pkg{fontspec} to be adapted for \LaTeX\ when run with the
25 \LuaTeX\ engine.
26
27
28
29 \section{Introduction}
30
31 The \pkg{fontspec} package allows users of either \XeTeX\ or \LuaTeX\ to
32 load OpenType fonts in a \LaTeX\ document. No font installation is necessary,
33 and font features can be selected and used as desired throughout the document.
34
35 Without \pkg{fontspec}, it is necessary to write cumbersome font definition
36 files for \LaTeX, since \LaTeX's font selection scheme (known as the
37 `\textsc{nfss}') has a lot going on behind the scenes to allow easy
38 commands like \cmd\emph\ or \cmd\bfseries. With an uncountable number of
39 fonts now available for use, however, it becomes less desirable to have to
40 write these font definition (|.fd|) files for every font one wishes to use.
41
42 Because \pkg{fontspec} is designed to work in a variety of modes, this
43 user documentation is split into separate sections that are designed to be
44 relatively independent. Nonetheless, the basic functionality all behaves in
45 the same way, so previous users of \pkg{fontspec} under \XeTeX\ should have
46 little or no difficulty switching over to \LuaTeX.
47
48 This manual can get rather in-depth, as there are a lot of details
49 to cover. See the documents \path{fontspec-example.tex} for a complete minimal example
50 to get started quickly.
51
52
53 \subsection{Acknowledgements}
54
55 This package could not have been possible without the early and continued support
56 the author of \XeTeX, Jonathan Kew. When I started this package, he steered
57 me many times in the right direction.
58
59 I've had great
60 feedback over the years on feature requests, documentation queries, bug reports, font suggestions, and so on from lots of people all around the world.
61 Many thanks to you all.
62
63 Thanks to David Perry and Markus B\"ohning for numerous documentation
64 improvements and David Perry again for contributing the text for one of the
65 sections of this manual.
66
67 Special thanks to Khaled Hosny, who was the driving force behind the support for \LuaLaTeX, ultimately leading to version 2.0 of the package.
68
69
70
71 \section{Package loading and options}
72
73 For basic use, no package options are required:
74 \begin{Verbatim}
75 \usepackage{fontspec}
76 \end{Verbatim}
77 Package options will be introduced below; some preliminary details are discussed first.
78 Package options are setup with the in-built \LaTeX{} keyval options handler. This means
79 that the package can be loaded more than once with different options without triggering
80 an option clash error.
81 \DescribeOption{config}
82 \DescribeOption{no-config}
83 The \texttt{config} and \texttt{no-config} option must be used in
84 the first loading and are ignored later.
85
86 \subsection{Font encodings}
87
88 The package switches the \textsc{nfss} font encoding to \texttt{TU}.
89 \texttt{TU} is a new Unicode font encoding, intended for both \XeTeX\ and \LuaTeX\ engines, and automatically contains support for symbols covered by \LaTeX's traditional \texttt{T1} and \texttt{TS1} font encodings (for example, |\%|, |\textbullet|, |\"u|, and so on).
90 Some additional features are provided by \pkg{fontspec} to customise some encoding details; see Part~\vref{part:enc} for further details.
91
92 \DescribeOption{euenc}
93 \DescribeOption{tuenc}
94 Pre-2017 behaviour is now obsolete. The \texttt{euenc} and \texttt{tuenc} package options are
95 ignored. Package authors and users who have referred explicitly to the encoding names \texttt{EU1} or \texttt{EU2} should update their code or documents.
96 (See internal variable names described in \vref{sec:api} for how to do this properly.)
97
98
99 \subsection{Maths fonts adjustments}
100 By default, \pkg{fontspec} adjusts \LaTeX's default maths setup in order to maintain the correct Computer Modern symbols when the roman font changes.
101 However, it will attempt to avoid doing this if another maths font package is loaded (such as \pkg{mathpazo} or the \pkg{unicode-math} package).
102
103 If you find that \pkg{fontspec} is incorrectly changing the maths font when it shouldn't be, apply the \DescribeOption{no-math} |no-math| package option to manually suppress its behaviour here.
104
105
106 \subsection{Configuration}
107 \label{sec:config}
108
109 If you wish to customise any part of the
110 \pkg{fontspec} interface, this should be done by creating your own
111 \texttt{fontspec.cfg} file,
112 which will be automatically loaded if it is found by \XeTeX\ or \LuaTeX.
113 A |fontspec.cfg| file is distributed with \pkg{fontspec} with a small number of defaults set up within it.
114
115 To customise \pkg{fontspec} to your liking, use the standard |.cfg| file as a starting point or write your own from scratch, then either place it in the same folder as the main document for isolated cases, or in a location
116 that \XeTeX\ or \LuaTeX\ searches by default; \eg\ in Mac\TeX: \path{~/Library/texmf/tex/latex/}.
117
118 \DescribeOption{no-config}
119 The package option |no-config| will suppress the loading of the |fontspec.cfg| file under all circumstances. Both options must be used the first time \pkg{fontspec} is loaded and are ignored in later calls.
120
121
122 \subsection{Warnings}
123 \label{sec:quiet-warnings}
124
125 This package can give some warnings that can be harmless if you know what
126 you're doing. Use the \DescribeOption{quiet} |quiet| package option to write these warnings to the
127 transcript (\texttt{.log}) file instead.
128
129 \DescribeOption{silent}
130 Use the |silent| package option to completely suppress these warnings if you
131 don't even want the |.log| file cluttered up.
132
133 Both options can also be used with \cs{Setkeys} in the document. Use the \DescribeOption{verbose} |verbose| option to get activate the warnings again.
134
135 \section{Interaction with \LaTeXe\ and other packages}
136
137 This section documents some areas of adjustment that \pkg{fontspec} makes
138 to improve default behaviour with \LaTeXe\ and third-party packages.
139
140
141
142 \subsection{Commands for old-style and lining numbers}
143
144 \DescribeMacro{\oldstylenums}
145 \DescribeMacro{\liningnums}
146 \LaTeX's definition of \cs{oldstylenums} relies on strange font encodings.
147 We provide a \pkg{fontspec}-compatible alternative and while we're at it
148 also throw in the reverse option as well. Use \cs{oldstylenums}\marg{text}
149 to explicitly use old-style (or lowercase) numbers in \meta{text}, and
150 the reverse for \cs{liningnums}\marg{text}.
151
152
153 \subsection{Italic small caps}
154
155 Support now provided by \LaTeXe\ in 2020.
156
157
158 \subsection{Emphasis and nested emphasis}
159
160 Support now provided by \LaTeXe\ in 2020.
161
162
163 \subsection{Strong emphasis}
164
165 \DescribeMacro{\strong}
166 \DescribeMacro{\strongenv}
167 The \cs{strong} macro is used analogously to \cs{emph} but produces variations in weight.
168 If you need it in environment form, use |\begin{strongenv}...\end{strongenv}|.
169
170 As with emphasis, this font-switching command is intended to move through a range
171 of font weights. For example, if the fonts are set up correctly it allows usage such as
172 |\strong{...\strong{...}}| in which each nested \cs{strong} macro increases the
173 weight of the font.
174
175 \DescribeMacro{\strongfontdeclare}
176 Currently this feature set is somewhat experimental and there is no syntactic sugar
177 to easily define a range of font weights using \pkg{fontspec} commands.
178 Use, say, the following to define first bold and then black (|k|) font faces for \cs{strong}:
179 \begin{Verbatim}
180 \strongfontdeclare{\bfseries,\fontseries{k}\selectfont}
181 \end{Verbatim}
182
183 \DescribeMacro{\strongreset}
184 If too many levels of \cs{strong} are reached, \cs{strongreset} is inserted.
185 By default this is a no-op and the font will simply remain the same.
186 Use \cs{renewcommand}\cs{strongreset}|{\mdseries}| to start again from the beginning if desired.
187
188 An example for setting up a font family for use with \cs{strong} is discussed in \vref{sec:strong-example}.
189
190 \end{document}
191
192 % /©
193 % ------------------------------------------------
194 % The FONTSPEC package <latex3.github.io/fontspec>
195 % ------------------------------------------------
196 % Copyright 2022-2025 The LaTeX project, LPPL "maintainer"
197 % Copyright 2004-2022 Will Robertson
198 % Copyright 2009-2015 Khaled Hosny
199 % Copyright 2013 Philipp Gesang
200 % Copyright 2013-2016 Joseph Wright
201 % ------------------------------------------------
202 % This package is free software and may be redistributed and/or modified under
203 % the conditions of the LaTeX Project Public License, version 1.3c or higher
204 % (your choice): <http://www.latex-project.org/lppl/>.
205 % ------------------------------------------------
206 % ©/