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
|
%%
%% This is file `realscripts.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% realscripts.dtx (with options: `package')
%% _____________________________
%% The REALSCRIPTS package
%% (C) 2010--2016 Will Robertson
%% License information appended
%%
\ProvidesPackage{realscripts}
[2016/02/13 v0.3d Access OpenType subscripts and superscripts]
\RequirePackage{fontspec}
\ExplSyntaxOn
\DeclareDocumentCommand \fakesubscript {m} {
\@textsubscript{\selectfont#1}
}
\DeclareDocumentCommand \fakesuperscript {m} {
\@textsuperscript{\selectfont#1}
}
\RenewDocumentCommand \textsubscript {s} {
\IfBooleanTF #1 \fakesubscript \realsubscript
}
\RenewDocumentCommand \textsuperscript {s} {
\IfBooleanTF #1 \fakesuperscript \realsuperscript
}
\DeclareDocumentCommand \realsubscript {m} {
\fontspec_if_fontspec_font:TF {
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+subs}
{ {\addfontfeature{VerticalPosition=Inferior}#1} }
{ \fontspec_if_feature:nTF {+sinf}
{ {\addfontfeature{VerticalPosition=ScientificInferior}#1} }
{ \fakesubscript{#1} }
}
}
{ \fontspec_if_aat_feature:nnTF {10} {2}
{ {\addfontfeature{VerticalPosition=Inferior}#1} }
{ \fakesubscript{#1} }
}
}
{ \fakesubscript{#1} }
}
\DeclareDocumentCommand \realsuperscript {m} {
\fontspec_if_fontspec_font:TF
{
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+sups}
{ {\addfontfeature{VerticalPosition=Superior}#1} }
{ \fakesuperscript{#1} }
}
{ \fontspec_if_aat_feature:nnTF {10} {1}
{ {\addfontfeature{VerticalPosition=Superior}#1} }
{ \fakesuperscript{#1} }
}
}
{ \fakesuperscript{#1} }
}
\cs_set:Npn \@makefnmark {
\mbox{\footnotemarkfont\textsuperscript{\@thefnmark}}
}
\cs_if_exist:NTF \ftntm@font
{
\cs_new:Npn \footnotemarkfont {\ftntm@font}
}
{
\cs_new:Npn \footnotemarkfont {\normalfont}
}
\DeclareDocumentCommand \textsubsuperscript {s O{l} mm} {
\leavevmode
\group_begin:
\IfBooleanTF #1
{
\hbox_set:Nn \l_tmpa_box {\textsubscript*{#3}}
\hbox_set:Nn \l_tmpb_box {\textsuperscript*{#4}}
}
{
\hbox_set:Nn \l_tmpa_box {\textsubscript{#3}}
\hbox_set:Nn \l_tmpb_box {\textsuperscript{#4}}
}
\hbox_set:Nn \l_tmpa_box
{ \box_move_down:nn \subsupersep {\box_use:N \l_tmpa_box} }
\hbox_set:Nn \l_tmpb_box
{ \box_move_up:nn \subsupersep {\box_use:N \l_tmpb_box} }
\str_case:nnF {#2}
{
{l}{\use_i:nnn}
{c}{\use_ii:nnn}
{r}{\use_iii:nnn}
}
{
\PackageWarning{realscripts}{
Unknown~alignment~option~`#2'. \MessageBreak
One~ of~ `l',~ `c',~ `r',~ only
}
\use_i:nnn
}
{
\hbox_overlap_right:n { \box_use:N \l_tmpa_box }
\hbox_overlap_right:n { \box_use:N \l_tmpb_box }
\skip_horizontal:n {
\dim_max:nn {\box_wd:N \l_tmpa_box} {\box_wd:N \l_tmpb_box}
}
}
{
\dim_compare:nTF { \box_wd:N \l_tmpa_box > \box_wd:N \l_tmpb_box }
{
\skip_horizontal:n {
0.5\box_wd:N \l_tmpa_box-0.5\box_wd:N \l_tmpb_box
}
\box_use:N \l_tmpb_box
\skip_horizontal:n {
-0.5\box_wd:N \l_tmpa_box-0.5\box_wd:N \l_tmpb_box
}
\box_use:N \l_tmpa_box
}
{
\skip_horizontal:n {
0.5\box_wd:N \l_tmpb_box-0.5\box_wd:N \l_tmpa_box
}
\box_use:N \l_tmpa_box
\skip_horizontal:n {
-0.5\box_wd:N \l_tmpb_box-0.5\box_wd:N \l_tmpa_box
}
\box_use:N \l_tmpb_box
}
}
{
\skip_horizontal:n {
\dim_max:nn {\box_wd:N \l_tmpa_box} {\box_wd:N \l_tmpb_box}
}
\hbox_overlap_left:n { \box_use:N \l_tmpa_box }
\hbox_overlap_left:n { \box_use:N \l_tmpb_box }
}
\group_end:
}
\DeclareDocumentCommand \textsupersubscript {s O{l} mm} {
\IfBooleanTF #1
{ \textsubsuperscript * [#2] {#4} {#3} }
{ \textsubsuperscript [#2] {#4} {#3} }
}
\dim_new:N \subsupersep
%%
%% Copyright (C) 2010--2016 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.
%%
%%
%% End of file `realscripts.sty'.
|