%D \module
%D   [       file=type-imp-unfonts,
%D        version=2012.03.11,
%D          title=\CONTEXT\ Typescript Macros,
%D       subtitle=UnFonts,
%D         author=Dalyoung \& Hans,
%D           date=\currentdate,
%D      copyright=Dalyoung \& Hans]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% usage: \setupbodyfont[unfonts]

\loadtypescriptfile[texgyre]
%\loadtypescriptfile[xits]

\definefontfeature
  [kr-default]
  [mode=node,script=hang,lang=kor]

\definefontfeature
  [kr-slanted]
  [mode=node,script=hang,lang=kor,slant=.2]

\definefontfeature
  [kr-latin-default]
  [default]

\definefontfeature
  [kr-latin-slanted]
  [krlatindefault]
  [slant=.2]

\definefontfeature
  [kr-latin-slanted-mono]
  [slant=.2]

\definefontfeature
  [kr-latin-smallcaps]
  [krlatindefault]
  [smcp=yes]

\definefontfeature
  [kr-latin-smallcaps-mono]
  [cmcp=yes]

\definefontfallback[kr-serif]           [texgyrepagella-regular*kr-latin-default]      [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifbold]       [texgyrepagella-bold*kr-latin-default]         [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifitalic]     [texgyrepagella-italic*kr-latin-default]       [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifbolditalic] [texgyrepagella-bolditalic*kr-latin-default]   [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifslanted]    [texgyrepagella-regular*kr-latin-slanted]      [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifboldslanted][texgyrepagella-bold*kr-latin-slanted]         [0x0000-0x0400][force=yes]
\definefontfallback[kr-serifcaps]       [texgyrepagella-regular*kr-latin-smallcaps]    [0x0000-0x0400][force=yes]
\definefontfallback[kr-sans]            [texgyreheros-regular*kr-latin-default]        [0x0000-0x0400][force=yes]
\definefontfallback[kr-sansbold]        [texgyreheros-bold*kr-latin-default]           [0x0000-0x0400][force=yes]
\definefontfallback[kr-sansitalic]      [texgyreheros-italic*kr-latin-default]         [0x0000-0x0400][force=yes]
\definefontfallback[kr-sansbolditalic]  [texgyreheros-bolditalic*kr-latin-default]     [0x0000-0x0400][force=yes]
\definefontfallback[kr-sansslanted]     [texgyreheros-regular*kr-latin-slanted]        [0x0000-0x0400][force=yes]
\definefontfallback[kr-sansboldslanted] [texgyreheros-bold*kr-latin-slanted]           [0x0000-0x0400][force=yes]
\definefontfallback[kr-sanscaps]        [texgyreheros-regular*kr-latin-smallcaps]      [0x0000-0x0400][force=yes]
\definefontfallback[kr-mono]            [texgyrecursor-regular]                        [0x0000-0x0400][force=yes]
\definefontfallback[kr-monobold]        [texgyrecursor-bold]                           [0x0000-0x0400][force=yes]
\definefontfallback[kr-monoitalic]      [texgyrecursor-italic]                         [0x0000-0x0400][force=yes]
\definefontfallback[kr-monobolditalic]  [texgyrecursor-bolditalic]                     [0x0000-0x0400][force=yes]
\definefontfallback[kr-monoslanted]     [texgyrecursor-regular*kr-latin-slanted-mono]  [0x0000-0x0400][force=yes]
\definefontfallback[kr-monoboldslanted] [texgyrecursor-bold*kr-latin-slanted-mono]     [0x0000-0x0400][force=yes]
\definefontfallback[kr-monocaps]        [texgyrecursor-regular*kr-latin-smallcaps-mono][0x0000-0x0400][force=yes]

