% This TeX code provides varoious kinds of character controls
% Caution, it is still under heave development


% Quote Kerning
% This is not complete. What we want is for this to be called from
% the setup file with a command that brings in the kerning amount.
% This will be easier to use and will allow for more automated control.
% It would be nice if we could have a command like: \kernquotes{0.1em}
% which would turn it on and set the amount. (more research needed)

% Define default kern amount
\newdimen\quotekernamount
\quotekernamount=0pt
\newif\ifqt@st
% Define quotes
\def\soq{^^^^2018}
\def\doq{^^^^201c}
\def\scq{^^^^2019}
\def\dcq{^^^^201d}
% Define kern values
\def\soqkern{\soq\kern\quotekernamount}
\def\doqkern{\doq\kern\quotekernamount}
\def\scqkern{\scq\kern\quotekernamount}
\def\dcqkern{\dcq\kern\quotekernamount}
% Combine values with characters
\def\soqnokern{\soq}
\def\doqnokern{\doq}
\def\scqnokern{\scq}
\def\dcqnokern{\dcq}
% Activate the search characters
\let\knext\relax
% Insert the kerned version
\def\h@ghquotes{^^^^201c^^^^2018^^^^201d^^^^2019} % List of things to trigger a match on
% Logic: If the test item (#1) is nowhere in the above list, then its first occuence will be just before the \E, and ##2 will be empty. If it IS in the list, then ##2 will contain something.
\def\qt@st#1{\def\@@qt@st##1#1##2\E{\edef\tmp{##2}\ifx\tmp\empty\qt@sttrue\else\qt@stfalse\fi}\x@\@@qt@st\h@ghquotes#1\E}
\def\soqtest{\qt@st{\knext}\let\knext=\soqnokern\ifqt@st\ifdim\quotekernamount=0pt\else\let\knext=\soqkern \fi\fi\knext\let\knext\relax}
\def\doqtest{\qt@st{\knext}\let\knext=\doqnokern\ifqt@st\ifdim\quotekernamount=0pt\else\let\knext=\doqkern \fi\fi\knext\let\knext\relax}
\def\scqtest{\qt@st{\knext}\let\knext=\scqnokern\ifqt@st\ifdim\quotekernamount=0pt\else\let\knext=\scqkern \fi\fi\knext\let\knext\relax}
\def\dcqtest{\qt@st{\knext}\let\knext=\dcqnokern\ifqt@st\ifdim\quotekernamount=0pt\else\let\knext=\dcqkern \fi\fi\knext\let\knext\relax}
\DefineActiveChar{^^^^2018}{\futurelet\knext\noexpand\soqtest}
\DefineActiveChar{^^^^2019}{\futurelet\knext\noexpand\scqtest}
\DefineActiveChar{^^^^201c}{\futurelet\knext\noexpand\doqtest}
\DefineActiveChar{^^^^201d}{\futurelet\knext\noexpand\dcqtest}
%\def\liter@lkerns{%\edef^^^^2018{\soq}\edef^^^^201c{\doq}\edef^^^^2019{\scq}\edef^^^^201d{\dcq}%
  %\catcode"2018=12 \catcode"201C=12 \catcode"2019=12 \catcode"201D=12}
%\def\sm@rtquotes{\catcode"2018=\active \catcode"201C=\active \catcode"2019=\active \catcode"201D=\active}
%\sm@rtquotes

