%D \module
%D   [       file=type-cowotf,
%D        version=2016.09.16,
%D          title=\CONTEXT\ Typescript Macros,
%D       subtitle=Cow Fonts (otf version),
%D         author={Taco Hoekwater \& 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 The cow fonts are a project of Duane Bibby, Hans Hagen and Taco
%D Hoekwater.

\unprotect

\definefontfeature
  [sheepdigits]
  [mode=node,
   script=latn,
   ss01=yes]

\definefontfeature
  [mathsheepdigits]
  [sheepdigits]
  [mode=base]

\definefontfeature
  [cowslogos]
  [mode=node,
   script=latn,
   ss02=yes,
   dlig=yes]

\definefontfeature
  [cowsligatures]
  [mode=node,
   script=latn,
   dlig=yes]

\definefontfeature
  [cowscolors]
  [mode=node,
   colr=yes,
   ss02=yes,
   dlig=yes]

\definefontfeature
  [cowsdefault]
  [default]
  [mode=node,
   wipemath=no,
   compose=yes]

\definefontfeature
  [sheepdefault]
  [cowsdefault,sheepdigits]

\definefontfeature
  [cowscolored]
  [cowsdefault,cowscolors]

\definefontfeature
  [sheepcolored]
  [sheepdefault,cowscolors]

\definefontfeature[sheepdefaultbold][sheepdefault][boldened]
\definefontfeature[cowsdefaultbold] [cowsdefault] [boldened]

\starttypescriptcollection[koeielettersot]

    \loadfontgoodies[koeielettersot]

    \starttypescript [\s!all] [cowsotf]
        \definefontsynonym [Cows]         [koeielettersot][\s!features=cowsdefault]
        \definefontsynonym [CowsLogo]     [koeielettersot][\s!features=cowslogos]
        \definefontsynonym [CowsMathRoman][koeielettersot][\s!features=mathextra,\s!goodies=koeielettersot]
    \stoptypescript

    \starttypescript [\s!all] [koeielettersotf,sheepotf]
        \definefontsynonym [Sheep]         [koeielettersot][\s!features=sheepdefault]
        \definefontsynonym [SheepBold]     [koeielettersot][\s!features=sheepdefaultbold]
        \definefontsynonym [SheepLogo]     [koeielettersot][\s!features=cowslogos]
        \definefontsynonym [SheepMathRoman][koeielettersot][\s!features={mathsheepdigits,mathextra},\s!goodies=koeielettersot]
    \stoptypescript

%   \definefontsynonym[\s!MathRoman][file:texgyredejavu-math][\s!features={\s!math\mathsizesuffix,mathextra},\s!goodies=dejavu-math]

    \starttypescript [\s!all] [coloredcowsotf]
        \definefontsynonym [Cows]         [koeielettersot][\s!features=cowscolored]
        \definefontsynonym [CowsLogo]     [koeielettersot][\s!features=cowslogos]
        \definefontsynonym [CowsMathRoman][koeielettersot][\s!features=mathextra,\s!goodies=koeielettersot]
    \stoptypescript

    \starttypescript [\s!all] [coloredsheepotf]
        \definefontsynonym [Sheep]         [koeielettersot][\s!features=sheepcolored]
        \definefontsynonym [SheepLogo]     [koeielettersot][\s!features=cowslogos]
        \definefontsynonym [SheepMathRoman][koeielettersot][\s!features={mathsheepdigits,mathextra},\s!goodies=koeielettersot]
    \stoptypescript

    \starttypescript [\s!serif] [cowsotf,coloredcowsotf]
        \setups[\s!font:\s!fallback:\s!serif]
        \definefontsynonym [\s!Serif]     [Cows]
        \definefontsynonym [\s!Serif Logo][CowsLogo]
    \stoptypescript

    \starttypescript [\s!serif] [koeielettersotf,sheepotf,coloredsheepotf]
        \setups[\s!font:\s!fallback:\s!serif]
        \definefontsynonym [\s!Serif]     [Sheep]
        \definefontsynonym [\s!SerifBold] [SheepBold]
        \definefontsynonym [\s!Serif Logo][SheepLogo]
    \stoptypescript

    \starttypescript [\s!math] [cowsotf,coloredcowsotf]
        \definefontsynonym [\s!MathRoman][CowsMathRoman]
        \enablemathrules % uses \fontclass, for now this way
    \stoptypescript

    \starttypescript [\s!math] [koeielettersotf,sheepotf,coloredsheepotf]
        \definefontsynonym [\s!MathRoman][SheepMathRoman]
        \enablemathrules % uses \fontclass, for now this way
    \stoptypescript

    \starttypescript [koeieletters,cows,sheep,coloredcows,coloredsheep]
        \definetypeface [\typescriptone][\s!rm][\s!serif][\typescriptone otf][\s!default]
        \definetypeface [\typescriptone][\s!ss][\s!serif][\typescriptone otf][\s!default]
        \definetypeface [\typescriptone][\s!mm][\s!math] [\typescriptone otf][\s!default]
        \definetypeface [\typescriptone][\s!tt][\s!mono] [modern]            [\s!default][\s!rscale=0.85]
    \stoptypescript

\stoptypescriptcollection

\protect

\continueifinputfile{type-imp-koeielettersot.mkiv}

\starttext

\setupbodyfont[cows]

% \input tufte

% \stoptext

% \starttext

\loadtypescriptfile[cowotf]

\definecolor[cowred]   [r=.50]
\definecolor[cowgreen] [g=.50]
\definecolor[cowblue]  [b=.50]
\definecolor[cowyellow][y=.25]

\definefontcolorpalette[cows][cowgreen,cowyellow,cowblue,cowred]

\startluacode
    fonts.handlers.otf.registerpalette("cows", {
        { g = .5 },
        { r = .75, g = .75 },
        { b = .5 },
        { r = .5 },
    })
\stopluacode

\adaptfontfeature[cowscolored] [colr=cows]

\setupbodyfont[coloredcows,12pt]

\input zapf

\definefontsynonym
  [CowsColored]
  [koeielettersot]

\showotfcomposition
  {koeielettersot*default,cowscolors}
  {1}
  {context}

\scale[width=\textwidth]{\getnamedglyphdirect{CowsColored*default,cowscolors}{contextlogo}}
\scale[width=\textwidth]{\definedfont[CowsColored*default,cowscolors]context}

\stoptext
