%D \module
%D   [       file=cont-log,
%D        version=1995.10.10,
%D          title=\CONTEXT\ Miscellaneous Macros,
%D       subtitle=\TEX\ Logos,
%D         author=J. Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt TeX Logos}

%D The system that is used to typeset this text is called \TEX, typeset with an
%D lowered~E. From te beginning of \TEX, authors of macro packages adapted this
%D raising and lowering style. In this module we define some of those logos.

\unprotect

\unexpanded\def\TeX
  {\dontleavehmode
   \begingroup
   T%
   \setbox\scratchbox\hbox{M}%
   \kern-.1667\wd\scratchbox
   \lower.5\exheight\hbox{E}%
   \kern-.125\wd\scratchbox
   X%
   \endgroup}

\unexpanded\def\TeXsuffix{\wordboundary\TeX}
\unexpanded\def\TeXprefix{\TeX\wordboundary}

\unexpanded\def\ConTeXt
  {\dontleavehmode
   \begingroup
   Con%
   \wordboundary
   \setbox\scratchboxone\hbox{T\kern\zeropoint e}%
   \setbox\scratchboxtwo\hbox{Te}%
   \discretionary{-}{}{\kern\dimexpr\wd\scratchboxtwo-\wd\scratchboxone\relax}%
   \TeX t%
   \endgroup}

\unexpanded\def\PPCHTeX{ppch\TeX}
\unexpanded\def\PRAGMA {Pragma ADE}

\unexpanded\def\LaTeX % requested by erik frambach
  {\dontleavehmode
   \begingroup
   \setbox\scratchbox\hbox{L}%
   \scratchdimen\ht\scratchbox
   \setbox\scratchbox\hbox{\doresetattribute{case}\txx A}%
   L\kern-.55\wd\scratchbox
   \raise\scratchdimen\hbox{\lower\ht\scratchbox\copy\scratchbox}%
   \kern-.2\wd\scratchbox\TeX
   \endgroup}

\unexpanded\def\TaBlE
  {T%
   \kern-.27\emwidth\lower.5\exheight\hbox{A}%
   \kern-.18\emwidth B%
   \kern-.1\emwidth\lower.5\exheight\hbox{L}%
   \kern-.075\emwidth E}

\unexpanded\def\PiCTeX
  {P%
   \kern-.12\emwidth\lower.5\exheight\hbox{I}%
   \kern-.075\emwidth C%
   \kern-.11\emwidth\TeX}

\def\syst_logos_ams_script#1%
  {\normalstartimath
   \cal\ifdim\bodyfontsize>1.1\emwidth\scriptstyle\fi#1%
   \normalstopimath}

\unexpanded\def\AmSTeX
  {\dontleavehmode
   \syst_logos_ams_script A%
   \kern-.1667\emwidth\lower.5\exheight\hbox{\syst_logos_ams_script M}%
   \kern-.125\emwidth\syst_logos_ams_script S%
   -\TeX}

\unexpanded\def\LamSTeX
  {L%
   \kern-.4\emwidth\raise.3\exheight\hbox{\syst_logos_ams_script A}%
   \kern-.25\emwidth\lower.4\exheight\hbox{\syst_logos_ams_script M}%
   \kern-.1\emwidth{\syst_logos_ams_script S}%
   -\TeX}

% \unexpanded\def\AmSLaTeX
%   {\dontleavehmode
%    \syst_logos_ams_script A%
%    \kern-.1667\emwidth\lower.5\exheight\hbox{\syst_logos_ams_script M}%
%    \kern-.125\emwidth{\syst_logos_ams_script S}%
%    -\LaTeX}

%D Alternative \CONTEXT\ logo, first Idris S.~Hamid's version:
%D
%D \def\Context
%D   {{\sc C\kern -.0667emo\kern -.0667emn\kern -.0549emt\kern
%D    -.1667em\lower.5ex\hbox {e}\kern -.125emx\kern -.0549emt}}
%D
%D I changed this into one that adapts itself:

\unexpanded\def\Context % wrong usage of \getscaledglyph
  {\dontleavehmode
   \begingroup
   C%
   \kern -.0667\emwidth
   \getscaledglyph{.8}\empty{%
     O\kern-.0667\emwidth
     N%
     \discretionary{-}{}{\kern-.0549\emwidth}%
     T%
     \doifelseitalic
       {\kern-.1\emwidth}%
       {\kern-.1667\emwidth}%
     \lower.5\exheight\hbox{E}%
     \doifelseitalic
       \empty
       {\kern-.11em}%
     X%
     \kern-.055\emwidth
     T%
   }%
   \endgroup}

