%%% aat-info.tex %%%
% By Jonathan Kew
%
% Prints XeTeX font features for a font
% using the "AAT" renderer of XeTeX;
% requires Mac OS X.
%
% See 'opentype-info.tex' for the equivalent
% functionality with OpenType fonts.
%
% Usage:
%   Type the name of the font below and compile this 
%   document with plain `xetex` to receive a listing
%   of the AAT font features supported by the chosen font.
%
% AAT-info is distributed under the Apache License v2: 
%   <http://www.apache.org/licenses/LICENSE-2.0.html>
%
%%%%%%%%%%%%%%%%%%%%
%
% Select the font name:
\def\myfontname{Hoefler Text}
%
%%% AAT-info.tex %%%


\font\testfont="\myfontname/AAT" at 10pt
\nopagenumbers

\baselineskip=14pt
\font\tenrm="Lucida Grande" at 10pt \tenrm
\font\title="Lucida Grande Bold" at 12pt

\font\sym="Apple Symbols" at 11pt
\def\radioOff{{\sym ^^^^25cb}}
\def\radioOn{{\sym ^^^^25c9}}
\def\checkOff{{\sym ^^^^2610}}
\def\checkOn{{\sym ^^^^2612}}

\newcount\nf
\newcount\f \newcount\fc
\newcount\ns
\newcount\s \newcount\sc
\nf=\XeTeXcountfeatures\testfont
\noindent {\title AAT features in ‘\myfontname’}\nobreak\medskip
\ifnum\nf>0
  \loop
    \fc=\XeTeXfeaturecode\testfont\f
    \noindent \XeTeXfeaturename\testfont\fc\ [\number\fc]
    \endgraf
    \ns=\XeTeXcountselectors\testfont\fc
    {
      \loop
      \sc=\XeTeXselectorcode\testfont\fc\s
      \textindent{%
        \ifnum\XeTeXisexclusivefeature\testfont\fc>0
          \ifnum\XeTeXisdefaultselector\testfont\fc\sc>0 \radioOn \else \radioOff \fi
        \else
          \ifnum\XeTeXisdefaultselector\testfont\fc\sc>0 \checkOn \else \checkOff \fi
        \fi
      }\XeTeXselectorname\testfont\fc\sc\ [\number\sc]
      \endgraf
      \advance\s by 1 \ifnum\s<\ns \repeat
    }
    \smallskip
  \advance\f by 1 \ifnum\f<\nf \repeat
\else
  \noindent {No AAT features available}\par
\fi

\bigskip

\newcount\val
\def\appendint{\count255=\val \divide\count255 by 65536
 \edef\decval{\decval\number\count255}\multiply\count255 by 65536
 \advance\val by -\count255 }
\def\decimalize#1{\val=#1 \def\decval{}\appendint \edef\decval{\decval.}%
 \multiply\val by 10 \appendint \multiply\val by 10 \appendint
 \multiply\val by 10 \appendint \multiply\val by 10 \appendint
 \multiply\val by 10 \appendint \multiply\val by 10 \appendint}
\def\decnum{\afterassignment\printdec \count255=}
\def\printdec{\dimen255=\count255 sp \expandafter\noPT\the\dimen255 }
{\catcode`\p=12 \catcode`\t=12 \gdef\noPT#1pt{#1}}
\newcount\nv
\newcount\v \newcount\vc
\nv=\XeTeXcountvariations\testfont
\noindent {\title AAT variation axes in \myfontname:}\nobreak\medskip
\ifnum\nv>0
  \loop
    \vc=\XeTeXvariation\testfont\v
    \noindent \XeTeXvariationname\testfont\vc
    \endgraf
    \indent Range:\ 
      {\decimalize{\XeTeXvariationmin\testfont\vc}%
       \font\x="\myfontname:\XeTeXvariationname\testfont\vc=\decval" at 10pt
       \x min \decnum\XeTeXvariationmin\testfont\vc}%
      \ …\ 
      {\decimalize{\XeTeXvariationmax\testfont\vc}%
       \font\x="\myfontname:\XeTeXvariationname\testfont\vc=\decval" at 10pt
       \x max \decnum\XeTeXvariationmax\testfont\vc}%
      \ \ 
      {\font\x="\myfontname" at 10pt
       \x (default:\ \decnum\XeTeXvariationdefault\testfont\vc)}%
      \endgraf
    \smallskip
  \advance\v by 1 \ifnum\v<\nv \repeat
\else
  \noindent {No AAT variations available}\par
\fi

\bigskip

\newcount\ng
\newcount\g \newcount\step
\ng=\XeTeXcountglyphs\testfont
\noindent{\title \myfontname\ contains \number\ng\ glyphs}
\nobreak\medskip
\step=\ng \divide\step by 25
\noindent
  \loop \advance\g by \step
    \ifnum\g<\ng {\testfont\XeTeXglyph\g} \repeat

\end
