%D \module
%D   [       file=type-imp-texgyre,
%D        version=2007.07.30,
%D          title=\CONTEXT\ Typescript Macros,
%D       subtitle=\TEX Gyre Fonts,
%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.

%D There are some weird ones that are never used .. all these Caps ... we can better
%D split them into pagella-caps etc.

\definefontfeature
  [mathcollapseitalics]
  [collapseitalics=yes]

\starttypescriptcollection[texgyre]

    \doifunknownfontfeature {pagella-math-bold} {\definefontfeature[pagella-math-bold][boldened]}
    \doifunknownfontfeature {schola-math-bold}  {\definefontfeature[schola-math-bold] [boldened]}
    \doifunknownfontfeature {bonum-math-bold}   {\definefontfeature[bonum-math-bold]  [boldened]}
    \doifunknownfontfeature {termes-math-bold}  {\definefontfeature[termes-math-bold] [boldened]}

    \definetypescriptprefix [f:pagella] [pagella]
    \definetypescriptprefix [f:termes]  [termes]
    \definetypescriptprefix [f:heros]   [heros]
    \definetypescriptprefix [f:bonum]   [bonum]
    \definetypescriptprefix [f:schola]  [schola]
    \definetypescriptprefix [f:adventor][adventor]
    \definetypescriptprefix [f:cursor]  [cursor]
    \definetypescriptprefix [f:chorus]  [chorus]

    \definetypescriptprefix [f:palatino]   [pagella]
    \definetypescriptprefix [f:times]      [termes]
    \definetypescriptprefix [f:helvetica]  [heros]
    \definetypescriptprefix [f:bookman]    [bonum]
    \definetypescriptprefix [f:schoolbook] [schola]
    \definetypescriptprefix [f:avantgarde] [adventor]
    \definetypescriptprefix [f:courier]    [cursor]
    \definetypescriptprefix [f:chancery]   [chorus]

    \definetypescriptprefix [n:pagella]  [TeXGyrePagella]
    \definetypescriptprefix [n:termes]   [TeXGyreTermes]
    \definetypescriptprefix [n:heros]    [TeXGyreHeros]
    \definetypescriptprefix [n:bonum]    [TeXGyreBonum]
    \definetypescriptprefix [n:schola]   [TeXGyreSchola]
    \definetypescriptprefix [n:adventor] [TeXGyreAdventor]
    \definetypescriptprefix [n:cursor]   [TeXGyreCursor]
    \definetypescriptprefix [n:chorus]   [TeXGyreChorus]

    \definetypescriptprefix [n:palatino]   [TeXGyrePagella]
    \definetypescriptprefix [n:times]      [TeXGyreTermes]
    \definetypescriptprefix [n:helvetica]  [TeXGyreHeros]
    \definetypescriptprefix [n:bookman]    [TeXGyreBonum]
    \definetypescriptprefix [n:schoolbook] [TeXGyreSchola]
    \definetypescriptprefix [n:adventor]   [TeXGyreAdventor]
    \definetypescriptprefix [n:courier]    [TeXGyreCursor]
    \definetypescriptprefix [n:chancery]   [TeXGyreChorus]

    \starttypescript [\s!serif,\s!sans] [adventor,bonum,bookman,heros,helvetica,pagella,palatino,schola,schoolbook,termes,times]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Regular]        [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-regular]    [\s!features=\s!default]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Italic]         [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-italic]     [\s!features=\s!default]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Bold]           [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bold]       [\s!features=\s!default]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-BoldItalic]     [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bolditalic] [\s!features=\s!default]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Caps]           [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-regular]    [\s!features=\s!smallcaps]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-ItalicCaps]     [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-italic]     [\s!features=\s!smallcaps]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-BoldCaps]       [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bold]       [\s!features=\s!smallcaps]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-BoldItalicCaps] [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bolditalic] [\s!features=\s!smallcaps]
    \stoptypescript

    \starttypescript [\s!mono] [cursor,courier]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Regular]        [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-regular]    [\s!features=\s!none]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Italic]         [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-italic]     [\s!features=\s!none]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-Bold]           [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bold]       [\s!features=\s!none]
        \definefontsynonym [\typescriptprefix{n:\typescripttwo}-BoldItalic]     [\s!file:texgyre\typescriptprefix{f:\typescripttwo}-bolditalic] [\s!features=\s!none]
    \stoptypescript

    \starttypescript [\s!serif,\s!calligraphy] [chorus,chancery]
        \definefontsynonym [TeXGyreChorus-MediumItalic] [\s!file:texgyrechorus-mediumitalic] [\s!features=\s!default]
    \stoptypescript

    \starttypescript [\s!serif] [pagella,palatino,termes,times,bonum,bookman,schola,schoolbook] [\s!name]
        \definefontsynonym [\s!Serif]             [\typescriptprefix{n:\typescripttwo}-Regular]
        \definefontsynonym [\s!SerifItalic]       [\typescriptprefix{n:\typescripttwo}-Italic]
        \definefontsynonym [\s!SerifBold]         [\typescriptprefix{n:\typescripttwo}-Bold]
        \definefontsynonym [\s!SerifBoldItalic]   [\typescriptprefix{n:\typescripttwo}-BoldItalic]
        \definefontsynonym [\s!SerifSlanted]      [\s!SerifItalic]
        \definefontsynonym [\s!SerifBoldSlanted]  [\s!SerifBoldItalic]
        \definefontsynonym [\s!SerifCaps]         [\typescriptprefix{n:\typescripttwo}-Caps]
    \stoptypescript

    \starttypescript [\s!serif] [pagella-caps,palatino-caps,termes-caps,times-caps,bonum-caps,bookman-caps,schola-caps,schoolbook-caps] [\s!name]
        \definefontsynonym [\s!Serif]             [\typescriptprefix{n:\typescripttwo}-Caps]
        \definefontsynonym [\s!SerifItalic]       [\typescriptprefix{n:\typescripttwo}-ItalicCaps]
        \definefontsynonym [\s!SerifBold]         [\typescriptprefix{n:\typescripttwo}-BoldCaps]
        \definefontsynonym [\s!SerifBoldItalic]   [\typescriptprefix{n:\typescripttwo}-BoldItalicCaps]
        \definefontsynonym [\s!SerifSlanted]      [\s!SerifItalic]
        \definefontsynonym [\s!SerifBoldSlanted]  [\s!SerifBoldItalic]
    \stoptypescript

    \starttypescript [\s!serif] [chorus,chancery] [\s!name]
        \definefontsynonym [\s!Serif]            [TeXGyreChorus-MediumItalic]
        \definefontsynonym [\s!SerifItalic]      [\s!Serif]
        \definefontsynonym [\s!SerifBold]        [\s!Serif]
        \definefontsynonym [\s!SerifBoldItalic]  [\s!Serif]
        \definefontsynonym [\s!SerifSlanted]     [\s!Serif]
        \definefontsynonym [\s!SerifBoldSlanted] [\s!Serif]
        \definefontsynonym [\s!SerifCaps]        [\s!Serif]
    \stoptypescript

    \starttypescript [\s!calligraphy] [chorus,chancery] [\s!name]
        \definefontsynonym [Calligraphy] [TeXGyreChorus-MediumItalic]
    \stoptypescript

    \starttypescript [\s!sans] [heros,helvetica,adventor] [\s!name]
        \definefontsynonym [\s!Sans]            [\typescriptprefix{n:\typescripttwo}-Regular]
        \definefontsynonym [\s!SansItalic]      [\typescriptprefix{n:\typescripttwo}-Italic]
        \definefontsynonym [\s!SansBold]        [\typescriptprefix{n:\typescripttwo}-Bold]
        \definefontsynonym [\s!SansBoldItalic]  [\typescriptprefix{n:\typescripttwo}-BoldItalic]
        \definefontsynonym [\s!SansSlanted]     [\s!SansItalic]
        \definefontsynonym [\s!SansBoldSlanted] [\s!SansBoldItalic]
        \definefontsynonym [\s!SansCaps]        [\typescriptprefix{n:\typescripttwo}-Caps]
    \stoptypescript

    \starttypescript [\s!sans] [heros-caps,helvetica-caps,adventor-caps] [\s!name]
        \definefontsynonym [\s!Sans]            [\typescriptprefix{n:\typescripttwo}-Caps]
        \definefontsynonym [\s!SansItalic]      [\typescriptprefix{n:\typescripttwo}-ItalicCaps]
        \definefontsynonym [\s!SansBold]        [\typescriptprefix{n:\typescripttwo}-BoldCaps]
        \definefontsynonym [\s!SansBoldItalic]  [\typescriptprefix{n:\typescripttwo}-BoldItalicCaps]
        \definefontsynonym [\s!SansSlanted]     [\s!SansItalic]
        \definefontsynonym [\s!SansBoldSlanted] [\s!SansBoldItalic]
    \stoptypescript

    \starttypescript [\s!mono] [cursor,courier] [\s!name]
        \definefontsynonym [\s!Mono]             [\typescriptprefix{n:\typescripttwo}-Regular]
        \definefontsynonym [\s!MonoItalic]       [\typescriptprefix{n:\typescripttwo}-Italic]
        \definefontsynonym [\s!MonoBold]         [\typescriptprefix{n:\typescripttwo}-Bold]
        \definefontsynonym [\s!MonoBoldItalic]   [\typescriptprefix{n:\typescripttwo}-BoldItalic]
        \definefontsynonym [\s!MonoSlanted]      [\s!MonoItalic]
        \definefontsynonym [\s!MonoBoldSlanted]  [\s!MonoBoldItalic]
        \definefontsynonym [\s!MonoCaps]         [\typescriptprefix{n:\typescripttwo}-Caps]
    \stoptypescript

    \starttypescript [\s!mono] [cursor-caps,courier-caps] [\s!name]
        \definefontsynonym [\s!Mono]            [\typescriptprefix{n:\typescripttwo}-Caps]
        \definefontsynonym [\s!MonoItalic]      [\typescriptprefix{n:\typescripttwo}-ItalicCaps]
        \definefontsynonym [\s!MonoBold]        [\typescriptprefix{n:\typescripttwo}-BoldCaps]
        \definefontsynonym [\s!MonoBoldItalic]  [\typescriptprefix{n:\typescripttwo}-BoldItalicCaps]
        \definefontsynonym [\s!MonoSlanted]     [\s!MonoItalic]
        \definefontsynonym [\s!MonoBoldSlanted] [\s!MonoBoldItalic]
    \stoptypescript

    % interesting is that we cannot move these definitions up (without loosing features)

    % caps: \definetypeface [pagella] [rm] [serif] [pagella-caps] [default]

    \starttypescript [times,termes]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [helvetica]      [\s!default] [\s!rscale=0.9]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default] [\s!rscale=1.05]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [termes]         [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [palatino,pagella]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [modern]         [\s!default] [\s!rscale=1.075]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default] [\s!rscale=1.075]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [pagella]        [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [schoolbook,schola]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [modern]         [\s!default] [\s!rscale=1.1]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default] [\s!rscale=1.1]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [schola]         [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [bookman,bonum]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [modern]         [\s!default] [\s!rscale=1.1]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default] [\s!rscale=1.1]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [bonum]          [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [chancery,chorus]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [modern]         [\s!default]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [modern]         [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [helvetica,heros]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern]         [\s!default] [\s!rscale=1.15]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]         [\s!default] [\s!rscale=1.15]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [modern]         [\s!default] [\s!rscale=1.15]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [avantgarde,adventor]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [adventor] [\s!default]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern]   [\s!default] [\s!rscale=1.15]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [modern]   [\s!default] [\s!rscale=1.15]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [modern]   [\s!default]
        \quittypescriptscanning
    \stoptypescript

    \starttypescript [courier,cursor]
        \definetypeface [\typescriptone] [\s!tt] [\s!mono]  [\typescriptone] [\s!default]
        \definetypeface [\typescriptone] [\s!rm] [\s!serif] [modern]         [\s!default]
        \definetypeface [\typescriptone] [\s!ss] [\s!sans]  [modern]         [\s!default]
        \definetypeface [\typescriptone] [\s!mm] [\s!math]  [modern]         [\s!default]
        \quittypescriptscanning
    \stoptypescript