%D The \METAFONT\ and \METAPOST\ logos adapt themselves to the current fontsize, an
%D ugly but usefull hack.

\let\logofont\nullfont

% \loadmapfile[original-base.map] % stil needed? not if we assume afm

\unexpanded\def\setMFPfont% more sensitive for low level changes
  {\font\logofont=logo%
     \ifx\fontalternative\s!bf\s!bf\else
     \ifx\fontalternative\s!it\s!sl\else
     \ifx\fontalternative\s!sl\s!sl\else
     \ifx\fontalternative\s!bi\s!bf\else
     \ifx\fontalternative\s!bs\s!bf\else
     \fi\fi\fi\fi\fi
     10 at \currentfontscale\bodyfontsize % there is no afm in the minimals yet
   \logofont}

\def\syst_logos_meta_hyphen % there is no hyphenchar in this font
  {\discretionary{\vrule\s!height.33\emwidth\s!depth-.27\emwidth\s!width.33\emwidth}{}{}}

\unexpanded\def\MetaFontLogo
  {\dontleavehmode
   \begingroup
   \setMFPfont META\syst_logos_meta_hyphen FONT%
   \endgroup}

\unexpanded\def\MetaPostLogo
  {\dontleavehmode
   \begingroup
   \setMFPfont META\syst_logos_meta_hyphen POST%
   \endgroup}

% \protected\def\MetaFunLogo
%   {\dontleavehmode
%    \begingroup
%    \setMFPfont META\syst_logos_meta_hyphen FUN%
%    \endgroup}

% As decided on the ConText Meeting 2013 the logo has been simplified:

\unexpanded\def\MetaFont{MetaFont}
\unexpanded\def\MetaPost{MetaPost}
\unexpanded\def\MetaFun {MetaFun}

%D \macros
%D  {TEX, METAFONT, METAPOST, METAFUN,
%D   PICTEX, TABLE,
%D   CONTEXT, PPCHTEX,
%D   AMSTEX, LATEX, LAMSTEX}
%D
%D We define the funny written ones as well as the less error prone upper case names
%D (in \CONTEXT\ we tend to write all user defined commands, like abbreviations, in
%D uppercase.)

\unexpanded\def\METAFONT {\MetaFont}
\unexpanded\def\METAPOST {\MetaPost}
\unexpanded\def\PPCHTEX  {\PPCHTeX}
\unexpanded\def\CONTEXT  {\ConTeXt}
\unexpanded\def\METAFUN  {\MetaFun}

\unexpanded\def\TEX      {\TeX}
\unexpanded\def\LATEX    {\LaTeX}
\unexpanded\def\PICTEX   {\PiCTeX}
\unexpanded\def\TABLE    {\TaBlE}
\unexpanded\def\AMSTEX   {\AmSTeX}
\unexpanded\def\LAMSTEX  {\LamSTeX}
\unexpanded\def\INRSTEX  {inrs\TeX}

%D And this is how they show up: \TeX, \MetaFont, \MetaPost, \PiCTeX, \TaBlE, \ConTeXt,
%D \PPCHTeX, \AmSTeX, \LaTeX, \LamSTeX.

%D Some placeholders:

\unexpanded\def\eTeX      {\mathematics{\varepsilon}-\TeX}
\unexpanded\def\pdfTeX    {pdf\wordboundary\TeX}
\unexpanded\def\pdfeTeX   {pdfe-\wordboundary\TeX}
\unexpanded\def\luaTeX    {lua\wordboundary\TeX}
\unexpanded\def\Lua       {Lua}
\unexpanded\def\LUA       {\Lua}
\unexpanded\def\luajitTeX {lua\wordboundary jit\wordboundary\TeX}
\unexpanded\def\luametaTeX{lua\wordboundary meta\wordboundary\TeX}
%unexpanded\def\XeTeX     {X\lower.5\exheight\hbox{\kern-.15\emwidth\mirror{E}}\kern-.1667\emwidth\TeX}

% Adapted from a patch by Mojca:

