%D \module
%D   [       file=font-var,
%D        version=2011.01.13, % (copied fron font-ini)
%D          title=\CONTEXT\ Font Macros,
%D       subtitle=Common Variables,
%D         author=Hans 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 Font Macros / Common Variables}

\unprotect

% some more will move here

%D \macros
%D   {fontstyle,fontalternative,fontsize,fontbody}
%D
%D Within a bodyfont, fonts can come in different sizes. For instance \type {\tf} is
%D accompanied by \type {\tfa}, \type {\tfb} etc. The first two characters denote
%D the alternative, while the third character in these sequences represents the
%D size. The actual size is saved in a macro. The styles, being roman (\type {\rm}),
%D sans serif (\type {\ss}) etc. are also available.

% fontclass       % modern dejavu
% fontbody        % ... 10pt 11pt 12pt ...
% fontstyle       % rm ss tt mm hw cg ...
% fontalternative % tf bf sl it bs bi sc ...
% fontsize        % a b c d ...
% fontface        % 0=normal 1=text 2=script 3=scriptscript 4=x 5=xx (math are temporary)

\mutable  \def\normalizedbodyfontsize{12pt}
\permanent\def\defaultfontbody       {\normalizedbodyfontsize}
\aliased  \let\defaultfontstyle      \s!rm
\aliased  \let\defaultfontalternative\s!tf
\aliased  \let\defaultfontface       \!!zerocount

% This one is never set so can't this go? It's used in a hash but then we
% we get two -- in row:

\permanent\lettonothing\defaultfontsize

% So maybe we can just remove it there or define it as:
%
% \permanent\cdef\defaultfontsize{*}

\mutable\let\fontbody       \defaultfontbody
\mutable\let\fontstyle      \defaultfontstyle
\mutable\let\fontalternative\defaultfontalternative
\mutable\let\fontsize       \defaultfontsize
\mutable\let\fontface       \!!zerocount

\mutable\lettonothing\globalfontclass
\mutable\lettonothing\fontclass

\installmacrostack\fontstyle

% we can use an indirect mapping for fontclasses (map string onto numbers) and indeed this
% is somewhat more efficient but also makes the code messy ... maybe some day ...

\newtoks\everycompactfontmode

\newconditional\c_font_compact

\appendtoks
    \c_font_compact\conditionaltrue
\to \everycompactfontmode

\protected\def\font_enable_compact_font_mode
  {\ifcase\currentgrouplevel
     \expand\everycompactfontmode
     \global\everycompactfontmode\emptytoks
     \glettonothing\font_enable_compact_font_mode
     %writestatus\m!fonts\empty
     %writestatus\m!fonts{compact font mode enabled}%
     %writestatus\m!fonts\empty
   \else
     \font_ignore_compact_font_mode
     \font_enable_compact_font_mode
   \fi}

\protected\def\font_ignore_compact_font_mode
  {\gdef\font_enable_compact_font_mode
     {%writestatus\m!fonts\empty
      %writestatus\m!fonts{compact font mode cannot be enabled}%
      %writestatus\m!fonts\empty
      \glettonothing\font_enable_compact_font_mode
      \glettonothing\font_ignore_compact_font_mode}}

\installtexexperiment
  {fonts.compact}
  {\font_enable_compact_font_mode}
  {}

\protect \endinput