\starttypescriptcollection[unfonts]

    \starttypescript [\s!serif] [unbatang]
        \definefontsynonym [unbatang]           [\s!file:unbatang]    [\s!features=kr-default,\s!fallbacks=kr-serif]
        \definefontsynonym [unbatangbold]       [\s!file:unbatangbold][\s!features=kr-default,\s!fallbacks=kr-serifbold]
        \definefontsynonym [unbatangitalic]     [\s!file:unbatang]    [\s!features=kr-slanted,\s!fallbacks=kr-serifitalic]
        \definefontsynonym [unbatangbolditalic] [\s!file:unbatangbold][\s!features=kr-slanted,\s!fallbacks=kr-serifbolditalic]
        \definefontsynonym [unbatangslanted]    [\s!file:unbatang]    [\s!features=kr-slanted,\s!fallbacks=kr-serifslanted]
        \definefontsynonym [unbatangboldslanted][\s!file:unbatangbold][\s!features=kr-slanted,\s!fallbacks=kr-serifboldslanted]
        \definefontsynonym [unbatangcaps]       [\s!file:unbatang]    [\s!features=kr-default,\s!fallbacks=kr-serifcaps]
    \stoptypescript

    \starttypescript [\s!sans] [undotum]
        \definefontsynonym[undotum]             [\s!file:undotum]     [\s!features=kr-default,\s!fallbacks=kr-sans]
        \definefontsynonym[undotumbold]         [\s!file:undotumbold] [\s!features=kr-default,\s!fallbacks=kr-sansbold]
        \definefontsynonym[undotumitalic]       [\s!file:undotum]     [\s!features=kr-slanted,\s!fallbacks=kr-sansitalic]
        \definefontsynonym[undotumbolditalic]   [\s!file:undotumbold] [\s!features=kr-slanted,\s!fallbacks=kr-sansbolditalic]
        \definefontsynonym[undotumslanted]      [\s!file:undotum]     [\s!features=kr-slanted,\s!fallbacks=kr-sansslanted]
        \definefontsynonym[undotumboldslanted]  [\s!file:undotumbold] [\s!features=kr-slanted,\s!fallbacks=kr-sansboldslanted]
        \definefontsynonym[undotumcaps]         [\s!file:undotum]     [\s!features=kr-default,\s!fallbacks=kr-sanscaps]
    \stoptypescript

    \starttypescript [\s!mono] [untype]
        \definefontsynonym[untype]              [\s!file:untaza]      [\s!features=kr-default,\s!fallbacks=kr-mono]
        \definefontsynonym[untypebold]          [\s!file:untaza]      [\s!features=kr-default,\s!fallbacks=kr-monobold]
        \definefontsynonym[untypeitalic]        [\s!file:untaza]      [\s!features=kr-slanted,\s!fallbacks=kr-monoitalic]
        \definefontsynonym[untypebolditalic]    [\s!file:untaza]      [\s!features=kr-slanted,\s!fallbacks=kr-monobolditalic]
        \definefontsynonym[untypeslanted]       [\s!file:untaza]      [\s!features=kr-slanted,\s!fallbacks=kr-monoslanted]
        \definefontsynonym[untypeboldslanted]   [\s!file:untaza]      [\s!features=kr-slanted,\s!fallbacks=kr-monoboldslanted]
        \definefontsynonym[untypecaps]          [\s!file:untaza]      [\s!features=kr-default,\s!fallbacks=kr-monocaps]
    \stoptypescript

    \starttypescript [\s!serif] [unbatang] [\s!name]
        \definefontsynonym[\s!Serif]           [unbatang]
        \definefontsynonym[\s!SerifBold]       [unbatangbold]
        \definefontsynonym[\s!SerifItalic]     [unbatangitalic]
        \definefontsynonym[\s!SerifBoldItalic] [unbatangbolditalic]
        \definefontsynonym[\s!SerifSlanted]    [unbatangslanted]
        \definefontsynonym[\s!SerifBoldSlanted][unbatangboldslanted]
        \definefontsynonym[\s!SerifCaps]       [unbatangcaps]
    \stoptypescript

    \starttypescript [\s!sans] [undotum] [\s!name]
        \definefontsynonym[\s!Sans]            [undotum]
        \definefontsynonym[\s!SansBold]        [undotumbold]
        \definefontsynonym[\s!SansItalic]      [undotumitalic]
        \definefontsynonym[\s!SansBoldItalic]  [undotumbolditalic]
        \definefontsynonym[\s!SansSlanted]     [undotumslanted]
        \definefontsynonym[\s!SansBoldSlanted] [undotumboldslanted]
        \definefontsynonym[\s!SansCaps]        [undotumcaps]
    \stoptypescript

    \starttypescript [\s!mono] [untype] [\s!name]
        \definefontsynonym[\s!Mono]            [untype]
        \definefontsynonym[\s!MonoBold]        [untypebold]
        \definefontsynonym[\s!MonoItalic]      [untypeitalic]
        \definefontsynonym[\s!MonoBoldItalic]  [untypebolditalic]
        \definefontsynonym[\s!MonoSlanted]     [untypeslanted]
        \definefontsynonym[\s!MonoBoldSlanted] [untypeboldslanted]
        \definefontsynonym[\s!MonoCaps]        [untypecaps]
    \stoptypescript

    % xits might get replaced with a pagella once we have it

    \starttypescript[unfonts]
        \definetypeface [unfonts] [\s!rm] [\s!serif] [unbatang]
        \definetypeface [unfonts] [\s!ss] [\s!sans]  [undotum]
        \definetypeface [unfonts] [\s!tt] [\s!mono]  [untype]
        \definetypeface [unfonts] [\s!mm] [\s!math]  [pagella]
    \stoptypescript

\stoptypescriptcollection