\stoptypescriptcollection

% tricky: we cannot mix now as the file is loaded only once

\startmode[txmath]

    \starttypescriptcollection[texgyre-math-times]

        \starttypescript [\s!math][times,termes][\s!all]
            \loadfontgoodies[tx-math]
            \definefontsynonym[\s!MathRoman][txmath@tx-math]
          % \definefontsynonym[\s!MathRomanBold][MathRoman]
        \stoptypescript

    \stoptypescriptcollection

\stopmode

\startnotmode[txmath]

    \starttypescriptcollection[texgyre-math-times]

        \starttypescript [\s!math][times,termes][\s!all]
          % \loadfontgoodies[texgyre]
          % \definefontsynonym[\s!MathRoman][file:texgyre-termes-math-regular.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=texgyre]
            \definefontsynonym[\s!MathRoman]    [file:texgyretermes-math.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=termes-math]
            \definefontsynonym[\s!MathRomanBold][file:texgyretermes-math.otf][\s!features={\s!math\mathsizesuffix,termes-math-bold,mathextra},\s!goodies=schola-math]
        \stoptypescript

    \stoptypescriptcollection

\stopnotmode

\startmode[pxmath]

    \starttypescriptcollection[texgyre-math-pagella]

        \starttypescript [\s!math][palatino,pagella][\s!all]
            \loadfontgoodies[px-math]
            \definefontsynonym[\s!MathRoman][pxmath@px-math]
          % \definefontsynonym[\s!MathRomanBold][MathRoman]
        \stoptypescript

    \stoptypescriptcollection

