%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%                impression de hieroglyphes en LaTeX
%%                Hieroglyphs Writing in LaTeX  
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%there are two ways for hieroglyphs writing there:
%% both of them are based on the
%%  " Inventaire des signes hieroglyphiques en vue de leur saisie
%%                             informatique "
%% Jan Buurman-Nicolas Grimal-Michael Hainsworth-Jochen Hallof-
%% Dirk Van Der Plas
%%
%% Memoires de l'Academie des Inscriptions et Belles Lettres
%%
%% (the text is in french, english, and german)

%% * the first way: Really hard one: make a list of the fonts 
%% (with "tex testfonts"), remember the number of the characters
%%
%% Two signs on the same level are separated by a '-'
%% a sign below another one is separated form it by a ':'
%% grouping is done by { }
%% 
%%% Exemples de texte    
%%\hieroglyphe{M/17-G/46-A/1-G/19-Y/3-Y/1:Z/2-M/17-{N/29-D/21}:Y/1}
%%\hieroglyphe{{Q/3-X/1}:{N/1-N/1-N/1}}
%%\hieroglyphe{{Q/3-X/1}:N/1}
%%\hieroglyphe{W/26:N/35:V/31}
%%\hieroglyphe{W/26:N/35:V/31-A/1-Y/3:Y/1-M/17-N/29:D/21:Y/1}

%% An easier way: I am writing now a program to generate hieroglyphic
%% texts. It will be an extension of the "manuel de codage" symbolism.

%% Fonts definitions (quite a lot !)

%% Useful symbols 
\newfont{\EgypS}{Egyp}

\newfont{\GA}{A scaled \magstep 1}
\newfont{\GAi}{A}
\newfont{\GAii}{A scaled 833}
\newfont{\GAiii}{A scaled 694}
\newfont{\GAiiii}{A scaled 582}
\newfont{\GB}{B scaled \magstep 1}
\newfont{\GBi}{B}
\newfont{\GBii}{B scaled 833}
\newfont{\GBiii}{B scaled 694}
\newfont{\GBiiii}{B scaled 582}
\newfont{\GC}{C scaled \magstep 1}
\newfont{\GCi}{C}
\newfont{\GCii}{C scaled 833}
\newfont{\GCiii}{C scaled 694}
\newfont{\GCiiii}{C scaled 582}
\newfont{\GD}{D scaled \magstep 1}
\newfont{\GDi}{D}
\newfont{\GDii}{D scaled 833}
\newfont{\GDiii}{D scaled 694}
\newfont{\GDiiii}{D scaled 582}
\newfont{\GE}{E scaled \magstep 1}
\newfont{\GEi}{E}
\newfont{\GEii}{E scaled 833}
\newfont{\GEiii}{E scaled 694}
\newfont{\GEiiii}{E scaled 582}
\newfont{\GF}{F scaled \magstep 1}
\newfont{\GFi}{F}
\newfont{\GFii}{F scaled 833}
\newfont{\GFiii}{F scaled 694}
\newfont{\GFiiii}{F scaled 582}
\newfont{\GG}{G scaled \magstep 1}
\newfont{\GGi}{G}
\newfont{\GGii}{G scaled 833}
\newfont{\GGiii}{G scaled 694}
\newfont{\GGiiii}{G scaled 582}
\newfont{\GH}{H scaled \magstep 1}
\newfont{\GHi}{H}
\newfont{\GHii}{H scaled 833}
\newfont{\GHiii}{H scaled 694}
\newfont{\GHiiii}{H scaled 582}
\newfont{\GI}{I scaled \magstep 1}
\newfont{\GIi}{I}
\newfont{\GIii}{I scaled 833}
\newfont{\GIiii}{I scaled 694}
\newfont{\GIiiii}{I scaled 582}
\newfont{\GK}{K scaled \magstep 1}
\newfont{\GKi}{K}
\newfont{\GKii}{K scaled 833}
\newfont{\GKiii}{K scaled 694}
\newfont{\GKiiii}{K scaled 582}
\newfont{\GL}{L scaled \magstep 1}
\newfont{\GLi}{L}
\newfont{\GLii}{L scaled 833}
\newfont{\GLiii}{L scaled 694}
\newfont{\GLiiii}{L scaled 582}
\newfont{\GM}{M scaled \magstep 1}
\newfont{\GMi}{M}
\newfont{\GMii}{M scaled 833}
\newfont{\GMiii}{M scaled 694}
\newfont{\GMiiii}{M scaled 582}
\newfont{\GN}{N scaled \magstep 1}
\newfont{\GNi}{N}
\newfont{\GNii}{N scaled 833}
\newfont{\GNiii}{N scaled 694}
\newfont{\GNiiii}{N scaled 582}
\newfont{\GO}{O scaled \magstep 1}
\newfont{\GOi}{O}
\newfont{\GOii}{O scaled 833}
\newfont{\GOiii}{O scaled 694}
\newfont{\GOiiii}{O scaled 582}
\newfont{\GP}{P scaled \magstep 1}
\newfont{\GPi}{P}
\newfont{\GPii}{P scaled 833}
\newfont{\GPiii}{P scaled 694}
\newfont{\GPiiii}{P scaled 582}
\newfont{\GQ}{Q scaled \magstep 1}
\newfont{\GQi}{Q}
\newfont{\GQii}{Q scaled 833}
\newfont{\GQiii}{Q scaled 694}
\newfont{\GQiiii}{Q scaled 582}
\newfont{\GR}{R scaled \magstep 1}
\newfont{\GRi}{R}
\newfont{\GRii}{R scaled 833}
\newfont{\GRiii}{R scaled 694}
\newfont{\GRiiii}{R scaled 582}
\newfont{\GS}{S scaled \magstep 1}
\newfont{\GSi}{S}
\newfont{\GSii}{S scaled 833}
\newfont{\GSiii}{S scaled 694}
\newfont{\GSiiii}{S scaled 582}
\newfont{\GT}{T scaled \magstep 1}
\newfont{\GTi}{T}
\newfont{\GTii}{T scaled 833}
\newfont{\GTiii}{T scaled 694}
\newfont{\GTiiii}{T scaled 582}
\newfont{\GU}{U scaled \magstep 1}
\newfont{\GUi}{U}
\newfont{\GUii}{U scaled 833}
\newfont{\GUiii}{U scaled 694}
\newfont{\GUiiii}{U scaled 582}
\newfont{\GV}{V scaled \magstep 1}
\newfont{\GVi}{V}
\newfont{\GVii}{V scaled 833}         
\newfont{\GViii}{V scaled 694}
\newfont{\GViiii}{V scaled 582}
\newfont{\GW}{W scaled \magstep 1}
\newfont{\GWi}{W}
\newfont{\GWii}{W scaled 833}
\newfont{\GWiii}{W scaled 694}
\newfont{\GWiiii}{W scaled 582}
\newfont{\GX}{X scaled \magstep 1}
\newfont{\GXi}{X}
\newfont{\GXii}{X scaled 833}
\newfont{\GXiii}{X scaled 694}
\newfont{\GXiiii}{X scaled 582}
\newfont{\GY}{Y scaled \magstep 1}
\newfont{\GYi}{Y}
\newfont{\GYii}{Y scaled 833}
\newfont{\GYiii}{Y scaled 694}
\newfont{\GYiiii}{Y scaled 582}
\newfont{\GZ}{Z scaled \magstep 1}
\newfont{\GZi}{Z}
\newfont{\GZii}{Z scaled 833}
\newfont{\GZiii}{Z scaled 694}
\newfont{\GZiiii}{Z scaled 582}
\newfont{\GAa}{Aa scaled \magstep 1}
\newfont{\GAai}{Aa}
\newfont{\GAaii}{Aa scaled 833}
\newfont{\GAaiii}{Aa scaled 694}
\newfont{\GAaiiii}{Aa scaled 582}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 
%%                      SIZE SYSTEM
%% there can be three groups of signs for size : long, high, and others
%% but this isn't really useful except for column writing. 