\def\syst_logos_xetex_e
  {\setbox\scratchbox\hbox{E}%
   \raise\dimexpr\ht\scratchbox+\dp\scratchbox\relax\hbox{\rotate[\c!rotation=180]{\box\scratchbox}}}

\unexpanded\def\XeTeX
  {X\lower.5\exheight
   \hbox
     {\kern-.15\emwidth
      \iffontchar\font"018E\relax
        \char"018E%
      \else
        \ifx\fontalternative\s!bf         \mirror{E}\else
        \ifx\fontalternative\s!it\syst_logos_xetex_e\else
        \ifx\fontalternative\s!sl\syst_logos_xetex_e\else
        \ifx\fontalternative\s!bi\syst_logos_xetex_e\else
        \ifx\fontalternative\s!bs\syst_logos_xetex_e\else
                                          \mirror{E}\fi\fi\fi\fi\fi
      \fi}%
   \kern-.1667\emwidth\TeX}

\let\ETEX      \eTeX
\let\PDFTEX    \pdfTeX
\let\PDFETEX   \pdfeTeX
\let\LUATEX    \luaTeX
\let\LUAJITTEX \luajitTeX
\let\LuaTeX    \luaTeX
\let\LuaMetaTeX\luametaTeX
\let\LUAMETATEX\luametaTeX
\let\XETEX     \XeTeX

\unexpanded\def\LuaTeX
  {\dontleavehmode
   \begingroup
     Lua%
     % hope for kerning, try aT
     \setbox0\hbox{aT}%
     \setbox2\hbox{a\kern\zeropoint T}%
     \ifdim\wd0=\wd2 % kerns can go two ways
       % no aT kerning, try oT as a is not symmetrical
       \setbox0\hbox{oT}%
       \setbox2\hbox{o\kern\zeropoint T}%
       \ifdim\wd0=\wd2 % kerns can go two ways
         % no aT and oT kerning, try To
         \setbox0\hbox{To}%
         \setbox2\hbox{T\kern\zeropoint o}%
         % maybe we need to compensate for the angle (sl/it/bs/bi)
       \fi
       \ifdim\wd0=\wd2\else
         \kern\dimexpr\wd0-\wd2\relax
       \fi
     \fi
     \TeX
   \endgroup}

\unexpanded\def\LuajitTeX
  {\dontleavehmode
   \begingroup
     % at this moment there is no real need for kerning tT
     Luajit\kern\zeropoint\TeX
   \endgroup}

\let\luaTeX   \LuaTeX
\let\luajitTeX\LuajitTeX
\let\LUATEX   \LuaTeX
\let\LUAJITTEX\LuajitTeX

\unexpanded\def\MKII{MkII} % MarkTwo
\unexpanded\def\MKIV{MkIV} % MarkFour   : MKIV
\unexpanded\def\MKVI{MkVI} % MarkSix    : MKIV
\unexpanded\def\MKXL{MkXL} % MarkFourty : LMTX
\unexpanded\def\MKLX{MkLX} % MarkSixty  : LMTX
\unexpanded\def\MKIX{MkIX} %            : MKIV / LMTX
\unexpanded\def\MKXI{MkXI} %            : MKIV / LMTX

\unexpanded\def\MPII{MpII} % MarkTwo
\unexpanded\def\MPIV{MpIV} % MarkFour   : MetaFun
\unexpanded\def\MPVI{MpVI} % MarkSix    : MetaFun
\unexpanded\def\MPXL{MpXL} % MarkFourty : LuaMetaFun
\unexpanded\def\MPLX{MpLX} % MarkSixty  : LuaMetaFun

\unexpanded\def\LMTX{LMTX} % for LuaMetaTeX

\appendtoks
    \def\ConTeXt   {ConTeXt}%
    \def\MetaPost  {MetaPost}%
    \def\MetaFont  {MetaFont}%
    \def\MetaFun   {MetaFun}%
    \def\TeX       {TeX}%
    \def\TeXsuffix {TeX}%
    \def\TeXprefix {TeX}%
    \def\LuaTeX    {LuaTeX}%
    \def\LuajitTeX {LuajitTeX}%
    \def\LuaMetaTeX{LuaMetaTeX}%
   %\let\wordboundary\empty % primitive so we need to promote it to frozen (orjust preroll)
\to \everysimplifycommands

\protect \endinput

