%D \module
%D   [      file=s-fonts-features, % was s-fnt-41, s-fnt-27
%D        version=2012.11.27, % 2010.02.22
%D          title=\CONTEXT\ Style File,
%D       subtitle=Features,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\startmodule[fonts-features]

\registerctxluafile{s-fonts-features}{}

\installmodulecommandluasingle \showusedfeatures  {moduledata.fonts.features.showused}
\installmodulecommandluasingle \showallkerns      {moduledata.fonts.features.showallkerns}
\installmodulecommandluasingle \showbasekerns     {moduledata.fonts.features.showbasekerns}
\installmodulecommandluasingle \showallligatures  {moduledata.fonts.features.showallligatures}
\installmodulecommandluasingle \showfeatureset    {moduledata.fonts.features.showfeatureset}
\installmodulecommandluasingle \showallfeatures   {moduledata.fonts.features.showallfeatures}
\installmodulecommandluasingle \showsubstitutions {moduledata.fonts.features.showsubstitutions}

\unexpanded\def\showfontidchar#1#2{\glyph id #1 #2\relax}

\def\kernpairheight{.8\strutht}
\def\kernpairdepth {.8\strutdp}
\def\kernpairwidth {\onepoint}

\unexpanded\def\showkernpair#1#2#3% first kern second
  {\dontleavehmode
   \hbox \bgroup
   \scratchdimen#2\scaledpoint
   \kern\fontcharwd\font#1\relax
   \ifdim\scratchdimen>\zeropoint
     \bgroup
       \darkgreen
       \vrule width \scratchdimen height \kernpairheight depth \kernpairdepth
     \egroup
     \kern-\scratchdimen
   \else\ifdim\scratchdimen<\zeropoint
     \kern\scratchdimen
     \bgroup
       \darkred
       \vrule width -\scratchdimen height \kernpairheight depth \kernpairdepth
     \egroup
   \else
     \kern-.5\dimexpr\kernpairwidth\relax
     \bgroup
       \darkblue
       \vrule width \kernpairwidth height \kernpairheight depth \kernpairdepth
     \egroup
     \kern-.5\dimexpr\kernpairwidth\relax
   \fi\fi
   \kern-\fontcharwd\font#1\relax
   \char#1\relax
   \char#3\relax
   \egroup
   \space}

\stopmodule

\continueifinputfile{s-fonts-features.mkiv}

\usemodule
  [art-01]

\starttext

%     \showusedfeatures \page

%     \definefontfeature[default-base][default][mode=base]

%     \start
%         \definedfont[Serif*default-base]
%         \showbasekerns
%         \page
%     \stop

%     \start
%         \bf
%         \showallkerns
%         \page
%     \stop

    \showsubstitutions
      [name=xcharter-math.otf,
       feature=*,
       script=math,
       language=dflt]

\stoptext
