% This is minimal level Hebrew support Version 2.0
% Jacques J. Goldberg, Technion, 6.15.88
% Modified as suggested by Ron Greenberg, MIT.
%\tracingmacros=1
%\tracingonline=1
%\tolerance=10000
\font\ivrit=redis10   % default Hebrew font.
\hyphenchar\ivrit=-1
%\let\ivrtmp=0  % Just to make it exist
% The two lines below are taken from D.Knuth and P.MacKay
%     TuGBoat vol.8,#1,page 14.
\def\hebrew#1{{\ivrit \reflect#1\empty\tcelfer }}
\def\reflect#1#2\tcelfer{\ifx#1\empty\else\reflect#2\tcelfer#1\fi}
\def\ivrbar{\vrule height7pt width0.5pt}  % This makes the vertical
					  % bar printable.
% Define work boxes
\newbox\ivrbox  % The Hebrew box to test full line condition
\newbox\ivrstrbox  % The box to hold the current Hebrew string
\setbox\ivrbox=\hbox{}  % Make them empty to begin with
\setbox\ivrstrbox=\hbox{}

\def\ivroff{\message{Latin }  % Toggle Hebrew off, dump current box.
           \hbox to\hsize{\hfil \unhbox\ivrstrbox \unskip} \par}
\def\ivron{\message{Hebrew }  % Toggle Hebrew on, set up empty box
           \unskip \par \setbox\ivrstrbox=\hbox{} \parindent=0pt }

\def\ivrconcat#1#2{#1 #2}     % Glue up two adjacent boxes

\newif\ifivrscrboxfull  % Verify if scratch box is full
\def\ivrcheckscrbox#1{    % Try to add this word
  \setbox\ivrbox=\hbox{\ivrconcat{#1}{\unhcopy\ivrstrbox}}
                 \ivrscrboxfullfalse % May fit in...
                \ifdim \hsize < \wd\ivrbox \ivrscrboxfulltrue \fi} % or not!
% Real work is here
\def\ivrword#1{\ivrcheckscrbox{#1}
          \ifivrscrboxfull \hbox to\hsize{\unhcopy\ivrstrbox \unskip}
                           \setbox\ivrstrbox=\hbox{#1}
      \else \setbox\ivrstrbox=\hbox{\ivrconcat{#1}{\unhcopy\ivrstrbox}}
        \fi} % Done
END/

