%----------------------------------------------------------------------
%  18:46:21  7/4/1988
%----------------------------------------------------------------------
% module `POLTAILS'
%
%
% macro package for PLAIN TeX
% A PREMATURED VERSION!!!
% to be used with crossed fingers
% NO RIGHTS RESERVED
%
% SPECIFICATION:
% defines macros \Polisha \PolishA \Polishe \PolishE
% for Polish tailed characters,
% \Polishl and \PolishL for Polish suppressed l's
% and, moreover, macro \polopenquot as Polish
% opening quotation symbol, macro \numbersymbol for N,
% and facilitates the use of them.
%
% macros and variables with names containing at-sign `@' are assumed
% to be local for this module
%
%
% IMPLEMENTATION :
%
% authors:  B. JACKOWSKI - T. HO�DYS - M. RY�KO
%
%--------
%
\def\KeepKerns#1#2{%
#2{\setbox0=\hbox{#1}\kern-\wd0\copy0\kern-\wd0}#2}%
%--------
\catcode `\@=11 %
%--------
\newdimen\prop@rshift
% \prop@rshift<0  -  shift to the left, >0  -  shift to the right
\newdimen\taild@pth
\newdimen\d@pthcorr
% \d@pthcorr<0 - shift up, >0 - shift down
\newdimen\min@x
\newdimen\curr@x
%--------
{%
\font\fivegr@@k=cmmi5 at 5truept%
\global\min@x=\fontdimen5\fivegr@@k}
%--------
\def\@@lap#1{\vbox to 0pt{\hsize=0pt\kern\d@pthcorr\rlap{\hss#1}\vss}}%
%--------
\def\s@ttwofonts#1#2{%
\font\small@rfont=\curr@nttailfont#1%
\font\bigg@rfont=\curr@nttailfont#2%
}%
%--------
\def\s@tprop@rfonts{%
\curr@x=\fontdimen5\the\font%
% doubled magnification factors (half excluded): 2000, 2400, 3456, 4148, 4976
\s@ttwofonts00%
\ifdim 2\min@x>\curr@x%
\s@ttwofonts01%
\else\ifdim 2.4\min@x>\curr@x%
\s@ttwofonts12%
\else\ifdim 3.456\min@x>\curr@x%
\s@ttwofonts23%
\else\ifdim 4.148\min@x>\curr@x%
\s@ttwofonts34%
\else%
\ifdim 4.976\min@x>\curr@x%
\s@ttwofonts45%
\fi\fi\fi\fi\fi}%
%--------
\def\s@ttailparam@t@rs#1#2{%
% \curr@ntcedillashift and \curr@ntiotashift are defined later on
\if c\curr@nttail%
% C E D I L L A
\prop@rshift=\curr@ntcedillashift{#2}%
\def\prop@rchar{\char'30}%
\d@pthcorr=-0.05ex
\setbox0=\hbox{\prop@rchar}\taild@pth=\dp0
\advance\taild@pth by \d@pthcorr % O.K. since \s@ttailparam@t@rs
%                                  is used inside a group in \tail@d
\else%
% G R E E K   I O T A
\def\prop@rchar{\char'23}%
\prop@rshift=\curr@ntiotashift{#2}%
\s@tprop@rfonts%
\ifnum \the\lccode`#1=`#1 %   small letter
\small@rfont\else%
\ifnum \the\uccode`#1=`#1 %   capital letter
\bigg@rfont%
\fi\fi%
\d@pthcorr=-0.05ex
\taild@pth=1ex \advance\taild@pth by \d@pthcorr \fi}%
%--------
\def\tail@d#1#2{%
#1%  incidentally, preceeding implicit kerns are preserved
%    (e.g., W\\asko is O.K.)
{\s@ttailparam@t@rs{#1}{#2}%
\setbox0=\@@lap{\kern2\prop@rshift\prop@rchar}\dp0=\taild@pth \box0}%
}%
%--------
\def\PolishA{\tail@d A0}%
\def\PolishE{\tail@d E1}%
\def\Polisha{\tail@d a2}%
\def\Polishe{\tail@d e3}%
%--------
\def\Polishl{\char32l}% 
\def\PolishL{\leavevmode{\setbox0\hbox{L}\hbox to\wd0{\hss\char32L}%
\kern-\wd0}L}
%--------
\newdimen\polop@nquotdim%
\def\polopenquot{%
{\setbox0=\hbox{''}\polop@nquotdim=\ht0%
\setbox0=\hbox{,}\advance\polop@nquotdim by -\ht0%
\setbox1=\hbox{\lower\polop@nquotdim\hbox{''}}%
\ht1=\ht0 \dp1=\dp0%
\leavevmode\box1}}%
%--------
\def\@@symbol{\vrule height 1ex width 0.22em depth -0.9ex%
\llap{\char'27 \kern -0.28em}}%
%--------
\def\numbersymbol{N\kern0.05em\@@symbol\kern 0.1em }% DON'T REMOVE THE SPACE!
%--------
\catcode `\@=12%
%----------------------------------------------------------------------
% the main macro of this part of the module, i.e., \Polishdiacriticalletters#1,
% produces the Polish diacritical character made of a letter #1;
% it may be used with letters a, c, e, l, n, o, s, x, z,
%                         and A, C, E, L, N, O, S, X, Z,
% #1=x and #1=X represent accented z and Z, resp.
% #1=z and #1=Z represent dotted z and Z, resp.,
% #1=@ repesents N� symbol,
% #1=, repesents Polish opening quotation mark,i.e. ",,";
%

% GENERAL REMARKS
% the module should work well with a basic set of CM or AM fonts;
% due to especial arragement of macros accomplishing
% Polish "tailed" letters implicit kernings are preserved;
%
% IT DOES NOT WORK IN MATHMODE!!! - embeding in boxes might help...
% (also typewriter fonts does not provide necessary types)
%
%--------
\def\Polishdiacriticalletters#1{%
\if      a#1\KeepKerns{\Polisha}a%
\else\if c#1\KeepKerns{\'c}c%
\else\if e#1\KeepKerns{\Polishe}e%
\else\if l#1\Polishl%
\else\if n#1\'n%
\else\if o#1\KeepKerns{\'o}o%
\else\if s#1\'s%
\else\if x#1\'z%
\else\if z#1\.z%
\else\if A#1\KeepKerns{\PolishA}A%
\else\if C#1\KeepKerns{\'C}C%
\else\if E#1\PolishE%
\else\if L#1\PolishL%
\else\if N#1\'N%
\else\if O#1\KeepKerns{\'O}O%
\else\if S#1\'S%
\else\if X#1\'Z%
\else\if Z#1\.Z%
\else\if @#1\numbersymbol%
\else\if ,#1\polopenquot%
\else%
\ifhmode %
  \hskip2pt \vrule height1.5ex width\overfullrule depth0.2ex \hskip2pt %
\else %
   \ifvmode %
   \vskip2pt \hrule height1.5ex width\overfullrule depth0.2ex \vskip2pt %
\fi %
\fi %
%\message{NIE MA DIAKRYTYCZNEGO #1!   }%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
%
%--------
%
\begingroup
\global\let\previoustwobackslashes=\\%
\def\\#1{%
\Polishdiacriticalletters{#1}}%
\global\let\Polishtwobackslashes=\\
\endgroup
%--------
%
% An alternative implementation, using active `/' rather than `\\':
%
%--------
\newcount\previousslashcode \previousslashcode=\the\catcode`\/%
\begingroup
\catcode`\/=12 %
\global\def\normalslash{/}
\catcode`\/=\active %
\global\let\previoussingleslash=/%
\def/#1{%
\ifx     /#1\normalslash \else%
\Polishdiacriticalletters{#1}%
\fi%
}%
\global\let\Polishsingleslash=/
%----------------------------------------------------------------------
% macros \switchtoslash and \switchtobackslashes enable an undecided
% user to switch back and forth between the two ways of marking Polish
% diacritical letters in a source text: after \switchtoslash / should be 
% used as the preceding operator, after \switchtobackslashes - \\ (default).
% Switching restores the previous meaning of the other operator.
%----------------------------------------------------------------------
\global\def\switchtoslash{%
\global\previousslashcode=\the\catcode`\/%
\catcode`\/=\active%
\global\let\\=\previoustwobackslashes%
\global\let\previoussingleslash=/%
\global\let/=\Polishsingleslash}%
%
\global\def\switchtobackslashes{%
\global\let\previoustwobackslashes=\\%
\global\let\\=\Polishtwobackslashes%
\ifnum \the\catcode`\/=\active \global\let/=\previoussingleslash \fi%
\global\catcode`\/=\previousslashcode %
}%
\endgroup%
%
%----------------------------------------------------------------------
% some additional macros:
%----------------------------------------------------------------------
\begingroup%
\catcode`\@=11 %
% a, A, e, and E shifts:
\global\def\setiotashifts(#1\A #2\E #3\a #4\e){%
\def\curr@ntiotashift##1{%
\ifcase##1 #1em\or#2em\or#3em\or#4em\fi}}% DON'T REMOVE THE SPACE!
%--------
\global\def\setcedillashifts(#1\A #2\E #3\a #4\e){%
\def\curr@ntcedillashift##1{%
\ifcase##1 #1em\or#2em\or#3em\or#4em\fi}}% DON'T REMOVE THE SPACE!
%--------
\global\def\switchtoiotatail{\let\curr@nttail=i}%
\global\def\switchtocedillatail{\let\curr@nttail=c}%
\global\def\switchtononbold{%
\setiotashifts(-0.12\A -0.2\E -0.1\a -0.18\e)%
\setcedillashifts(-0.1\A -0.24\E -0.14\a -0.2\e)%
\def\curr@nttailfont##1{%
\ifcase ##1 cmmi5 at 5truept \or%
cmmi5 at 5.475truept \or%
cmmi5 at 6truept \or%
cmmi5 at 7.2truept \or%
cmmi5 at 8.64truept \or%
cmmi5 at 10.37truept \or%
\fi}%
}%
\global\def\switchtobold{%
\setiotashifts(-0.14\A -0.18\E -0.1\a -0.2\e)%
\setcedillashifts(-0.18\A -0.24\E -0.16\a -0.22\e)%
\def\curr@nttailfont##1{%
\ifcase ##1 cmmi5 at 5truept \or%
cmmi5 at 5.475truept \or%
cmmi5 at 6truept \or%
cmmi5 at 7.2truept \or%
cmmib10 at 10truept \or%
cmmib10 at 10.95truept \or%
\fi}%
}%
\endgroup%
%----------------------------------------------------------------------
% DEFAULTS:
%----------------------------------------------------------------------
\switchtobackslashes
\switchtoiotatail
\switchtononbold
%
%
\endinput