\stopmode

\startnotmode[pxmath]

    \starttypescriptcollection[texgyre-math-pagella]

        \starttypescript [\s!math][palatino,pagella][\s!all]
          % \loadfontgoodies[texgyre]
          % \definefontsynonym[\s!MathRoman][file:texgyre-pagella-math-regular.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=texgyre]
            \definefontsynonym[\s!MathRoman]    [file:texgyrepagella-math.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=pagella-math]
            \definefontsynonym[\s!MathRomanBold][file:texgyrepagella-math.otf][\s!features={\s!math\mathsizesuffix,pagella-math-bold,mathextra},\s!goodies=schola-math]
        \stoptypescript

    \stoptypescriptcollection

\stopnotmode

\starttypescriptcollection[texgyre-math-bonum]

    \starttypescript [\s!math][bookman,bonum][\s!all]
      % \loadfontgoodies[texgyre]
      % \definefontsynonym[\s!MathRoman][file:texgyre-bonum-math-regular.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=texgyre]
        \definefontsynonym[\s!MathRoman]    [file:texgyrebonum-math.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=bonum-math]
        \definefontsynonym[\s!MathRomanBold][file:texgyrebonum-math.otf][\s!features={\s!math\mathsizesuffix,bonum-math-bold,mathextra},\s!goodies=schola-math]
    \stoptypescript

\stoptypescriptcollection

\starttypescriptcollection[texgyre-math-schola]

    \starttypescript [\s!math][schoolbook,schola][\s!all]
      % \loadfontgoodies[texgyre]
      % \definefontsynonym[\s!MathRoman][file:texgyre-schola-math-regular.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=texgyre]
        \definefontsynonym[\s!MathRoman]    [file:texgyreschola-math.otf][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=schola-math]
        \definefontsynonym[\s!MathRomanBold][file:texgyreschola-math.otf][\s!features={\s!math\mathsizesuffix,schola-math-bold,mathextra},\s!goodies=schola-math]
    \stoptypescript

\stoptypescriptcollection


