%
% SKT.STY
%
% Revision 2.0 1996/11/27 Charles Wikner wikner@nacdh4.nac.ac.za
% Revision 2.2 2002/01/02 Charles Wikner wikner@nac.ac.za
%
% Copyright 1996 & 2002 Charles Wikner
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
\ProvidesFile{skt.sty}[1995/10/27 skt-series sanskrit fonts]
\RequirePackage{relsize}
\RequirePackage{ifthen}
%
\DeclareOption{xitalic}{%
\def\sktx{\usefont{OT1}{cmr}{m}{it}}%
\def\sktX{\usefont{OT1}{cmr}{bx}{it}}%
}
%
\DeclareOption{iitalic}{%
\def\skti{\usefont{OT1}{cmr}{m}{it}}%
\def\sktI{\usefont{OT1}{cmr}{bx}{it}}%
}
%
\DeclareOption{titalic}{%
\def\sktt{\usefont{OT1}{cmr}{m}{it}}%
\def\sktT{\usefont{OT1}{cmr}{bx}{it}}%
}
%
\DeclareOption{uitalic}{%
\def\sktu{\usefont{OT1}{cmr}{m}{it}}%
\def\sktU{\usefont{OT1}{cmr}{bx}{it}}%
}
%
\DeclareOption{larger}{%
\def\skt{\usefont{OT1}{skt}{m}{n}\larger\sktcommon}%
\def\skts{\usefont{OT1}{skt}{m}{sl}\larger\sktcommon}%
\def\sktb{\usefont{OT1}{skt}{b}{n}\larger\sktcommon}%
\def\sktbs{\usefont{OT1}{skt}{b}{sl}\larger\sktcommon}%
\def\sktf{\usefont{OT1}{skt}{f}{n}\larger\sktcommon}%
\def\sktfs{\usefont{OT1}{skt}{f}{sl}\larger\sktcommon}%
}
\def\sktcommon{\tolerance=10000%
               \pretolerance=10000%
               \emergencystretch=.2\hsize%
               \baselineskip 1.333\baselineskip}
%
\ProcessOptions
%
% if the "xitalic" option is not exercised, then ...
\providecommand{\sktx}{\usefont{OT1}{cmr}{m}{n}}%
\providecommand{\sktX}{\usefont{OT1}{cmr}{bx}{n}}
%
% if the "iitalic" option is not exercised, then ...
\providecommand{\skti}{\usefont{OT1}{cmr}{m}{n}}%
\providecommand{\sktI}{\usefont{OT1}{cmr}{bx}{n}}
%
% if the "titalic" option is not exercised, then ...
\providecommand{\sktt}{\usefont{OT1}{cmr}{m}{n}}%
\providecommand{\sktT}{\usefont{OT1}{cmr}{bx}{n}}
%
% if the "uitalic" option is not exercised, then ...
\providecommand{\sktu}{\usefont{OT1}{cmr}{m}{n}}%
\providecommand{\sktU}{\usefont{OT1}{cmr}{bx}{n}}
%
% if the "larger" option is not exercised, then ...
\providecommand{\skt}{\usefont{OT1}{skt}{m}{n}\sktcommon}%
\providecommand{\skts}{\usefont{OT1}{skt}{m}{sl}\sktcommon}%
\providecommand{\sktb}{\usefont{OT1}{skt}{b}{n}\sktcommon}%
\providecommand{\sktbs}{\usefont{OT1}{skt}{b}{sl}\sktcommon}%
\providecommand{\sktf}{\usefont{OT1}{skt}{f}{n}\sktcommon}%
\providecommand{\sktfs}{\usefont{OT1}{skt}{f}{sl}\sktcommon}%
%
\def\@skt#1{{\skt\number #1}}
% This allows the printing of page numbers in Sanskrit
% using LaTeX command "\pagenumbering{skt}".
%
% The SKT preprocessor makes use of the following commands:
%

