%%
%% 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/09/29 v2.1b Advanced font selection for XeLaTeX/LuaLaTeX]


\ExplSyntaxOn
\RequirePackage{fixltx2e}[2006/03/24]
\DeclareRobustCommand \em {
  \@nomath\em
  \str_if_eq:xxTF \f@shape \itdefault \eminnershape
  {
    \str_if_eq:xxTF \f@shape \sldefault \eminnershape \emshape
  }
}
\DeclareTextFontCommand{\emph}{\em}
\cs_set_eq:NN \emshape \itshape
\cs_set_eq:NN \eminnershape \upshape
\DeclareRobustCommand{\-}{%
  \discretionary{%
    \char\ifnum\hyphenchar\font<\z@
           \xlx@defaulthyphenchar
         \else
           \hyphenchar\font
         \fi}{}{}}
\def\xlx@defaulthyphenchar{`\-}
\cs_new:Npn \fontspec_visible_space: {
  \font_glyph_if_exist:NnTF \font {"2423}
    {\char"2423\relax}
    {\fontspec_visible_space_fallback:}
}
\cs_new:Npn \fontspec_visible_space_fallback: {
  {
    \usefont{\zf@enc}{lmtt}{\f@series}{\f@shape}
    \textvisiblespace
  }
}
\group_begin:
\char_make_active:n{"20}%
\cs_gset:Npn\fontspec_print_visible_spaces:{%
\char_make_active:n{"20}%
\cs_set_eq:NN^^20\fontspec_visible_space:%
}%
\group_end:
\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{\fontspec_print_visible_spaces:\@sverb}
\AtBeginDocument{
  \fontspec_patch_verbatim:
  \fontspec_patch_moreverb:
  \fontspec_patch_fancyvrb:
  \fontspec_patch_listings:
}
\cs_set:Npn \fontspec_patch_verbatim: {
  \@ifpackageloaded{verbatim}{
    \cs_set:cpn {verbatim*} {
      \group_begin: \@verbatim \fontspec_print_visible_spaces: \verbatim@start
    }
  }{
    \cs_set:cpn {verbatim*} {
      \@verbatim \fontspec_print_visible_spaces: \@sxverbatim
    }
  }
}
\cs_set:Npn \fontspec_patch_moreverb: {
  \@ifpackageloaded{moreverb}{
    \cs_set:cpn {listingcont*} {
      \cs_set:Npn \verbatim@processline {
        \thelisting@line \global\advance\listing@line\c_one
        \the\verbatim@line\par
      }
      \@verbatim \fontspec_print_visible_spaces: \verbatim@start
    }
  }{}
}
\cs_set:Npn \fontspec_patch_fancyvrb: {
  \@ifpackageloaded{fancyvrb}{
    \cs_set_eq:NN \FancyVerbSpace \fontspec_visible_space:
  }{}
}
\cs_set:Npn \fontspec_patch_listings: {
  \@ifpackageloaded{listings}{
    \cs_set_eq:NN \lst@visiblespace \fontspec_visible_space:
  }{}
}
%% 
%% 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'.