% size of the current sign
% for long signs :
\def\HtaW{} % possible values : {} i ii iii iiii
% for high signs :
\def\HtaH{}
%for other signs :
\def\Hta{} 

\newcount\@Hauteur              % sign size used
\@Hauteur=0
\newcount\@HauteurW              % sign size used
\@HauteurW=0
\newcount\@HauteurH              % sign size used
\@HauteurH=0


% text orientation
\newif\if@droitegauche
\@droitegauchefalse
\newif\if@xettexon
\@xettexonfalse
\newif\if@external
\@externaltrue
\newif\if@horizontal
\@horizontaltrue

\def\@aligner{\if@external\raise -\@Lower \fi}

% using tex--xet
\def\leftright{\if@xettexon\endR\fi\beginL\@droitegauchefalse\@xettexontrue}
\def\rightleft{\if@xettexon\endL\fi\beginR\@droitegauchetrue\@xettexontrue}
\def\boxrightleft#1{{\@droitegauchetrue{}#1}}

% \Acv{size}part of font/number\relax => gives you a character
\def\Acv#1#2/#3\relax{%
\count0=#3%
\if@droitegauche%
\advance\count0 by 128\fi%
\hskip 0.3mm{\csname G#2#1\endcsname\char\count0}\hskip 0.3mm}%

%%%% front-end to sign :

\def\Aca #1/#2/{\Acv{\Hta}#1/#2\relax}

\newdimen\Htm % maximum height of a quadra (we chosed the size
                    % of the independant pronoun(ink)
\newdimen\Htmi
\newdimen\Htmii
\newdimen\Htmiii
\newdimen\Htmiiii
\newdimen\Htm@ % Constant value

% now calculating the size of "ink" :
\setbox0=\vbox{%
\offinterlineskip%
\def\Hta{iiii}%
\hbox{\Acv{\Hta}W/26\relax}%
\hbox{\Acv{\Hta}V/32\relax}%
\hbox{\Acv{\Hta}A/1\relax}}%

% if you want smaller quadra, uncomment the line below.
% size of the aleph vulture
 \setbox0=\vbox{\hbox{\Acv{\Hta}G/1\relax}}

\Htm=\ht0
\advance\Htm by 0.025mm         % Htm : max size of wanted quadra

\setbox0=\vbox{\hbox{\Acv{i}G/1\relax}}
\Htmi=\ht0
\setbox0=\vbox{\hbox{\Acv{ii}G/1\relax}}
\Htmii=\ht0
\setbox0=\vbox{\hbox{\Acv{iii}G/1\relax}}
\Htmiii=\ht0
\setbox0=\vbox{\hbox{\Acv{iiii}G/1\relax}}
\Htmiiii=\ht0

\Htm@=\Htm

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%                      CODE FOR CARTOUCHE(s)
%% 
%% 
%% ==> left to right
%% 
%%  ( @deb@cI              @regleC@I            @fin@cI
%%    @deb@cII             text of cartouche    @fin@cII
%%    @deb@cIII            @regleC@II           @fin@cIII
%% 
%% box4 = middle part
%% dimen0 = necessary dimension of cII fillers

\newdimen\@Lower
\@Lower=1.5mm                   % cartouche line + space
% Now, the cartouche 

\newdimen\epaisseur             % width of cartouche line
\epaisseur=0.3mm

%%%% DEFAULT VALUES (well, values that make a cartouche)
\def\@regleC@I{\if@horizontal\hrule height\epaisseur\vskip0.2mm\else
  \vrule width\epaisseur\hskip0.2mm\fi}

\def\@regleC@II{\if@horizontal\vskip0.2mm\hrule height\epaisseur\relax\else
  \hskip0.2mm\vrule width\epaisseur\relax\fi}

\def\@cadre@rempl{\if@horizontal\hskip 0.5mm\else\vskip 0.5mm\fi}

\def\@fin@cI{%
  \if@horizontal
  \if@droitegauche\hbox{1}\else\hbox{4}\fi
  \else
  \if@droitegauche\hbox{2}\else\hbox{3}\fi\fi}
  
\def\@fin@cII{%
  \if@horizontal
  \if@droitegauche
  {\setbox0=\hbox{1}%
    \hbox{\hbox to \wd0{\hfil\vrule width \epaisseur height \dimen0}%
      \vbox{\vbox to 0mm{\vss\hbox{7}\vss}\vskip0.5\dimen0}}}%
    \else
  {\setbox0=\hbox{1}%
    \hbox{\hbox to \wd0{\hfil\vrule width \epaisseur height \dimen0}%
      \vbox{\vbox to 0mm{\vss\hbox{5}\vss}\vskip0.5\dimen0}}}%
  \fi
  \else
  \hbox to 0mm{\hbox{\kern0.5\dimen0\hbox to 0mm{\hss6\hss}}\hss}%
  \hbox to \dimen0{\leaders\hrule height\epaisseur\hfil}%
  \relax\fi}

\def\@fin@cIII{%
  \if@horizontal
  \if@droitegauche\hbox{2}\else\hbox{3}\fi
  \else
  \if@droitegauche\hbox{3}\else\hbox{2}\fi\fi}

\def\@deb@cI{%
  \if@horizontal
  \if@droitegauche\hbox{4}\else\hbox{1}\fi
  \else
  \if@droitegauche\hbox{1}\else\hbox{1}\fi\fi}
  
\def\@deb@cII{%
  \if@horizontal
  \leaders\vrule width\epaisseur\vfil\relax\else
  {\setbox0=\hbox{1}%
    \hbox{\vbox to\ht0{%
      \hbox to \dimen0{\leaders\hrule height\epaisseur\hfil}%
      \vfil}}}%
  \fi}

\def\@deb@cIII{%
  \if@horizontal
  \if@droitegauche\hbox{3}\else\hbox{2}\fi
  \else
  \if@droitegauche\hbox{4}\else\hbox{4}\fi\fi}


\def\@init@cadre#1{%
  \offinterlineskip%
  \if@horizontal\relax%
  \else\largeur@colonne=.8\largeur@colonne\relax\fi
  \let\strut=\relax
  \EgypS
  \setbox4=\hbox{}%
  \if@horizontal
  \setbox2=\hbox{\vbox{\@deb@cI\@deb@cIII}\vbox{\@fin@cI\@fin@cIII}}%
  \setbox4=\vbox{\@regleC@I\hbox{\Centrer\@cadre@rempl\hbox{#1}\@cadre@rempl}\@regleC@II}% peut etre dans une hbox
  \ifdim\ht2>\ht4%
  \setbox4=\vbox to \ht2{\@regleC@I\vfill\hbox{\Centrer\@cadre@rempl\hbox{#1}\@cadre@rempl}\vfill\@regleC@II}%
  \fi
  \dimen0=\ht4%
  \advance\dimen0 by -\ht2%
  \else
  \setbox2=\vbox{\hbox{\@deb@cI\@deb@cIII}\hbox{\@fin@cI\@fin@cIII}}%
  \setbox4=\hbox{\@regleC@I\vbox{\@cadre@rempl\vbox{#1}\@cadre@rempl}\@regleC@II}%
  \ifdim\wd2>\wd4%
  \setbox4=\hbox to \wd2{\@regleC@I\hfill\vbox{\@cadre@rempl\vbox{#1}\@cadre@rempl}\hfill\@regleC@II}%
  \fi
  \dimen0=\wd4%
  \advance\dimen0 by -\wd2%
  \fi}

\def\@dessin@cadre{{\if@horizontal
    \dimen2=\epaisseur
    \if@external\advance\dimen2 by \@Lower\fi
    \raise -\dimen2\hbox\else\vbox\fi
    {\@debut@cadre\copy4\@fin@cadre}}}

\def\@debut@cadre{\if@horizontal\vbox to\ht4\else\hbox to\wd4\fi{%
    \@deb@cI\@deb@cII\@deb@cIII}}

\def\@fin@cadre{\if@horizontal
  \vbox to\ht4{\@fin@cI\@fin@cII\@fin@cIII}
  \else
  \hbox to\wd4{\@fin@cIII\@fin@cII\@fin@cI}\fi}

\def\cartouche#1{{\let\@cadre@rempl=\relax\@init@cadre{#1}\@dessin@cadre}}


\def\debcartouche#1{{\let\@fin@cI=\relax\let\@fin@cII=\relax\let\@fin@cIII=\relax
    \@init@cadre{#1}\@dessin@cadre}}


\def\milcartouche#1{{\let\@fin@cI=\relax\let\@fin@cII=\relax\let\@fin@cIII=\relax
    \let\@deb@cI=\relax\let\@deb@cII=\relax\let\@deb@cIII=\relax
    \@init@cadre{#1}\@dessin@cadre}}


\def\fincartouche#1{{\let\@deb@cI=\relax\let\@deb@cII=\relax\let\@deb@cIII=\relax
    \@init@cadre{#1}\@dessin@cadre}}


%% Now, castles 

\def\@hori@ligne{%
  \if@horizontal
  \leaders\vrule width\epaisseur\vfil\relax\else
  \leaders\hrule height\epaisseur\hfil\relax\fi}

\def\@fin@chateauII{%
  \if@horizontal
  {\setbox0=\hbox{8}%
    \hbox to \wd0{\hfill\vrule width\epaisseur height\dimen0}}%
  \else
  \hbox to \dimen0{\leaders\hrule height\epaisseur\hfill}%
  \relax\fi}

\def\@coin@chateau{\hbox{8}}

\def\@pas@coin@chateau{%%
  {\setbox0=\hbox{8}%
  \if@horizontal
  \hbox to \wd0{\vrule height\epaisseur width\wd0}%
  \else
  \vbox to \ht0{\hrule width\epaisseur  height \ht0}%
  \fi
}}




\def\chateau#1{{\let\@fin@cI=\relax\let\@fin@cIII=\@coin@chateau
    \let\@deb@cI=\relax\let\@deb@cIII=\relax
    \let\@fin@cII=\@fin@chateauII
    \let\@fin@cI=\@pas@coin@chateau
    \let\@deb@cII=\@hori@ligne
    \@init@cadre{#1}\@dessin@cadre}}


%% Now serekhs 

\def\@serekh@eltH{\vbox{\hrule  width0mm height .75\epaisseur\hrule  width
    2mm height\epaisseur\hrule  width0mm height .75\epaisseur}}

\def\@serekh@eltV{\hbox{\vrule  height0mm width .75\epaisseur\vrule height
    2mm width\epaisseur\vrule  height0mm width .75\epaisseur}}

\def\@fin@serekhII{%
  \if@horizontal
  {\setbox0=\@serekh@eltH
    \hbox{%
      \vbox to \dimen0{\leaders\vrule width\epaisseur\vfil}%
      \vbox to \dimen0{\hrule width\epaisseur height\epaisseur
        \vfil
        \hrule width\epaisseur height\epaisseur
        }%
      \vbox to \dimen0{\leaders\vrule width\epaisseur\vfil}%
      \vbox to\dimen0{\hrule  width 2mm height\epaisseur
        \cleaders\box0\vfill
        \hrule  width 2mm height\epaisseur}}}
    \else
  {\setbox0=\@serekh@eltV
    \vbox{%
      \hbox to \dimen0{\leaders\hrule height\epaisseur\hfil}%
      \hbox to \dimen0{\vrule height\epaisseur width\epaisseur
        \hfil
        \vrule height\epaisseur width\epaisseur
        }%
      \hbox to \dimen0{\leaders\hrule height\epaisseur\hfil}%
      \hbox to\dimen0{\vrule  height 2mm width\epaisseur
        \cleaders\box0\hfill
        \vrule  height 2mm width\epaisseur}}}
  \relax\fi}

\def\serekh#1{{\let\@fin@cI=\relax\let\@fin@cIII=\relax
    \let\@deb@cI=\relax\let\@deb@cIII=\relax
    \let\@fin@cII=\@fin@serekhII
    \let\@deb@cII=\@hori@ligne    
    \@init@cadre{#1}\@dessin@cadre}}

\def\finserekh#1{{\let\@fin@cI=\relax\let\@fin@cIII=\relax
    \let\@deb@cI=\relax\let\@deb@cIII=\relax
    \let\@fin@cII=\@fin@serekhII
    \let\@deb@cII=\relax    
    \@init@cadre{#1}\@dessin@cadre}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%              end of cartouche

\def\Hesp{\@HachureP{\phantom{\Acv{\Hta}A/1\relax}}} %% the phantom of
                                %% a white space

\def\Hqrtesp{\@HachureP{\phantom{\Acv{\Hta}X/1\relax}}} %% the fourth
                                %% part of a quadra
\def\HToLine{\par}              % line change after -!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% For use with sesh
%% 
%% Couples of macros (mmx. \Hhbt and \HhbtI are used thus :
%%         HhbtI is used for the top sign 
%%         Hhbt is used for the others
%% Hhbt : horizontal inside boxes
%% Hrp  : hspace between signs
%% Hitmts : hspace between words (same as Hrp, breaks more easily)
%% Hta : one of (nothing), i, ii, ... : font size used
%% H@Reduction : tries to get a good width for horizontal arangement
%% Himbt : resets the value of some macros when INSIDE a quadra
%% Hbt : a quadra 
%% Hbti : a quadra, when inside another quadra
%% Hunh : a lone hieroglyph, a long way from home
%% horligne : signs on the same level. used for signs in column 


\def\MInEx{iiii} % smaller font size available
\def\negAROBspace{\hskip -1mm} % negative space
\def\negAROBvspace{\vskip -1mm} % negative vertical space
\def\Hhbt#1{\vskip 0.05\Htm plus 1fil\hbox{\H@Reduction{#1}}} % 
\def\HhbtI#1{\hbox{\H@Reduction{#1}}}

\def\Hrp{\nolinebreak[1]\hskip 0.0mm plus 0.5mm}% espace entre les signes
\def\Hitmts{\linebreak[3]\hskip 0.0mm plus 0.5mm}% espace entre les mots

\def\horligne#1{#1}

%\def\Hsmaller{%
%\ifx\Hta\MInEx%
%\else
%\edef\Hta{\Hta i}\advance\@Hauteur by 1%
%\fi}

\def\Hsmaller{\@Smaller}

\def\@Smaller{%
  \ifx\Hta\MInEx%
  \else
  \edef\Hta{\Hta i}\advance\@Hauteur by 1%
  \edef\HtaW{\HtaW i}\advance\@HauteurW by 1%
  \edef\HtaH{\HtaH i}\advance\@HauteurH by 1%
  \fi}

\def\Horizontal@Smaller{\@Smaller}
\def\Vertical@Smaller{\@Smaller}

% Horizontal box.
\def\H@Reduction#1{%  
{\ifx\Hta\MInEx%
  #1\else
  \setbox0=\hbox{#1}%
  \ifdim\wd0>1.3\Htm%      Un quadra, c'est presque carre'
  \Horizontal@Smaller
  \H@Reduction{#1}%
  \else #1\fi\fi}}

\def\Himbt#1{%
  \def\Hhbt##1{%
    \vskip 0.05\Htm plus 1fil\hbox to \wd0{%
      \hfil \H@Reduction{##1}\hfil}}%
  \def\HhbtI##1{\hbox to \wd0{\hfil \H@Reduction{##1}\hfil}}%
  \setbox0=\vbox to \Htm{\offinterlineskip #1}}


%% Boite contenant des hieroglyphes 
\def\Hbt#1{{%
    \def\strut{\relax}%
    \setbox0=\vbox{\offinterlineskip\@externalfalse
      #1}%
    \ifdim\ht0>\Htm%
    \ifx\Hta\MInEx%
    \Himbt{\@externalfalse #1}%
    \@aligner\hbox{\@HachureP{\box0}}%
    \else%
    \Vertical@Smaller
    \Hbt{\@externalfalse #1}%
    \fi%
    \else%
    \Himbt{\@externalfalse #1}%
    \@aligner\hbox{\@HachureP{\box0}}\fi}\strut}

%% Une boite, a` l'inte'rieur, n'a pas de hauteur fixe 

\def\Hbti#1{{%
\def\Hhbt##1{\vskip 0.05\Htm plus 1fil\hbox{\H@Reduction{##1}}}%
\def\HhbtI##1{\hbox{\H@Reduction{##1}}}%
\ifcase \@Hauteur \or
\Htm\Htmi\or
\Htm\Htmii\or
\Htm\Htmiii\or
\Htm\Htmiiii\else
\message{Too small a sign!}%
\fi
\setbox0=\vbox{\offinterlineskip #1}%
\ifdim\ht0>\Htm
\ifx\Hta\MInEx
\Himbt{#1}\hbox{\box0}%
\else%
\Vertical@Smaller
\Hbti{#1}%
\fi%
\else%
\Himbt{#1}\hbox{\box0}%
\fi}}

%hieroglyphes seuls (centre's ou non)

\def\HunhA#1{{%
\setbox0=\hbox{#1}%
\ifdim\ht0>0.75\Htm%
\setbox0=\hbox{\@HachureP{\box0}}%
\else
\setbox0=\hbox{\@HachureP{\vbox to \Htm{\vfil\box0\vfil}}}%
\fi
\@aligner\box0\strut}}

\def\HunhB#1{\@aligner\hbox{\@HachureP{#1}}\strut}

\def\Centrer{\def\Hunh{\HunhA}}
\def\SurLigne{\def\Hunh{\HunhB}}
\Centrer

%ligatures Dd et Dt :

\def\ligAROBDd{{\hbox{\vbox{\offinterlineskip%
\hbox{\Acv{\Hta}I/11\relax}%
\ifnum\@Hauteur<3%
\vskip -1mm\hbox{\Acv{\Hta ii}D/48\relax}%
\else
\ifnum\@Hauteur=3%
\vskip -1mm\hbox{\Acv{\Hta i}D/48\relax}%
\else
\vskip -1mm\hbox{\Acv{\Hta}D/48\relax}%
\fi\fi%
}}}}

\def\ligAROBDt{{\hbox{\vbox{\offinterlineskip%
\hbox{\Acv{\Hta}I/11\relax}%
\vskip -1mm\hbox{\Acv{\Hta}X/1\relax}%
}}}}

\def\ligAROBDra{\hbox{\vbox{\offinterlineskip%
\hbox{\Acv{\Hta}I/11\relax}%
\vskip -1.6mm\hbox{\hskip1mm\Acv{\Hta}N/5\relax}%
}}}


%%% A CORRIGER **** PATCH INFAME *****
\def\ligAROBD{\hbox{\vbox{\offinterlineskip%
\hbox{\Acv{\Hta}I/11\relax}%
\hbox{}
}}}

%%% Les nombres
\def\hierCC{\hbox{\Acv{\Hta}V/1\relax\Acv{\Hta}V/1\relax}}
% Hachures ?


\newbox\HachureBoxII
\setbox\HachureBoxII=\hbox{{\offinterlineskip%
\EgypS\vbox{\hbox{C}\hbox{C}\hbox{C}}}}

\newbox\HachureBoxIII
\setbox\HachureBoxIII=\hbox{\EgypS CCC}

\let\@HachureP=\relax
\def\hachure#1{{\leavevmode\def\strut{\relax}%
    \setbox0=\hbox{\@externalfalse #1}%
    \@aligner\hbox{\hbox to 0mm{%
        \HRemplir{\wd0}{1.1\Htm}\hss}\box0}}\strut}

%\def\hachure#1{{\leavevmode\def\strut{\relax}%
%    \let\@HachureP=\hachurega
%    \def\Hrp{\nolinebreak[1]}% espace entre les signes
%    \def\Hitmts{\linebreak[3]}% espace entre les mots
%    #1}}
    
\def\hachuregaux{\@aligner\hbox{\copy\HachureBoxII\copy\HachureBoxII}}
\def\hachureg{\hachuregaux}
\def\hachurev{\@aligner\copy\HachureBoxII}
\def\hachureh{\@aligner\copy\HachureBoxIII}
\def\hachuret{\@aligner\hbox{\EgypS C}}

\def\hachurega#1{{\def\strut{}%
    \leavevmode\setbox0=\hbox{\@externalfalse #1}%
    \@aligner\hbox{\hbox to 0mm{%
        \copy0\hss}\HRemplir{\wd0}{1.1\Htm}}}\strut}

\def\hachureva#1{{\def\strut{}%
    \offinterlineskip\setbox0=\hbox{\@externalfalse #1}%
    \@aligner\hbox to \wd0{%
      \hbox to 0mm{\vbox to 0mm{\vss\HRemplir{0.5\wd0}{1.1\Htm}}\hss}%
      \box0}}\strut}

\def\hachureha#1{{\def\strut{}%
    \offinterlineskip\setbox0=\hbox{\@externalfalse #1}%
    \@aligner\hbox to \wd0{%
      \hbox to 0mm{\vbox to 0mm{\vss\vbox to 1.1\Htm{%
            \HRemplir{\wd0}{0.55\Htm}\vss}}\hss}%
        \box0}}\strut}

\def\hachureta#1{{\def\strut{}%
    \offinterlineskip\setbox0=\hbox{\@externalfalse #1}%
    \@aligner\hbox to \wd0{%
      \hbox to 0mm{\vbox to 0mm{\vss\vbox to 1.1\Htm{%
            \HRemplir{0.55\Htm}{0.55\Htm}\vss}}\hss}%
        \box0}}\strut}

\def\hsuperpose#1#2{%
  \setbox0=\hbox{#1}%
  \setbox2=\hbox{#2}%
  \setbox0=\hbox{\raise\dp0\box0}% there MUST be another way !!!!!!
  \setbox2=\hbox{\raise\dp2\box2}%
  \ifdim\ht0>\ht2
  \setbox2=\hbox to \wd2{\vbox to \ht0{\offinterlineskip\vss\box2\vss}}%
  \else
  \setbox0=\hbox to \wd0{\vbox to \ht2{\offinterlineskip\vss\box0\vss}}%
  \fi
  \ifdim\wd0>\wd2
  \@aligner\hbox{\rlap{\hbox to\wd0{\hss\box2\hss}}\box0}%
  \else
  \@aligner\hbox{\rlap{\hbox to\wd2{\hss\box0\hss}}\box2}%
  \fi}

\def\Hrotate#1#2{% turns a box around its middle
% NEEDS PS OUTPUT FACILITY !!!!!
\setbox0=\hbox{#2}
\special{ps:gsave currentpoint currentpoint translate 
#1 rotate neg exch neg exch translate
}
\box0
\special{ ps:currentpoint grestore moveto}%
}



%%% \r[1234] commands

\def\HRXC#1{\HrotateXC{#1}}
\def\HRXC{\HrotateXC}

\def\HrotateXC#1{
% turns a box around its middle ??? 
% NEEDS PS OUTPUT FACILITY !!!!!
\setbox0=\hbox{#1}%
\hbox to 0.5\wd0{\hss\vbox to 0.5\ht0{\vss}\vrule\hss}%
\special{ps:gsave currentpoint currentpoint translate 
90 rotate neg exch neg exch translate
}%
\hbox to 0em{\hss\vbox to 0ex{\vss\box0\vss}\hss}%
\special{ ps:currentpoint grestore moveto}%
}


\newif\if@displayhieroglyphes
\@displayhieroglyphestrue

\def\DisplayHieroglyphs{\@displayhieroglyphestrue}
\def\TextHieroglyphs{\@displayhieroglyphesfalse}
\def\ch@seHsize{}
\def\ch@seHsizei{\Htm=\Htmi\Htmi=\Htmii\Htmii=\Htmiii\Htmiii=\Htmiiii}
\def\ch@seHsizeii{\Htm=\Htmii\Htmii=\Htmiii\Htmiii=\Htmiiii}
\def\ch@seHsizeiii{\Htm=\Htmiii\Htmii=\Htmiiii}
\def\ch@seHsizeiiii{\Htm=\Htmiiii}
\def\SmallerText{\Hsmaller\edef\tmp{\csname ch@seHsize\Hta\endcsname}\tmp}

\def\hieroglyph{%
\ifvmode\leavevmode\fi%
\bgroup
\if@displayhieroglyphes%
\setbox\strutbox=\hbox{\vrule height 1\Htm depth 0.5\Htm
  width\z@}\bgroup%
\else%
\EnPetit\bgroup
\fi%
}

\def\endhieroglyph{\egroup\egroup}

\def\EnPetit#1{\bgroup
  \let\strut=\relax
  \@Smaller\relax\Htm\Htmi\relax #1\egroup}
 
\def\traittexte#1{$\stackrel{\mbox{\rm\tiny #1}}%
{\vrule width 0.05pt height 1mm}$}

\def\enrouge#1{{\setbox0=\hbox{#1}%
\dimen0=\ht0%
\advance\dimen0 by 7pt%
\raise -7pt\hbox{\vbox to \dimen0{\offinterlineskip\box0\vfil\hrule}}}}

\def\parconstruct#1#2#3{%
  \setbox0=\hbox{#3}%
  \hbox{$\left#1\box0\right#2$}}

\def\edisuperfet#1{\parconstruct{\{}{\}}{#1}}
\def\ediefface#1{\parconstruct{[}{]}{#1}}
\def\edidisparu#1{\parconstruct{\{}{\}}{#1}}
\def\ediajoutscribe#1{\parconstruct{\{}{\}}{#1}}
\def\ediajoutauteur#1{\parconstruct{\langle}{\rangle}{#1}}

\def\nouvLigne{\endhieroglyph\hieroglyph}
\def\nouvPage{\nouvLigne}

\def\EnGros{\@displayhieroglyphestrue}

\newdimen\largeur@colonne
\def\H@I@Reduction#1{%  
{\ifx\Hta\MInEx%
#1\else
\setbox0=\hbox{#1}%
\ifdim\wd0>\largeur@colonne% 
\Horizontal@Smaller
\H@I@Reduction{#1}%
\else #1\fi\fi}}

\def\EnColonne[#1]#2{{%
    \ifvmode\leavevmode\fi
    \@horizontalfalse
                                %
    \def\Aca ##1/##2/{\setbox0=\hbox{\Acv{}##1/##2\relax}%
      \ifdim\wd0>.8\Htm@\hbox{\Acv{\HtaW}##1/##2\relax}\else
      \ifdim\ht0>.5\Htm@\hbox{\Acv{\HtaH}##1/##2\relax}\else
      \hbox{\Acv{\Hta}##1/##2\relax}\fi\fi}%
                                %
    \def\Horizontal@Smaller{%
      \ifx\Hta\MInEx
      \else
      \ifnum\@HauteurW>\@Hauteur\relax
      \edef\Hta{\Hta i}\advance\@Hauteur by 1%
      \edef\HtaH{\HtaH i}\advance\@HauteurH by 1%
      \else
      \edef\HtaW{\HtaW i}\advance\@HauteurW by 1%
      \fi\fi}%
                                %
    \def\Vertical@Smaller{%
      \ifx\Hta\MInEx%
      \else
      \ifnum\@HauteurH>\@Hauteur\relax
      \edef\Hta{\Hta i}\advance\@Hauteur by 1%
      \edef\HtaW{\HtaW i}\advance\@HauteurW by 1%
      \else
      \edef\HtaH{\HtaH i}\advance\@HauteurH by 1%
      \fi\fi}%
    %
    \def\HToLine{\hskip1mm}%
    %
    \largeur@colonne=#1\relax
    %
    \def\@aligner{\relax}%
    %
    \def\horligne##1{{%
        \def\Hrp{\hskip 0.1mm plus 1fil}%
        \def\Hbt{\oldHbt}%
        \def\Hunh####1{\hbox{####1}}%
        \hbox to \largeur@colonne{\H@I@Reduction{##1}}}}%
    %
    \let\leavevmode=\relax
    \let\oldHbt=\Hbt
    \def\strut{\relax}%
    \def\Hrp{\vskip 0.5mm}% espace entre les signes
    \def\Hitmts{\vskip 0.5mm}%
    \def\Hunh##1{\hbox to \largeur@colonne{\hss ##1\hss}}%
    %
    \def\Hbt##1{{%
        \@externalfalse
        \setbox0=\vbox{\offinterlineskip ##1}%
        \wd0\largeur@colonne\relax % We force the quadra's width to be the same as the column's
        \ifdim\ht0>\Htm%
        \ifx\Hta\MInEx%
        \Himbt{##1}%
        \hbox to\largeur@colonne{\hss\box0\hss}%
        \else%
        \Vertical@Smaller
        \Hbt{##1}%
        \fi%
        \else%
        \Himbt{##1}%
        \hbox to\largeur@colonne{\hss\box0\hss}\fi}}%
    %
    \def\hieroglyph{%
      \if@displayhieroglyphes\bgroup\else\EnPetit\bgroup\fi
      \hbox to 1.1\largeur@colonne\bgroup
      \ColumnSepar\hfil\vtop\bgroup\offinterlineskip\null
      \hsize\largeur@colonne\relax}%
    %
    \def\endhieroglyph{\egroup\hfil\ColumnSepar\egroup\egroup}%
    %
    #2}}

\def\HRemplir#1#2{{%
    \dimen0=#1\relax
    \dimen2=#2\relax
    \count4=\dimen0%
    \setbox0=\hbox{\EgypS C}%
    \count2=\wd0%
                                %\ifdim\dimen0<\wd0\relax\dimen0=\wd0\relax\fi
    \ifdim\dimen2<\ht0\relax\dimen2=\ht0\relax\fi
    \divide\count4 by \count2%
    \advance\count4 by 1%
    \dimen0=\wd0%
    \multiply\dimen0 by \count4%
    \hbox{\vbox to \dimen2{\leaders\hbox to \dimen0{%
          \leaders\box0\hfill}\vfill}}}}

\def\pointrouge{\vbox to\Htm{\hbox{\EgypS o}\vfill}}
\def\pointnoir{\vbox to\Htm{\hbox{\EgypS O}\vfill}}

\def\NoRulesBetweenColumns{\def\ColumnSepar{\relax}}
\def\RulesBetweenColumns{\def\ColumnSepar{\vrule}}
\NoRulesBetweenColumns
