%%
%% This is file `fontspec-patches.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fontspec.dtx  (with options: `patches')
%% 
%%   _________________________________________
%%   The fontspec package for XeLaTeX/LuaLaTeX
%%   (C) 2004--2010    Will Robertson and Khaled Hosny
%% 
%%   License information appended.
%% 
%% 
\ProvidesPackage{fontspec-patches}
  [2010/07/14 v2.0b Advanced font selection for XeLaTeX/LuaLaTeX]



\ExplSyntaxOn
\RequirePackage{fixltx2e}[2006/03/24]
\DeclareRobustCommand \em {
  \@nomath\em
  \tl_if_eq:xxTF \f@shape \itdefault \eminnershape \emshape
}
\DeclareTextFontCommand{\emph}{\em}
\let\emshape\itshape
\let\eminnershape\upshape
\DeclareRobustCommand{\-}{%
  \discretionary{%
    \char\ifnum\hyphenchar\font<\z@
           \xlx@defaulthyphenchar
         \else
           \hyphenchar\font
         \fi}{}{}}
\def\xlx@defaulthyphenchar{`\-}
\def\xxt@visiblespace{
  \iffontchar\font"2423
    \expandafter\textvisiblespace
  \else
    \expandafter\xxt@visiblespace@fallback
  \fi
}
\def\xxt@visiblespace@fallback{
  {
    \usefont{EU1}{lmtt}{\f@series}{\f@shape}
    \textvisiblespace
  }
}
\begingroup
  \catcode`\~=\active
  \gdef\xxt@vprintspaces{\catcode`\~\active\let \xxt@visiblespace}
\endgroup
\def\verb{
  \relax\ifmmode\hbox\else\leavevmode\null\fi
  \bgroup
    \verb@eol@error \let\do\@makeother \dospecials
    \verbatim@font\@noligs
    \@ifstar\@@sverb\@verb
}
\def\@@sverb{\xxt@vprintspaces\@sverb}
\AtBeginDocument{
  \fontspec_patch_verbatim:
  \fontspec_patch_moreverb:
  \fontspec_patch_fancyvrb:
  \fontspec_patch_listings:
}
\cs_set:Npn \fontspec_patch_verbatim: {
  \@ifpackageloaded{verbatim}{
    \@namedef{verbatim*}{
      \begingroup\@verbatim\xxt@vprintspaces\verbatim@start
    }
  }{
    \@namedef{verbatim*}{\@verbatim\xxt@vprintspaces\@sxverbatim}
  }
}
\cs_set:Npn \fontspec_patch_moreverb: {
  \@ifpackageloaded{moreverb}{
    \@namedef{listingcont*}{
      \def\verbatim@processline{
        \thelisting@line \global\advance\listing@line\c_one
        \the\verbatim@line\par
      }
      \@verbatim\xxt@vprintspaces\verbatim@start
    }
  }{}}
\cs_set:Npn \fontspec_patch_fancyvrb: {
  \@ifpackageloaded{fancyvrb}{
    \let\FancyVerbSpace\xxt@visiblespace
  }{}
}
\cs_set:Npn \fontspec_patch_listings: {
  \@ifpackageloaded{listings}{
    \let\lst@visiblespace\xxt@visiblespace
  }{}
}
%% 
%% Copyright 2004--2010 Will Robertson <wspr81@gmail.com>
%% Copyright 2009--2010 Khaled Hosny <khaledhosny@eglug.org>
%% 
%% 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 "author-maintained" by Will Robertson.
%% 
%% This work consists of this file fontspec.dtx
%%           and the derived files fontspec.sty,
%%                                 fontspec.lua,
%%                                 fontspec.cfg,
%%                                 fontspec-xetex.tex,
%%                                 fontspec-luatex.tex,
%%                             and fontspec.pdf.
%% 
%%
%% End of file `fontspec-patches.sty'.
