%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% aboxes.sty
% ArabTeX
% Version 17.12.95
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (c) Klaus Lagally
%     Institut fuer Informatik
%     Universitaet Stuttgart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\a@ident {aboxes.sty} {3.04 build output boxes} {17.12.95}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% dynamic definitions for Arabic
{\catcode `\ =9 \catcode `\^^M=9 \catcode `\^^I=9
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\gdef \def@arabaccent {% define accent macros for Arabic
\globaldefs 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def \put@accent ##1+##2*{% put modifier onto contents of "\ab@x"
% m1 + m2 *
	\global\red@mod   ##1 \relax
	\ifnum ##1 > 9 \global\advance \red@mod -10 \relax \fi
\ifnum ##2 = \c@kasra    \a@putkasra    \red@mod \else
\ifnum ##2 = \c@kasratan \a@putkasratan \red@mod \else
	\ifcase \red@mod 
\relax	   \or \put@shadda  \or \put@hamza \or \put@hamza \put@shadda \or
\put@madda \or \put@hamzalo \or
	\fi
	\put@voc ##2*%
\fi \fi }

\def \put@fatha     {\put@acc@hi {\char \a@fatha     }}
\def \put@damma     {\put@acc@hi {\char \a@damma     }}
\def \put@kasra     {\put@acc@lo {\char \a@kasra     }}
\def \put@shadda    {\put@hi     {\char \a@shadda    }}
\def \put@hamza     {\put@hi     {\char \a@hamza     }}
\def \put@hamzalo   {\put@lo     {\char \a@hamza     }}
\def \put@sukun     {\put@acc@hi {\char \a@sukun     }}
\def \put@madda     {\put@acc@hi {\char \a@madda     }}
\def \put@wasla     {\put@acc@hi {\char \a@wasla     }}
\def \put@fathatan  {\put@acc@hi {\char \a@fathatan  }}
\def \put@dammatan  {\put@acc@hi {\char \a@dammatan  }}
\def \put@kasratan  {\put@acc@lo {\char \a@kasratan  }}
\def \put@fathaspec {\put@acc@hi {\char \a@quran@alif}}
\def \put@kasraspec {\put@acc@lo {\char \a@quran@alif}}
\def \put@ammad     {\put@acc@hi {\char \a@ammad     }}
\def \put@zwarakay  {\put@acc@hi {\char \a@zwarakay  }}
\globaldefs 0 }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
}% end of dynamic definitions for Arabic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif \if@con        	\newif \if@mod        	\newif \if@raise   
\newif \if@tie        	\newif \if@raisetie   	\newif \if@tat
\newif \if@uptie      	\newif \if@high@chr   	\newif \if@tatl
\newif \ifa@@write  	\a@@writetrue
%\newif \ifa@kern	

\newcount \chr@cd     \newcount \act@cd     \newcount \chr@tie
\newcount \act@tie    \newcount \chr@mod    \newcount \act@mod
\newcount \chr@cls    \newcount \act@cls    \newcount \red@mod
\newcount \old@cls

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newdimen \a@dp       \newdimen \a@ht       \newdimen \a@wd    
\newdimen \a@disp     \newdimen \a@dim      \newdimen \a@acc
\newdimen \a@tat@ht

\newbox \ab@x         \newbox \lig@box       

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%em# := 25.4dx#;	%ex# := 8dy#;

% Arabic kerning
\def \a@kern   {\nobreak\kern 0.05em }	
\def \a@mkern  {\nobreak\kern -0.05em }

\def \a@kern   {\kern 0.05em }	
\def \a@mkern  {\kern -0.05em }

% shift for raised characters
\def \a@dsp    {.5ex }

% fixed positions for .harakAt
\def \acc@hi   {1.8ex }		\def \acc@lo   {0.4ex }

% kashida dimensions
\def \tat@ht   {0.20ex }	\def \tat@wd   {0.02ex }
\def \tat@skip {0.04ex plus .5ex }
\def \tat@skip {0.04ex plus 0.2fil }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \put@mod #1*{% deposit character, modifiers and ties	% m *
\if@tie \put@tie \@tiefalse \fi
\put@accent #1*\dep@sitb@x
\if@high@chr \advance \a@disp -\a@dsp \@high@chrfalse \fi
\a@ital {\act@cd }\@raisefalse
\if@tat \put@tat \@tatfalse \fi }

\def \dep@sitb@x {% put contents into output, unpack if possible
\ifhbox \ab@x
      \ifdim \a@disp = \z@ \unhbox \ab@x
      \else \raise \a@disp \hbox {\unhbox \ab@x }%
      \fi
\else \global\advance \a@ht \a@disp \global\advance \a@dp -\a@disp
      \ht \ab@x \a@ht \dp \ab@x \a@dp \box \ab@x
\fi }

\def \put@tie {% ties between characters
\ifdim \a@disp = \z@ \char \the\act@tie
\else \raise \a@disp \hbox {\char \the\act@tie }%
\fi \a@ital {\act@tie }}

\def \put@tat {% put a keshide
\a@tat@ht \a@disp \advance \a@tat@ht \tat@ht \nobreak\hskip -\tat@wd
\leaders \hrule height \a@tat@ht depth -\a@disp \hskip \tat@skip 
\hskip -\tat@wd }

\def \a@norm {% start a new character group
\global\@highfalse \@raisefalse \@tiefalse \a@disp \z@ \@high@chrfalse }

\def \a@ital #1{% shifting char: displace \a@disp by italcorr
\setbox0 \hbox {\char \the #1\/}\advance \a@disp \wd0
\setbox0 \hbox {\char \the #1}\advance \a@disp -\wd0 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \a@putkasra #1{% modification at kasra			% m1
\ifcase #1\put@kasra	\or \put@fatha \put@shadda 		\or
\put@ihamza \put@kasra	\or \put@fatha \put@hamza \put@shadda 	\or
\put@madda \put@kasra	\or \put@hamzalo \put@kasra  		\or
\fi }

\def \a@putkasratan #1{% modification at kasratan		% m1
\ifcase #1\put@kasratan	  \or \put@fathatan \put@shadda  	   \or
\put@ihamza \put@kasratan \or \put@fathatan \put@hamza \put@shadda \or
\put@madda \put@kasratan  \or \put@hamzalo \put@kasratan 	   \or
\fi }

\def \put@voc #1*{% put .harakAt				% m2
\ifcase #1\relax \or \put@sukun    \or \put@fatha     \or \put@kasra     \or
\put@damma       \or \put@fathatan \or \put@kasratan  \or \put@dammatan  \or
\put@zwarakay    \or \put@wasla    \or \put@fathaspec \or \put@kasraspec \or
\put@ammad \or
\fi }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \put@ihamza {% hamza at <i> depending on carrier
\ifnum \act@cd = \a@alif@iso     \put@hamzalo \else
\ifnum \act@cd = \a@alif@end     \put@hamzalo \else
\ifnum \act@cd = \a@lam@alif@iso \put@hamzalo \else
\ifnum \act@cd = \a@lam@alif@end \put@hamzalo \else
   \put@hamza
\fi\fi\fi\fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \put@dot #1{% modify character skeleton
\ifcase #1%
\relax				   \or	 %  0
\put@hi {\char \a@one@dot@up      }\or   %  1
\put@hi {\char \a@two@dots@up     }\or   %  2
\put@hi {\char \a@three@dots@up   }\or   %  3
\put@lo {\char \a@one@dot@down    }\or   %  4
\put@lo {\char \a@two@dots@down   }\or   %  5
\put@lo {\char \a@three@dots@down }\or   %  6
\put@hi {\char \a@hamza           }\or   %  7
\put@hi {\char \a@ttah@dia        }\or   %  8
\put@lo {\char \a@one@dot@down }%
  \put@lo {\char \a@one@dot@down  }\or   %  9
\put@hi {\char \a@one@dot@up }%
  \put@lo {\char \a@one@dot@down  }\or   % 10
\put@lo {\char \a@h@dia           }\or   % 11
\put@hi {\char \a@bow@dia         }\or   % 12
\put@lo {\char \a@bow@dia         }\or   % 13
\put@lo {\char \a@two@dots@down }%
  \put@hi {\char \a@bow@dia       }\or   % 14
\put@hi {\char \a@one@dot@down }%
  \put@hi {\char \a@one@dot@down  }\or   % 15
\fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def \put@box #1{\global\setbox \ab@x   \hbox{#1}% put into box
\global\a@ht   \ht \ab@x   \global\a@wd   \wd \ab@x   
\global\a@dp   \dp \ab@x }

\def \put@acc@hi {% upper accent
\ifacc@hi \a@acc \acc@hi \advance \a@acc -\a@disp
\ifdim \a@acc > \a@ht
  \advance \a@acc -\a@ht \global\advance \a@ht \a@acc
  \global\setbox \ab@x   \vbox {\kern \a@acc \nointerlineskip
  \ifvbox \ab@x \unvbox \ab@x \else \box \ab@x \fi }%
\fi\fi \put@hi }

\def \put@acc@lo {% lower accent
\ifacc@hi \a@acc \acc@lo \advance \a@acc \a@disp
\ifdim \a@acc > \a@dp
  \advance \a@acc -\a@dp \global\advance \a@dp \a@acc
  \global\setbox \ab@x   \vbox
  {\ifvbox \ab@x \unvbox \ab@x \else \box \ab@x \fi
  \nointerlineskip \kern \a@acc }%
\fi\fi \put@lo }

% try to economize on diacritics
\def \put@hi #1{% upper modifier
\setbox0 \hbox {#1}\dimen@ \a@wd 
\advance \dimen@ -\wd0 \divide \dimen@ \tw@
\ifdim \z@ > \dimen@ \setbox0 \rlap {#1}\fi
\global\advance \a@ht \ht0 \global\advance \a@ht \dp0 
\global\setbox \ab@x   \vbox 
{\moveright \dimen@ \box0 \nointerlineskip
\ifvbox \ab@x \unvbox \ab@x \else \box \ab@x \fi }}

\def \put@lo #1{% lower modifier
\setbox0 \hbox {#1}\dimen@ \a@wd 
\advance \dimen@ -\wd0 \divide \dimen@ \tw@
\ifdim \z@ > \dimen@ \setbox0 \rlap {#1}\fi
\global\advance \a@dp \ht0 \global\advance \a@dp \dp0 
\global\setbox \ab@x   \vbox 
{\ifvbox \ab@x \unvbox \ab@x \else \box \ab@x \fi 
\nointerlineskip \moveright \dimen@ \box0 }}

\def \a@lig #1*#2*{% deposit a ligature
% m * m *
\setbox \lig@box \hbox {\char \the\act@cd }%
\global\a@wd   \wd \lig@box  \global\divide \a@wd 2   
\let \if@tatl \if@tat \@tatfalse
\global\setbox \ab@x   \vbox {\hbox to\a@wd {\unhcopy \lig@box \hss }}%
\global\a@ht   \ht \lig@box  \global\a@dp   \dp \lig@box \put@mod #1*%
\let \if@tat \if@tatl
\global\setbox \ab@x   \vbox {\hbox to\a@wd {\hss \unhcopy \lig@box }}%
\global\a@ht   \ht \lig@box  \global\a@dp   \dp \lig@box \put@mod #2*}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chardef \c@shadda   = 1     \chardef \c@hamza    = 2
\chardef \c@hamzalow = 3     \chardef \c@madda    = 4
\chardef \c@high     = 10

\chardef \c@sukun     = 1    \chardef \c@fatha     = 2
\chardef \c@kasra     = 3    \chardef \c@damma     = 4
\chardef \c@fathatan  = 5    \chardef \c@kasratan  = 6
\chardef \c@dammatan  = 7    \chardef \c@zwarakay  = 8
\chardef \c@wasla     = 9    \chardef \c@fathaspec = 10
\chardef \c@kasraspec = 11   \chardef \c@ammad     = 12

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EOF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



