summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fontspec/fontspec-patches.sty
blob: 82479c61ab3d8ac83e9cb0468459aad2dd2a2943 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%%
%% 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--2014    Will Robertson and Khaled Hosny
%% 
%%   License information appended.
%% 
%% 
\ProvidesPackage{fontspec-patches}
  [2014/06/01 v2.4 Font selection for XeLaTeX and LuaLaTeX]


\RequirePackage{fixltx2e}[2006/03/24]
\ExplSyntaxOn
\DeclareRobustCommand \em
 {
  \@nomath\em
  \str_if_eq_x:nnTF \f@shape \itdefault \eminnershape
  {
    \str_if_eq_x:nnTF \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:Nn \fontspec_visible_space:
 {
  \font_glyph_if_exist:NnTF \font {"2423}
   { \char"2423\scan_stop: }
   { \fontspec_visible_space_fallback: }
 }
\cs_new:Nn \fontspec_visible_space_fallback:
 {
  {
   \usefont{\g_fontspec_encoding_tl}{lmtt}{\f@series}{\f@shape}
   \textvisiblespace
  }
 }
\group_begin:
\char_set_catcode_active:n{"20}%
\cs_gset:Npn\fontspec_print_visible_spaces:{%
\char_set_catcode_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\__fontspecsverb\@verb
 }
\def\__fontspecsverb{\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:
   }{}
 }
\RenewDocumentCommand \oldstylenums {m}
 {
  { \addfontfeature{Numbers=OldStyle} #1 }
 }
\NewDocumentCommand \liningnums {m}
 {
  { \addfontfeature{Numbers=Lining} #1 }
 }
%% 
%% Copyright 2004--2014 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 (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'.