Plz, consider the following code:
\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{realscripts}
\usepackage[english]{babel}
\babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{<myfont>}
\frenchspacing
\ExplSyntaxOn
\cs_new:Nn \__realscripts_numtosup:n
{
\str_set:Nn \l_tmpa_str {#1}
\str_map_inline:Nn \l_tmpa_str
{
\str_if_in:nnTF {0123456789} {##1}
{
\int_set:Nn \l_tmpa_int {##1}
\if_case:w \l_tmpa_int ⁰
\or: ¹
\or: ²
\or: ³
\or: ⁴
\or: ⁵
\or: ⁶
\or: ⁷
\or: ⁸
\or: ⁹
\fi:
}
{ {\addfontfeature{VerticalPosition=Superior}##1} }
}
}
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript {m} {
\fontspec_if_fontspec_font:TF
{
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+sups}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
{ \fontspec_if_aat_feature:nnTF {10} {1}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
}
{ \fakesuperscript{#1} }
}
\ExplSyntaxOff
\begin{document}
\null\vfill
In text numbers: 0123456789
To be\footnote{xxx}. or not to be\footnote{xxx}: that is the question\footnote{xxx}:
Whether ‘tis nobler in the mind to suffer\footnote{xxx}
The slings and arrows of outrageous fortune\footnote{xxx},
Or to take arms against a sea of troubles\footnote{xxx},
And by opposing end them\footnote{xxx}? To die: to sleep\footnote{xxx};
No more\footnote{xxx}; and by a sleep\footnote{xxx} to say we end\footnote{xxx}
The heart-ache\footnote{xxx} and the thousand natural shocks\footnote{xxx}
That flesh is heir to, ‘tis a consummation\footnote{xxx}
Devoutly to be wish’d\footnote{xxx}. To die, to sleep\footnote{xxx};
A{\addfontfeatures{VerticalPosition=Superior}0123456789}.
A{\textsuperscript{9876543210}}.
A{\addfontfeatures{VerticalPosition=Superior}321}.
A{\textsuperscript{321}}.
\end{document}
The resulting .pdf in the following pic:
Obviously, I set a paroxysmal kerning between number 1 and period only for testing reasons. You'll note the kerning works with the last line of the code, but it's not applied to superscript notes marker. Why?
Update
I tried the following code:
\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\usepackage{realscripts}
\usepackage[english]{babel}
\babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle}]{Source Serif Pro}
\directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["one.superior"] = { ["period"] = -250 },
},
}
}
\frenchspacing
\ExplSyntaxOn
\cs_new:Nn \__realscripts_numtosup:n
{
\str_set:Nn \l_tmpa_str {#1}
\str_map_inline:Nn \l_tmpa_str
{
\str_if_in:nnTF {0123456789} {##1}
{
\int_set:Nn \l_tmpa_int {##1}
\if_case:w \l_tmpa_int ⁰
\or: ¹
\or: ²
\or: ³
\or: ⁴
\or: ⁵
\or: ⁶
\or: ⁷
\or: ⁸
\or: ⁹
\fi:
}
{ {\addfontfeature{VerticalPosition=Superior}##1} }
}
}
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript {m} {
\fontspec_if_fontspec_font:TF
{
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+sups}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
{ \fontspec_if_aat_feature:nnTF {10} {1}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
}
{ \fakesuperscript{#1} }
}
\ExplSyntaxOff
\begin{document}
\null\vfill
In text numbers: 0123456789
To be\footnote{xxx}. or not to be\footnote{xxx}: that is the question\footnote{xxx}:
Whether ‘tis nobler in the mind to suffer\footnote{xxx}
The slings and arrows of outrageous fortune\footnote{xxx},
Or to take arms against a sea of troubles\footnote{xxx},
And by opposing end them\footnote{xxx}? To die: to sleep\footnote{xxx};
No more\footnote{xxx}; and by a sleep\footnote{xxx} to say we end\footnote{xxx}
The heart-ache\footnote{xxx} and the thousand natural shocks\footnote{xxx}
That flesh is heir to, ‘tis a consummation\footnote{xxx}
Devoutly to be wish’d\footnote{xxx}. To die, to sleep\footnote{xxx};
A{\addfontfeatures{VerticalPosition=Superior}0123456789}.
A{\textsuperscript{9876543210}}.
A{\addfontfeatures{VerticalPosition=Superior}321}.
A{\textsuperscript{321}}.
A{\addfontfeature{RawFeature=+sups}1.}
A{\addfontfeature{RawFeature=+supkern;+sups}1.}
\end{document}
but \directlua doesn't produce any result and the last two line unnecessary, for period is itself superscrit. What's wrong?
Further update
Try this code:
\documentclass[a4paper,12pt]{book}
\usepackage{fontspec}
\directlua {
fonts.handlers.otf.addfeature {
name = "supkern",
type = "kern",
data = {
["¹"] = { ["."] = -180,
[","] = -180 },
},
}
}
\usepackage[english]{babel}
\babelfont[english]{rm}[Ligatures=TeX,Numbers={Proportional,OldStyle},RawFeature=+supkern,RawFeature=+calt]{Source Serif Pro}
\usepackage{realscripts}
\usepackage{perpage}
\MakePerPage{footnote}
\usepackage[bottom,hang,stable,norule]{footmisc} % perpage
\renewcommand{\footnotemargin}{0.01em}
\renewcommand{\hangfootparskip}{0pt}
\renewcommand{\footnotelayout}{\hspace{1em}}
\makeatletter
\def\@makefnmark{\unpenalty{\footnotemarkfont\textsuperscript{\@thefnmark}}}
\makeatother
\ExplSyntaxOn
\bool_new:N \l__realscripts_punct_found_bool
\tl_new:N \l__realscripts_footnote_text_tl
\cs_set_eq:NN \__realscripts_footnote:n \footnote
\cs_new_protected:Nn \__realscripts_footnote_with_punct:
{
\bool_set_false:N \l__realscripts_punct_found_bool
\str_map_inline:nn { ., }
{
\token_if_eq_meaning:NNT \l_peek_token ##1
{
\footnotemark
\l_peek_token
\footnotetext { \l__realscripts_footnote_text_tl }
\bool_set_true:N \l__realscripts_punct_found_bool
\str_map_break:
}
}
\bool_if:NTF \l__realscripts_punct_found_bool
{ \use_none:n }
{ \__realscripts_footnote:n { \l__realscripts_footnote_text_tl } }
}
\cs_new_protected:Nn \__realscripts_footnote_with_punct:n
{
\tl_set:Nn \l__realscripts_footnote_text_tl {#1}
\peek_after:Nw \__realscripts_footnote_with_punct:
}
\cs_new_protected:Nn \__realscripts_numtosup:n
{
\str_set:Nn \l_tmpa_str {#1}
\str_map_inline:Nn \l_tmpa_str
{
\str_if_in:nnTF { 0123456789 } {##1}
{
\int_set:Nn \l_tmpa_int {##1}
\if_case:w \l_tmpa_int ⁰
\or: ¹
\or: ²
\or: ³
\or: ⁴
\or: ⁵
\or: ⁶
\or: ⁷
\or: ⁸
\or: ⁹
\fi:
}
{ { \addfontfeature {VerticalPosition=Superior} ##1 } }
}
}
\cs_generate_variant:Nn \__realscripts_numtosup:n { x }
\DeclareDocumentCommand \realsuperscript { m } {
\fontspec_if_fontspec_font:TF
{
\fontspec_if_opentype:TF
{ \fontspec_if_feature:nTF {+sups}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
{ \fontspec_if_aat_feature:nnTF {10} {1}
{ \__realscripts_numtosup:x{#1} }
{ \fakesuperscript{#1} }
}
}
{ \fakesuperscript{#1} }
}
\DeclareDocumentCommand \footnote { +m }
{
\__realscripts_footnote_with_punct:n {#1}
}
\ExplSyntaxOff
\begin{document}
\chapter{Test chapter}
«text»\footnote{Footnote text}.
A\footnote{Footnote text}.
A\footnote{Footnote text},
A\footnote{Footnote text};
A\footnote{Footnote text}.
\end{document}
You'll realize that something strange happens: no footnote 1!


<myfont>. You can add special kerns with fonts.handlers.otf.addfeature, see e.g. https://tex.stackexchange.com/questions/312154/how-to-adjust-font-features-in-luatex. – Ulrike Fischer Feb 09 '19 at 23:17\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}– Henri Menke Feb 10 '19 at 02:45