% \iffalse
%<*internal>
\begingroup
\input l3docstrip.tex\relax
\keepsilent
\usedir{tex/latex/fontspec}
\let\MetaPrefix\relax
\preamble
------------------------------------------------
The FONTSPEC package for XeLaTeX/LuaLaTeX
(C)  2004--2016  Will Robertson and Khaled Hosny
License information appended.
------------------------------------------------
\endpreamble
\postamble
------------------------------------------------
Copyright 2004--2016 Will Robertson <wspr81@gmail.com>
Copyright 2009--2013   Khaled Hosny <khaledhosny@eglug.org>

Distributable under the LaTeX Project Public License, version 1.3c or higher.
The latest version of this license is at: http://www.latex-project.org/lppl.txt

This work is "maintained" by Will Robertson.
It consists of the files: fontspec*.dtx, fontspec.cfg, fontspec-example.tex.
And the derived files: fontspec*.sty,fontspec.lua, and fontspec.pdf.
------------------------------------------------
\endpostamble
\askforoverwritefalse
\def\MetaPrefix{-- }
\generate{\file{fontspec.lua}{\from{fontspec-lua.dtx}{lua}}}
\let\MetaPrefix\DoubleperCent
\ifx\FontspecDebug\undefined\def\FSDEBUG{}\else\def\FSDEBUG{,debug}\fi

\generate{\file{fontspec.sty}{
  \from{fontspec.dtx}{fontspec,load\FSDEBUG}
}}
\generate{\file{fontspec-xetex.sty}{
  \from{fontspec.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-vars.dtx}{vars\FSDEBUG}
  \from{fontspec-msg.dtx}{msg\FSDEBUG}
  \from{fontspec-opening.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-fontload.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-user.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-api.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-internal.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-keyval.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-math.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-closing.dtx}{fontspec,xetexx\FSDEBUG}
  \from{fontspec-patches.dtx}{patches\FSDEBUG}
}}
\generate{\file{fontspec-luatex.sty}{
  \from{fontspec.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-vars.dtx}{vars\FSDEBUG}
  \from{fontspec-msg.dtx}{msg\FSDEBUG}
  \from{fontspec-opening.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-fontload.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-user.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-api.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-internal.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-keyval.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-math.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-closing.dtx}{fontspec,luatex\FSDEBUG}
  \from{fontspec-patches.dtx}{patches\FSDEBUG}
}}

\def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup
%</internal>
%<*fontspec>
\RequirePackage{expl3}
\RequirePackage{xparse}
%</fontspec>
%<*driver>
\ProvidesExplFile{fontspec.dtx}
%</driver>
%<fontspec&!xetexx&!luatex>\ProvidesExplPackage{fontspec}%
%<fontspec&xetexx>\ProvidesExplPackage{fontspec-xetex}%
%<fontspec&luatex>\ProvidesExplPackage{fontspec-luatex}%
%<*fontspec>
  {2016/02/01}{2.5a}{Font selection for XeLaTeX and LuaLaTeX}
%</fontspec>
%
%<*driver>
\ExplSyntaxOff
\providecommand\ENDDOCUMENT{}
\input{fontspec-doc.tex}
\StopEventually{}
\part{Implementation}
\DocInput{fontspec.dtx}
\DocInput{fontspec-vars.dtx}
\DocInput{fontspec-opening.dtx}
\DocInput{fontspec-fontload.dtx}
\DocInput{fontspec-user.dtx}
\DocInput{fontspec-api.dtx}
\DocInput{fontspec-internal.dtx}
\DocInput{fontspec-keyval.dtx}
\DocInput{fontspec-math.dtx}
\DocInput{fontspec-closing.dtx}
\DocInput{fontspec-lua.dtx}
\DocInput{fontspec-patches.dtx}
\DocInput{fontspec-msg.dtx}
\end{document}
%</driver>
% \fi
%
% \section{Loading}
%
% The \textsf{expl3} module is \texttt{fontspec}.
%    \begin{macrocode}
%<@@=fontspec>
%    \end{macrocode}
%
% Check engine and load specific modules.
% For Lua\TeX, load \pkg{luaotfload}.
%    \begin{macrocode}
%<*load>
\sys_if_engine_luatex:T
  { \RequirePackage{luaotfload}
    \directlua{require("fontspec")}
    \RequirePackageWithOptions{fontspec-luatex} \endinput }
\sys_if_engine_xetex:T
  { \RequirePackageWithOptions{fontspec-xetex}  \endinput }
%    \end{macrocode}
% If not one of the above, error:
%    \begin{macrocode}
\msg_new:nnn {fontspec} {cannot-use-pdftex}
 {
  The~ fontspec~ package~ requires~ either~ XeTeX~ or~ LuaTeX.\\\\
  You~ must~ change~ your~ typesetting~ engine~ to,~ e.g.,~ "xelatex"~ or~ "lualatex" instead~ of~ plain~ "latex"~ or~ "pdflatex".
 }
\msg_fatal:nn {fontspec} {cannot-use-pdftex}
\endinput
%</load>
%    \end{macrocode}
% \clearpage
% \PrintChanges
% \clearpage
% \setcounter{IndexColumns}{2}
% \PrintIndex
% \Finale
\endinput
