%D \module
%D   [       file=type-imp-ebgaramond,
%D        version=2013.06.22,
%D          title=\CONTEXT\ Typescript Macros,
%D       subtitle=EB Garamond,
%D         author=Mikael Sundqvist & 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.

% Why so many features ... dead slow too. Anyway, we support it but also keep
% supporting the two design sizes.

% renewed:
%
% Regular
% Italic
% Medium
% MediumItalic
% SemiBold
% SemiBoldItalic
% Bold
% BoldItalic
% ExtraBold
% ExtraBoldItalic

\definefontfeature
  [eb-garamond-normal]
  [default]
  [mode=node,
   ccmp=yes,
   calt=yes,
   dlig=no,
   hlig=no,
 % salt=yes,
 % onum=yes,
   onum=no,
   pnum=yes,
   script=latn]

\definefontfeature
  [eb-garamond-smallcaps]
  [eb-garamond-normal]
  [smcp=yes,c2sc=yes]

\definefontfeature
  [ysabeau-smallcaps]
  [default]
  [smcp=yes,c2sc=yes]

% \loadtypescriptfile[ebgaramond]
%
% \definefontfeature
%   [eb-garamond-normal]
%   [eb-garamond-normal]
%   [dlig=no,hlig=no]
%
% \setupbodyfont[ebgaramond]
%
% \starttext
%     No weird over the top ligatures.
% \stoptext

\starttypescriptcollection[ebgaramond]

  % \pushglobalsetups
  %     \startsetups[ebgaramond]
  %       % \setmathfenceparameter   \c!alternative{1}%
  %     \stopsetups
  % \popglobalsetups

    \doifunknownfontfeature {ebgaramond-math-bold} {\definefontfeature[ebgaramond-math-bold][boldened]}

    \starttypescript [\s!serif] [ebgaramond,ebgaramond-nt]
        \setups[font:fallback:serif]
        \definefontsynonym [\s!Serif]          [\s!file:ebgaramond-regular]   [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifItalic]    [\s!file:ebgaramond-italic]    [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBold]      [\s!file:ebgaramond-bold]      [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBoldItalic][\s!file:ebgaramond-bolditalic][\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifCaps]      [\s!Serif]                     [\s!features=eb-garamond-smallcaps]
    \stoptypescript

    \starttypescript [\s!serif] [ebgaramond-eight]
        \setups[font:fallback:serif]
        \definefontsynonym [\s!Serif]          [\s!file:ebgaramond08-regular] [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifItalic]    [\s!file:ebgaramond08-italic]  [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBold]      [\s!file:ebgaramond-bold]      [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBoldItalic][\s!file:ebgaramond-bolditalic][\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifCaps]      [\s!Serif]                     [\s!features=eb-garamond-smallcaps]
    \stoptypescript

    \starttypescript [\s!serif] [ebgaramond-twelve]
        \setups[font:fallback:serif]
        \definefontsynonym [\s!Serif]          [\s!file:ebgaramond12-regular] [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifItalic]    [\s!file:ebgaramond12-italic]  [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBold]      [\s!file:ebgaramond-bold]      [\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifBoldItalic][\s!file:ebgaramond-bolditalic][\s!features=eb-garamond-normal,\s!goodies=ebgaramond-text]
        \definefontsynonym [\s!SerifCaps]      [\s!Serif]                     [\s!features=eb-garamond-smallcaps]
    \stoptypescript

    \starttypescript [\s!sans] [ysabeau]
        % \setups[font:fallback:sans]
        \definefontsynonym [\s!Sans]          [\s!file:ysabeau-regular]       [\s!features=\s!default]
        \definefontsynonym [\s!SansItalic]    [\s!file:ysabeau-italic]        [\s!features=\s!default]
        \definefontsynonym [\s!SansBold]      [\s!file:ysabeau-bold]          [\s!features=\s!default]
        \definefontsynonym [\s!SansBoldItalic][\s!file:ysabeau-bolditalic]    [\s!features=\s!default]
        \definefontsynonym [\s!SansCaps]      [\s!Sans]                       [\s!features=ysabeau-smallcaps]
     \stoptypescript

    \starttypescript [\s!math] [ebgaramond,ebgaramond-nt,ebgaramond-eight,ebgaramond-twelve]
        \checkedmapfontsize[\typescripttwo][\s!script]      [.70]
        \checkedmapfontsize[\typescripttwo][\s!scriptscript][.50]
    \stoptypescript

    \starttypescript [\s!math] [ebgaramond,ebgaramond-eight,ebgaramond-twelve] [\s!name]
        \definefontsynonym [\s!MathRoman]     [\s!file:garamond-math.otf] [\s!features={\s!math\mathsizesuffix,ebgaramond:mathextra,mathextra},\s!goodies=ebgaramond-math]
        \definefontsynonym [\s!MathRomanBold] [\s!file:garamond-math.otf] [\s!features={\s!math\mathsizesuffix,ebgaramond-math-bold,ebgaramond:mathextra,mathextra},\s!goodies=ebgaramond-math]
    \stoptypescript

    \starttypescript [\s!math] [ebgaramond-nt] [\s!name]
        \definefontsynonym [\s!MathRoman]     [\s!file:garamond-math.otf] [\s!features={\s!math\mathsizesuffix,ebgaramond:mathextra,mathextra}]
        \definefontsynonym [\s!MathRomanBold] [\s!file:garamond-math.otf] [\s!features={\s!math\mathsizesuffix,ebgaramond-math-bold,ebgaramond:mathextra,mathextra}]
    \stoptypescript

    \starttypescript[ebgaramond,ebgaramond-nt,ebgaramond-eight,ebgaramond-twelve]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [ysabeau]        [\s!default]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [dejavu]         [\s!default] [\s!rscale=0.8]
      % \definetypeface [\typescriptone] [\s!mm] [\s!math]  [bonum]          [\s!default] [\s!rscale=0.8]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [\typescriptone] [\s!default]
    \stoptypescript

\stoptypescriptcollection
