MAJOR=4
MINOR=31
DEVNAME=tty31
 $©    %D \module
%D   [       file=font-mat,
%D        version=2011.01.13, % (copied fron font-ini)
%D          title=\CONTEXT\ Font Macros,
%D       subtitle=Symbolic Access,
%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 / Symbolic Access}

\unprotect

%D \macros
%D   {getglyph, symbolicfont}
%D
%D Individual glyphs can be accessed by using
%D
%D \starttyping
%D \getglyph{fontname}{character}
%D \stoptyping
%D
%D This macro is used in for instance the symbol modules and as one can see, it does
%D obey the small and even smaller sizes. The \type {\symbolicfont} macro can be
%D used to switch to a font named \type {fontname} (see \type {cont-log} and \type
%D {symb-eur} for examples of symbolic definitions.

\def\v_font_string_a
  {\ifx\fontstyle\s!rm \s!Serif \orelse
   \ifx\fontstyle\s!ss \s!Sans  \orelse
   \ifx\fontstyle\s!tt \s!Mono  \else
                       \s!Serif \fi}

\def\v_font_string_b
  {\ifx\fontstyle\s!rm \s!Regular \orelse
   \ifx\fontstyle\s!ss \s!Support \orelse
   \ifx\fontstyle\s!tt \s!Type    \else
                       \s!Serif   \fi}

\def\v_font_string_c
  {\ifx\fontalternative\s!bf \s!Bold        \orelse
   \ifx\fontalternative\s!sl \s!Slanted     \orelse
   \ifx\fontalternative\s!it \s!Italic      \orelse
   \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
   \ifx\fontalternative\s!bi \s!BoldItalic  \fi}

\let\v_font_string_d\s!Serif % default fontstyle (will be redefined in type-ini)

\definefontsynonym
  [CurrentFont]
  [\noexpand\v_font_string_a\noexpand\v_font_string_c]

% potential generalization:
%
% \letvalue{\??fontfile:t:\s!rm}\s!Serif
% \letvalue{\??fontfile:t:\s!ss}\s!Sans
% \letvalue{\??fontfile:t:\s!tt}\s!Mono
%
% \letvalue{\??fontfile:a:\s!rm}\s!Regular
% \letvalue{\??fontfile:a:\s!ss}\s!Support
% \letvalue{\??fontfile:a:\s!tt}\s!Type
%
% \letvalue{\??fontfile:s:\s!bf}\s!Bold
% \letvalue{\??fontfile:s:\s!sl}\s!Slanted
% \letvalue{\??fontfile:s:\s!it}\s!Italic
% \letvalue{\??fontfile:s:\s!bs}\s!BoldSlanted
% \letvalue{\??fontfile:s:\s!bi}\s!BoldItalic
%
% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
% \def\v_font_string_a{\executeifdefined{\??fontfile:t:\fontstyle}\s!Serif}
% \def\v_font_string_b{\executeifdefined{\??fontfile:a:\fontstyle}\s!Serif}
% \def\v_font_string_c{\executeifdefined{\??fontfile:s:\fontstyle}\empty}
% \def\v_font_string_d{\executeifdefined{\??fontfile:t:\csname\??typescriptdefaultstyles\fontclass\endcsname}\s!Serif}

%D \macros
%D   {fontstylesuffix}
%D
%D The next macro is used to map non latin fontnames on fonts. See \type
%D {font-uni} for an example of its use.

% \frozen ...

\permanent\def\fontstylesuffix% why the \s!Regular ? see \getglyph
  {\ifx\fontalternative\s!tf     \s!Regular \orelse
   \ifx\fontalternative\s!bf        \s!Bold \orelse
   \ifx\fontalternative\s!sl     \s!Slanted \orelse
   \ifx\fontalternative\s!it      \s!Italic \orelse
   \ifx\fontalternative\s!bs \s!BoldSlanted \orelse
   \ifx\fontalternative\s!bi  \s!BoldItalic \orelse
   \ifx\fontalternative\s!sc        \s!Caps \else
                                 \s!Regular \fi}

\permanent\def\glyphfontfile#base% appends
  {#base%
   \ifcsname\??fontfile#base\v_font_string_a\v_font_string_c\endcsname
     \v_font_string_a\v_font_string_c
   \orelse\ifcsname\??fontfile#base\v_font_string_b\v_font_string_c\endcsname
     \v_font_string_b\v_font_string_c
   \orelse\ifcsname\??fontfile#base\v_font_string_a\endcsname
     \v_font_string_a
   \orelse\ifcsname\??fontfile#base\v_font_string_b\endcsname
     \v_font_string_b
   \orelse\ifcsname\??fontfile#base\v_font_string_c\endcsname
     \v_font_string_c
   \fi}

%D The next macro can be used to make decisions based on the shape:

\permanent\def\doifelseitalic#yes#nop%
  {\ifx\fontalternative\s!sl#yes\orelse
   \ifx\fontalternat