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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
% \iffalse
%
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble
____________________________
The REALSCRIPTS package
(C) 2010 Will Robertson
License information appended
\endpreamble
\postamble
Copyright (C) 2010 by Will Robertson <will.robertson@latex-project.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 "maintained" (as per LPPL maintenance status)
by Will Robertson.
This work consists of the file realscripts.dtx
and the derived files realscripts.sty,
realscripts.ins, and
realscripts.pdf.
\endpostamble
\askforoverwritefalse
\generate{\file{realscripts.sty}{\from{realscripts.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{realscripts.ins}{\from{realscripts.dtx}{batchfile}}}
\def\tmpa{plain}
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi
\endgroup
%</internal>
%
% \begin{macrocode}
%<*driver>
\ProvidesFile{realscripts.dtx}
%</driver>
%<package>\ProvidesPackage{realscripts}
%<*package>
[2010/08/05 v0.1 Access OpenType subscripts and superscripts]
%</package>
% \end{macrocode}
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{color,graphicx,metalogo,hologo,fontspec,realscripts}
\linespread{1.05} % A bit more space between lines
\frenchspacing % Remove extra space after punctuation
\definecolor{niceblue}{rgb}{0.1,0.2,1}
\def\theCodelineNo{\textcolor{niceblue}{\sffamily\tiny\arabic{CodelineNo}}}
\newcommand*\pkg[1]{\texttt{#1}}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
%
% \fi
%
% \errorcontextlines=999
% \makeatletter
%
% \GetFileInfo{\jobname.sty}
%
% \title{The \pkg{\jobname} package}
% \author{Will Robertson}
% \date{\filedate \qquad \fileversion}
%
% \maketitle
%
% \noindent
% OpenType fonts provide the possiblity of using specially-drawn glyphs for
% subscript and superscript text. \LaTeX\ by default simply uses a smaller
% font size, which is acceptable if the font has optical sizes. Most fonts
% don't, however.
%
% If you are using the \pkg{fontspec} package\footnote{The \pkg{fontspec} package requires \XeLaTeX\ or \hologo{LuaLaTeX}.} to select OpenType fonts
% (or other sorts of fonts with the necessary font features), then loading
% this package will provide versions of the \cmd\textsuperscript\ and
% \cmd\textsubscript\ commands that take advantage of the OpenType font
% features.
%
% This package will also patch the default \LaTeX\ footnote mechanism to
% use \cs{textsuperscript} automatically.
%
% Here is an example using the `{\fontspec{Skia} Skia}' font of Mac\,OS\,X: (surrounded by `A' and `Z' for visual context)
%
% \begin{quotation}\color{niceblue}
% \fontspec{Skia}
% |\textsuperscript | A \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
% |\textsubscript | A \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890} Z
% \end{quotation}
% The original definitions are available in starred verions of the commands:
% (compare this example to that above to see why using these features is often desirable)
% \begin{quotation}\color{niceblue}
% \fontspec{Skia}
% |\textsuperscript* | A \textsuperscript*{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
% |\textsubscript* | A \textsubscript*{abcdefghijklmnopqrstuvwxyz1234567890} Z
% \end{quotation}
% When the glyphs are not available the commands will fall back on the standard technique of scaling down the text font:
% (this is Mac\,OS\,X's `{\fontspec{Didot} Didot}')
% \begin{quotation}\color{niceblue}
% \fontspec{Didot}
% |\textsuperscript | A \textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890} Z\par
% |\textsubscript | A \textsubscript{abcdefghijklmnopqrstuvwxyz1234567890} Z
% \end{quotation}
% But beware fonts that contain the necessary font features but lack the full repertoire of glyphs: (this is `{\fontspec{Adobe Jenson Pro}Adobe Jenson Pro}')
% \begin{quotation}\color{niceblue}
% \fontspec{Adobe Jenson Pro}
% |\textsuperscript | A {\textsuperscript{abcdefghijklmnopqrstuvwxyz1234567890}} Z\par
% |\textsubscript | A {\textsubscript{abcdefghijklmnopqrstuvwxyz1234567890}} Z
% \end{quotation}
%
% The functionality of the starred and non-starred commands can
% also be accessed using the macros
% \cmd\realsubscript,
% \cmd\realsuperscript,
% \cmd\fakesubscript, and
% \cmd\fakesuperscript, in case another package (or you wish to)
% redefine the original \cmd\text\dots\ commands
%
% \newpage
% \part{The \textsf{\jobname} package}
%\iffalse
%<*package>
%\fi
% This is the package implementation.
%
% \begin{macrocode}
\RequirePackage{fontspec}[2010/05/14 v2.0]
\ExplSyntaxOn
% \end{macrocode}
%
% \begin{macro}{\textsubscript}
% \begin{macro}{\textsubscript*}
% \begin{macro}{\textsuperscript}
% \begin{macro}{\textsuperscript*}
% These commands are either defined to create fake or real sub-/super-scripts if they are starred or not, respectively.
% \begin{macrocode}
\DeclareDocumentCommand \textsubscript {s} {
\IfBooleanTF #1 \fakesubscript \realsubscript
}
\DeclareDocumentCommand \textsuperscript {s} {
\IfBooleanTF #1 \fakesuperscript \realsuperscript
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fakesubscript}
% \begin{macro}{\fakesuperscript}
% The old (`fake') methods:
% \begin{macrocode}
\DeclareDocumentCommand \fakesubscript {m} {
\@textsubscript{\selectfont#1}
}
\DeclareDocumentCommand \fakesuperscript {m} {
\@textsuperscript{\selectfont#1}
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\realsubscript}
% The new subscript command to use OpenType features if possible.
% \begin{macrocode}
\DeclareDocumentCommand \realsubscript {m} {
\fontspec_if_fontspec_font:TF {
% \end{macrocode}
% For OpenType fonts, the subscript feature (|subs|) is used, but if that doesn't
% exist then the scientific inferior feature (|sinf|) is used on the assumption
% that something's better than nothing.
% \begin{macrocode}
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+subs}
{ {\addfontfeature{VerticalPosition=Inferior}#1} }
{ \fontspec_if_feature:nTF {+sinf}
{ {\addfontfeature{VerticalPosition=ScientificInferior}#1} }
{ \fakesubscript{#1} }
}
}
% \end{macrocode}
% ATSUI fonts:
% \begin{macrocode}
{ \fontspec_if_aat_feature:nnTF {10} {2}
{ {\addfontfeature{VerticalPosition=Inferior}#1} }
{ \fakesubscript{#1} }
}
}
% \end{macrocode}
% Non-fontspec fonts:
% \begin{macrocode}
{ \fakesubscript{#1} }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\realsuperscript}
% The new superscript command to use OpenType features if possible.
% \begin{macrocode}
\DeclareDocumentCommand \realsuperscript {m} {
\fontspec_if_fontspec_font:TF
{
% \end{macrocode}
% OpenType fonts:
% \begin{macrocode}
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+sups}
{ {\addfontfeature{VerticalPosition=Superior}#1} }
{ \fakesuperscript{#1} }
}
% \end{macrocode}
% ATSUI fonts:
% \begin{macrocode}
{ \fontspec_if_aat_feature:nnTF {10} {1}
{ {\addfontfeature{VerticalPosition=Superior}#1} }
{ \fakesuperscript{#1} }
}
}
% \end{macrocode}
% Non-fontspec fonts:
% \begin{macrocode}
{ \fakesuperscript{#1} }
}
% \end{macrocode}
% \end{macro}
% Patching footnotes:
% \begin{macro}{\@makefnmark}
% This is the command used to typeset the `footnote mark'.
% \begin{macrocode}
\cs_set:Npn \@makefnmark {
\mbox{\normalfont\textsuperscript{\@thefnmark}}
}
% \end{macrocode}
% \end{macro}
%
%\iffalse
%</package>
%\fi
%
% \Finale
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by XeTeX:}
% \typeout{*}
% \typeout{* \space\space\space realscripts.sty}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput
|