\protect\newcounter{SKTCNTS}
\protect\newcounter{SKTCNTX}
\protect\newcounter{SKTCNTY}
\protect\newcounter{SKTCNTZ}
\newsavebox{\SKTBOXA}
\newsavebox{\SKTBOXB}
\protect\newlength{\SKTDIMV} % vertical dimensions
\protect\newlength{\SKTDIMH} % horizontal dimensions
\protect\newlength{\SKTDIMS} % scratch dimensions
%
\newcommand{\ZB}[1]%
%     Imbedded Roman punctuation (#1) printed boldface for sktb.
{\textrm{\textbf{{#1}}}%
}
%
\newcommand{\ZN}[1]%
%     Imbedded Roman punctuation (#1) printed boldface for skt.
{\textrm{\textbf{{#1}}}%
}
%
\newcommand{\ZF}[1]%
%     Imbedded Roman punctuation (#1) printed normal weight for sktf.
{\textmd{\textrm{{#1}}}%
}
%
\newcommand{\ZX}[1]%
%     Print full height sktt capital letter string #1
{{\relsize{-1}#1}%
}
%
\newcommand{\ZY}[1]%
%     Print half height sktt capital letter string #1
{{\relsize{-3}#1}}%
%
\newcommand{\ZS}[1]%
%     Horizontal space `cursor' #1 times 1/24 of 1em.
{\setlength{\SKTDIMS}{.041667em}%
 \kern#1\SKTDIMS%
}
%
\newcommand{\ZH}[2]%
%     Horizontal space `cursor' #1 times 1/24 of 1em,
%     print #2, and return `cursor' to original position.
{\setlength{\SKTDIMS}{.041667em}%
 \protect\makebox[0pt][l]{\kern#1\SKTDIMS{{#2}}}%
}
%
\newcommand{\ZV}[2]%
%     Vertical space `cursor' #1 times 1/24 of 1ex,
%     print #2, and return `cursor' to original position.
%     Note: if font is slanted, then increase horizontal
%     space by (font slope) * (vertical space).
{\setlength{\SKTDIMS}{.041667ex}%
 \setlength{\SKTDIMH}{0ex}%
 \setlength{\SKTDIMV}{#1\SKTDIMS}%
 \ifthenelse{\lengthtest{\the\fontdimen1\the\font > 0pt}}%
    {\setlength{\SKTDIMS}{\the\fontdimen1\the\font}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \protect\setcounter{SKTCNTS}{\SKTDIMS}%
     \setlength{\SKTDIMS}{\theSKTCNTS\SKTDIMV}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \addtolength{\SKTDIMH}{\SKTDIMS}%
    }{}%
 \protect\makebox[0pt][l]{\kern\SKTDIMH\protect\raisebox{\SKTDIMV}{{#2}}}%
}
%
\newcommand{\ZW}[1]%
%     In sktt mode underline and print string #1
{\settodepth{\SKTDIMV}{#1}%                  get character depth
 \addtolength{\SKTDIMV}{.45ex}%              additional depth before underline
 \settowidth{\SKTDIMH}{#1}%                  get character width
 \protect\savebox{\SKTBOXA}{\rule{\SKTDIMH}{.15ex}}%  define underline rule
%     The next five lines of code determine how much to offset the line
%     horizontally so as to line up with the slope of the characters,
%     for example when they are italic, the line should shift left slightly.
%     The fontdimen1 specificies the amount of horizontal shift per 1pt
%     height of the character; this dimension is then loaded into an
%     integer counter! The result is a dimensionless slope, which needs
%     to be divided by 65536 (2^16) to convert it to a fraction. This
%     division is done in two stages to prevent overflows.
%     The depth of the rule below the baseline is multiplied by this
%     ratio to determine the horizontal shift needed for the underline.
 \setlength{\SKTDIMS}{\the\fontdimen1\the\font}%
 \setlength{\SKTDIMS}{.0039062\SKTDIMS}%         divide by 256
 \protect\setcounter{SKTCNTS}{\SKTDIMS}%                see TeX book bottom page 118
 \setlength{\SKTDIMH}{\theSKTCNTS\SKTDIMV}%
 \setlength{\SKTDIMH}{.0039062\SKTDIMH}%         divide by 256
%     Now print the rule with its horizontal and vertical offsets, as a
%     zero-width box, i.e. return 'cursor' to point before printing.
 \protect\makebox[0pt][l]{\kern-\SKTDIMH\protect\raisebox{-\SKTDIMV}{\usebox{\SKTBOXA}}}%
 {#1}%    and finally print the basic character(s).
} 
%
\newcommand{\ZZ}[1]%
%     Print character #1 with '..' diacritic beneath it
%     See \ZW command above for detail; the principle is the same.
{\settodepth{\SKTDIMV}{#1}%
 \addtolength{\SKTDIMV}{.5ex}%
 \protect\savebox{\SKTBOXA}{{\kern.02em.\kern-.07em.}}% define diacritic
%     Diacritic horizontal displacement = ( width(char) - width(accent) ) / 2.
 \settowidth{\SKTDIMH}{#1}%
 \settowidth{\SKTDIMS}{\usebox{\SKTBOXA}}%
 \addtolength{\SKTDIMH}{-\SKTDIMS}%
 \setlength{\SKTDIMH}{.5\SKTDIMH}%
%     Determine extra horizontal displacement according to font slope.
 \setlength{\SKTDIMS}{\the\fontdimen1\the\font}%
 \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
 \protect\setcounter{SKTCNTS}{\SKTDIMS}%
 \setlength{\SKTDIMS}{\theSKTCNTS\SKTDIMV}%
 \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
 \addtolength{\SKTDIMH}{-\SKTDIMS}%     combine the two horizontal displacements
%     Now print the diacritic with its horizontal and vertical offsets,
%     as a zero-width box, i.e. return 'cursor' to point before printing.
 \protect\makebox[0pt][l]{\kern\SKTDIMH{\protect\raisebox{-\SKTDIMV}{\usebox{\SKTBOXA}}}}%
 {#1}%    and finally print the basic character(s)
}

\newcommand{\ZA}[2]%
%     Print character #2 with additional diacritics 
%     Range of diacritic code #1 is 0--89, where 0--29 is the accent code
%     and 30 is added to this if the vowel is nasalised (\~) as well; and
%     a further 30 is added to replace the tilde (\~) by breve(\u). Thus
%     0--29 produces the accent only; 30--59 produces a tilde with accent
%     accent above; and 60--89 produces breve with accent above.
%     The accent codes are: 
%     1 Rigveda svarita (!),                2 Rigveda anudaatta (_),
%     3 Rigveda kampa-3 (__3!),             4 Rigveda kampa-1 (_1!),  
%     5 General udaatta (^u),               6 Taittiriiya diirgha svarita (!!),
%     7 Western svarita (\`),               8 Western udaatta (\'), 
%     9 Saamaveda udaatta (^1),            10 Saamaveda svarita (^2), 
%    11 Saamaveda anudaatta (^3),          12 Saamaveda (^2r), 
%    13 Saamaveda (^2u),                   14 Saamaveda (^3k), 
%    15 Saamaveda (1_),                    16 Rig(?)veda (_3!),
%    17 Maitraaya.nii Jaatya Svarita (u),  18 Yajurveda Jaatya Svarita (w),
%    19 Yajurveda Jaatya Svarita (|___),   20 Maitrayaniya Svarita (.),
%    21 Sentence end udaatta (..),         22 Kaa.thaka Anudaatta (!),
%    23 Atharvaveda Jaatya Svarita (s),    24 Kaa.thaka Jaatya (^),
%    25 Maitraaya.nii dependent svarita (!!!).
%     
%     See \ZW command above for detail; the principle is the similar.
{%
 \settoheight{\SKTDIMV}{#2}%
 \protect\setcounter{SKTCNTY}{#1}%
 \protect\savebox{\SKTBOXA}{#2}%
 \setlength{\SKTDIMS}{\the\fontdimen1\the\font}%
 \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
 \protect\setcounter{SKTCNTX}{\SKTDIMS}%                  this value will be used in
% horizontally positioning accents for italic fonts; if non-zero, it also 
% changes the sans serif font used for some accents, to slanted sans serif.
 \ifthenelse{\value{SKTCNTY}>29}%                 add nasal or breve accent
    {\ifthenelse{\value{SKTCNTY}>59}%
        {\protect\savebox{\SKTBOXB}{\u{}}\addtocounter{SKTCNTY}{-60}}%
        {\protect\savebox{\SKTBOXB}{\~{}}\addtocounter{SKTCNTY}{-30}}%
     \addtolength{\SKTDIMV}{-1ex}%
% the next eight lines of code are repeated three more times in this command
     \settowidth{\SKTDIMH}{\usebox\SKTBOXA}%
     \settowidth{\SKTDIMS}{\usebox\SKTBOXB}%
     \addtolength{\SKTDIMH}{-\SKTDIMS}%
     \setlength{\SKTDIMH}{.5\SKTDIMH}%
     \setlength{\SKTDIMS}{\theSKTCNTX\SKTDIMV}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \addtolength{\SKTDIMH}{\SKTDIMS}%
     \protect\makebox[0pt][l]{\kern\SKTDIMH{\protect\raisebox{\SKTDIMV}{\usebox{\SKTBOXB}}}}%
     \protect\setcounter{SKTCNTZ}{#1}%
     \ifthenelse{\value{SKTCNTZ}>59}
        {\addtolength{\SKTDIMV}{1.6ex}}% raise accents above breve a little more
        {\addtolength{\SKTDIMV}{1.5ex}}%
    }{}%
 \addtolength{\SKTDIMV}{.2ex}%
 \ifthenelse{\value{SKTCNTY}>8 \and \value{SKTCNTY}<15}% raise SV accents only
    {\ifthenelse{\lengthtest{\SKTDIMV<1.7ex}}%
        {\setlength{\SKTDIMV}{1.7ex}}%
        {}}%
    {}%
 \protect\savebox{\SKTBOXB}{{}}%  default empty accent box
% Now for the accents themselves:
 \ifthenelse{\value{SKTCNTY}=1}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\textsf{\i}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\slshape\textsf{\i}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=2}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.4ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \protect\savebox{\SKTBOXB}{\rule{.3em}{.1ex}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=3}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.4ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \protect\savebox{\SKTBOXB}{\rule{.3em}{.1ex}}}%
    {}%
% accent code 4 will use the empty accent box
 \ifthenelse{\value{SKTCNTY}=5}%
    {\protect\savebox{\SKTBOXB}{\protect\raisebox{.1ex}{\relsize{-3}u}}}%
    {}%
% \ifthenelse{\value{SKTCNTY}=6}{\protect\savebox{\SKTBOXB}%
%            {\rule[.1ex]{.05em}{.6ex}\kern.1em\rule[.1ex]{.05em}{.6ex}}}{}%
 \ifthenelse{\value{SKTCNTY}=6}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\textsf{\i\i}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\slshape\textsf{\i\i}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=7}%
    {\protect\savebox{\SKTBOXB}{\`{}}\addtolength{\SKTDIMV}{-1.2ex}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=8}%
    {\protect\savebox{\SKTBOXB}{\'{}}\addtolength{\SKTDIMV}{-1.2ex}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=9}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{1}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{1}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=10}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{2}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{2}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=11}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{3}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{3}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=12}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{2r}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{2r}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=13}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{2u}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{2u}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=14}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\textsf{3k}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-4}\mdseries\slshape\textsf{3k}}}}}%
    {}%
% accent codes 15 and 16 will use the empty accent box
 \ifthenelse{\value{SKTCNTY}=17}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.8ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}[0ex][.4ex]{\mdseries\textsf{\u{}}}}}}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}[0ex][.4ex]{\mdseries\slshape\textsf{\u{}}}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=18}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.3ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-3}\mdseries\textsf%
                             {\u{}\kern-.26em\u{}}}}}}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-3}\mdseries\slshape\textsf%
                             {\u{}\kern-.26em\u{}}}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=19}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.5ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \protect\savebox{\SKTBOXB}{\kern0.05em\rule{.05em}{.3ex}\kern-.05em\rule{.3em}{.10ex}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=20}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.7ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-2}\mdseries\textsf{\symbol{"17}}}}}}%
      {\protect\savebox{\SKTBOXB}{{\kern-.02em\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-2}\mdseries\slshape\textsf{\symbol{"17}}}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=21}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.7ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\kern0.035em\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-2}\mdseries\textsf%
                             {\symbol{"17}\kern-.42em\symbol{"17}}}}}}%
        {\protect\savebox{\SKTBOXB}{{\kern0.035em\protect\raisebox{-1ex}[0ex][.4ex]{\relsize{-2}\mdseries\slshape\textsf%
                             {\symbol{"17}\kern-.42em\symbol{"17}}}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=22}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{0.9ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\textsf\i}}}%
        {\protect\savebox{\SKTBOXB}{{\kern.02em\relsize{-3}\mdseries\slshape\textsf\i}}}}%
    {}%
% accent code 23 will use the empty accent box
 \ifthenelse{\value{SKTCNTY}=24}%
    {\settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.8ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\protect\raisebox{-1ex}{\mdseries\textsf{\^{}}}}}}%
        {\protect\savebox{\SKTBOXB}{{\kern-.02em\protect\raisebox{-1ex}[0ex][.4ex]{\mdseries\slshape\textsf{\^{}}}}}}}%
    {}%
 \ifthenelse{\value{SKTCNTY}=25}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\textsf{\i\i\i}}}}%
        {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\slshape\textsf{\i\i\i}}}}}%
    {}%
% this space reserved for more accent codes
 \settowidth{\SKTDIMH}{\usebox\SKTBOXA}%        calculate hor. and vert. offsets
 \settowidth{\SKTDIMS}{\usebox\SKTBOXB}%
 \addtolength{\SKTDIMH}{-\SKTDIMS}%
 \setlength{\SKTDIMH}{.5\SKTDIMH}%
 \setlength{\SKTDIMS}{\theSKTCNTX\SKTDIMV}%
 \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
 \addtolength{\SKTDIMH}{\SKTDIMS}%                     and then print the accent
 \protect\makebox[0pt][l]{\kern\SKTDIMH{\protect\raisebox{\SKTDIMV}{\usebox{\SKTBOXB}}}}%
 \usebox{\SKTBOXA}%      print the basic character now so that font is restored 
% Now for those accents that add a following numeral:
 \ifthenelse{\value{SKTCNTY}=3  \or \value{SKTCNTY}=4%
         \or \value{SKTCNTY}=15 \or \value{SKTCNTY}=16}%
    {\ifthenelse{\value{SKTCNTY}=3 \or \value{SKTCNTY}=16}%
        {\protect\savebox{\SKTBOXA}{{\relsize{-2}3}}}%                  save the numeral
        {\protect\savebox{\SKTBOXA}{{\relsize{-2}1}}}%
     \protect\savebox{\SKTBOXB}{\rule{.3em}{.1ex}}%    calculate hor. line below numeral
     \settodepth{\SKTDIMV}{\usebox\SKTBOXA}%
     \addtolength{\SKTDIMV}{.4ex}%
     \setlength{\SKTDIMV}{-\SKTDIMV}%
     \settowidth{\SKTDIMH}{\usebox\SKTBOXA}%
     \settowidth{\SKTDIMS}{\usebox\SKTBOXB}%
     \addtolength{\SKTDIMH}{-\SKTDIMS}%
     \setlength{\SKTDIMH}{.5\SKTDIMH}%
     \setlength{\SKTDIMS}{\theSKTCNTX\SKTDIMV}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \addtolength{\SKTDIMH}{\SKTDIMS}%                  and then print under-bar
     \protect\makebox[0pt][l]{\kern\SKTDIMH{\protect\raisebox{\SKTDIMV}{\usebox{\SKTBOXB}}}}%
% If the accent numeral is to have a vertical line above it, then calculate it:
     \ifthenelse{\value{SKTCNTY}=3 \or \value{SKTCNTY}=4 \or \value{SKTCNTY}=16}%
        {\ifthenelse{\value{SKTCNTX}=0}%
            {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\textsf{\i}}}}%
            {\protect\savebox{\SKTBOXB}{{\relsize{-3}\mdseries\slshape\textsf{\i}}}}%
         \settoheight{\SKTDIMV}{\usebox\SKTBOXA}%
         \addtolength{\SKTDIMV}{.3ex}%
         \settowidth{\SKTDIMH}{\usebox\SKTBOXA}%
         \settowidth{\SKTDIMS}{\usebox\SKTBOXB}%
         \addtolength{\SKTDIMH}{-\SKTDIMS}%
         \setlength{\SKTDIMH}{.5\SKTDIMH}%
         \setlength{\SKTDIMS}{\theSKTCNTX\SKTDIMV}%
         \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
         \addtolength{\SKTDIMH}{\SKTDIMS}%          and then print the over-line
         \protect\makebox[0pt][l]{\kern\SKTDIMH{\protect\raisebox{\SKTDIMV}{\usebox{\SKTBOXB}}}}}
        {}%
     \usebox{\SKTBOXA}}%                     and print the accent numeral itself
    {}%
% Now for the <s> accent
 \ifthenelse{\value{SKTCNTY}=23}%
    {\ifthenelse{\value{SKTCNTX}=0}%
        {\protect\savebox{\SKTBOXB}{{\kern.075em{\relsize{-3}\mdseries\textsf%
                 {\protect\raisebox{.35ex}{\j}\kern-.365em\protect\raisebox{.15ex}{\'{}}}}}}}%
        {\protect\savebox{\SKTBOXB}{{\kern.075em{\relsize{-3}\mdseries\slshape\textsf%
                 {\protect\raisebox{.30ex}{\j}\kern-.385em\protect\raisebox{.10ex}{\'{}}}}}}}%
     \usebox{\SKTBOXB}}%                                print the accent itself
    {}%
% Finally, add strut to ensure at least .2ex separation from previous text line.
 \settoheight{\SKTDIMS}{\usebox{\SKTBOXB}}%
 \addtolength{\SKTDIMV}{\SKTDIMS}%
 \addtolength{\SKTDIMV}{.2ex}%
 \rule{0pt}{\SKTDIMV}% 
}
%
%---------------------------------------------------------------------------
%

%
% Print string at relative position x,y: \ZP{x}{y}{string}
%
\newcommand{\ZP}[3]%
%     Horizontal space `cursor' #1 times 1/24 of 1em,
%     vertical space `cursor' #2 times 1/24 of 1em,
%     print #3, and return `cursor' to original position.
%     Note: if font is slanted, then increase horizontal
%     space by (font slope) * (vertical space).
{\setlength{\SKTDIMS}{.041667em}%
%\typeout{ZP:x=#1,y=#2,z=#3 }%
 \setlength{\SKTDIMH}{#1\SKTDIMS}%
 \setlength{\SKTDIMS}{.041667ex}%
 \setlength{\SKTDIMV}{#2\SKTDIMS}%
 \ifthenelse{\lengthtest{\the\fontdimen1\the\font > 0pt}}%
    {\setlength{\SKTDIMS}{\the\fontdimen1\the\font}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \protect\setcounter{SKTCNTS}{\SKTDIMS}%
     \setlength{\SKTDIMS}{\theSKTCNTS\SKTDIMV}%
     \setlength{\SKTDIMS}{.0039062\SKTDIMS}%
     \addtolength{\SKTDIMH}{\SKTDIMS}%
    }{}%
 \protect\makebox[0pt][l]{\kern\SKTDIMH\protect\raisebox{\SKTDIMV}{{#3}}}%
}

%
% Print \ZL{xxx} string of encoded mini-chars:
%
\newcommand{\ZL}[1]{\ZT #1{}{}{}\endZT}

%
% Decode mini-char value and print it, then loop: only used by \ZL.
%
\def\ZT #1#2#3\endZT{\ZC{#1}\symbol{\value{SKTCNTS}}%
                      \loop%
                      \ifnum\catcode`#2 > 10%
                      \ZT #2#3{}\endZT%
                      \repeat%
}

%
% Decode a mini-char value in \ZL or \ZM commands.
%
\newcommand{\ZC}[1]{%
  \protect\setcounter{SKTCNTS}{`#1}%           set value = ASCII code + 128
  \addtocounter{SKTCNTS}{128}%
  \ifthenelse{\catcode`#1 = 12}%        check for category codes 11 or 12
             {}%
             {\ifthenelse{\catcode`#1 = 11}%
                         {}%
                         {\errmessage{SKT macro ZC: invalid parameter "#1"}%
                          \protect\setcounter{SKTCNTS}{0}%  set error value to zero.
                         }%
             }%$
}

%
% Print encoded mini-char position string \ZM{xycxyc...}
%
\newcommand{\ZM}[1]{\protect\ZR #1!}

%
% Extract X-position, Y-position, decode mini-char, print it, and loop:
% only used by ZQ command.
%
\def\ZR #1#2#3#4!{%
                         \ZD{#1}\protect\setcounter{SKTCNTX}{\value{SKTCNTS}}%
                         \ZD{#2}\protect\setcounter{SKTCNTY}{\value{SKTCNTS}}%
                         \ZC{#3}\protect\setcounter{SKTCNTZ}{\value{SKTCNTS}}%
                         \ZP{\theSKTCNTX}{\theSKTCNTY}{\symbol{\theSKTCNTZ}}%
                         \ifthenelse{\equal{#4}{}}{}{\ZR #4!}%
}

%
% Decode a position value: only used by \ZM command.
%
\newcommand{\ZD}[1]{%
  \protect\setcounter{SKTCNTS}{0}%      set default value = 0
  \ifthenelse{\equal{#1}{0}}%    if char. not "0", then ...
             {}%
             {\ifthenelse{\catcode`#1 = 11}%             if A-Z or a-z, then ...
                         {\protect\setcounter{SKTCNTS}{`#1}%    convert A-Z to   1-26,
                          \addtocounter{SKTCNTS}{-64}%      and a-z to -(1-26).
                          \ifthenelse{\value{SKTCNTS} > 32}%
                                     {\protect\setcounter{SKTCNTS}{-\value{SKTCNTS}}%
                                      \addtocounter{SKTCNTS}{32}%
                                     }%
                                     {}%
                         }%
                         {\errmessage{SKT macro ZD: invalid parameter "#1"}}%
             }%
}

%
% All naagarii accent characters are in the form \ZK{x} where `x' is the 
% accent character. To colour the accents separately, this command may be
% redefined anywhere in the .skt file as \renewcommand{\ZK}[1]{{\red #1}}.
% It actually makes the text easier to read when the accents are coloured.
%
\newcommand{\ZK}[1]{{#1}}

\endinput