%D \module
%D   [       file=t-oldgreek,
%D        version=2006.04.10,
%D          title=Ancient Greek,
%D       subtitle=Publications,
%D         author=Thomas A. Schmitz
%D           date=\currentdate,
%D      copyright=Thomas A. Schmitz]
%C
%C This program is free software; you can redistribute it and/or modify it under
%C the terms of the GNU General Public License as published by the Free Software
%C Foundation; either version 2 of the License, or (at your option) any later
%C version.

%D Module t-oldgreek providing method for polytonic Greek input in \CONTEXT.
%D This module is for compatibility reasons only: please use module
%D t-ancientgreek in normal circumstances. Only when this does not work, try if
%D the simpler setup in this module solves your problems.

\writestatus{loading}{module oldgreek}

\startmodule[oldgreek]

\unprotect

%D The new mechanism for modules allows setting values. We need to provide
%D default setups for fonts and scaling. The \tex{setupgreek} command is not
%D needed any longer; we now set these values when we call the module in this
%D form:
%D \starttyping
%D \usemodule[oldgreek][font=KadmosNew,scale=1.2,altfont=BosporosNew,altscale=1]
%D \stoptyping

\setupmodule[scale=1,font=Ibycus,altfont=Leipzig,altscale=1]

%D load mapfile for Greek fonts
\loadmapfile[tasgreek.map]

%D Next, we load the appropriate unicode vector for polytonic Greek.

\useunicodevector[31]

%D We use the encoding for ancient Greek.

\useencoding[agr]
 
%D define fontsynonyms
\definefontsynonym[Alkaios]       [agralk-Alkaios]                [encoding=agr]
\definefontsynonym[Alkaioslun]    [agralk-l-Alkaios]              [encoding=agr]
\definefontsynonym[Aristarcoj]    [ariagr-Aristarcoj]             [encoding=agr]
\definefontsynonym[Bosporos]      [Bosporosc]                     [encoding=agr]
\definefontsynonym[Bosporoslun]   [Bosporosl]                     [encoding=agr]
\definefontsynonym[Bosporosnew]   [bosnew]                        [encoding=agr]
\definefontsynonym[GaramondGreek] [greekgara]                     [encoding=agr]
\definefontsynonym[GreekAisa]     [aisagr-AisaUC]                 [encoding=agr]
\definefontsynonym[GreekAisait]   [aisagr-AisaUCi]                [encoding=agr]
\definefontsynonym[GreekAisabo]   [aisagr-AisaUCb]                [encoding=agr]
\definefontsynonym[GreekAisaboit] [aisagr-AisaUCbi]               [encoding=agr]
\definefontsynonym[GreekBodoni]   [gfsgreekbodoni]                [encoding=agr]
\definefontsynonym[GreekBodoniit] [gfsgreekbodoniitalic]          [encoding=agr]
\definefontsynonym[GreekBodonibo] [gfsgreekbodonibold]            [encoding=agr]
\definefontsynonym[GreekCanonica]      [canagr-MgOpenCanonica]    [encoding=agr]
\definefontsynonym[GreekCanonicait]    [canagrit-MgOpenCanonicaItalic] [encoding=agr]
\definefontsynonym[GreekCanonicabo]    [canagr-MgOpenCanonicaBold][encoding=agr]
\definefontsynonym[GreekCanonicaboit]  [canagr-MgOpenCanonicaBoldItalic][encoding=agr]
\definefontsynonym[GreekCardo]     [Cardos]                        [encoding=agr]
\definefontsynonym[GreekCentury]       [greekcentury]             [encoding=agr]
\definefontsynonym[GreekDidot]     [gfsgreekdidot]                 [encoding=agr]
\definefontsynonym[GreekDidotit]   [gfsgreekdidotitalic]           [encoding=agr]
\definefontsynonym[GreekDidotbo]   [gfsgreekdidotbold]             [encoding=agr]
\definefontsynonym[GreekDidotboit] [gfsgreekdidotbolditalic]       [encoding=agr]
\definefontsynonym[GreekDioxipe]       [dioxagr-dioxi]            [encoding=agr]
\definefontsynonym[GreekDioxipeit]     [dioitagr-Dioxipe-Italic]  [encoding=agr]
\definefontsynonym[GreekDioxipebo]     [dioboagr-Dioxipe-Bold]    [encoding=agr]
\definefontsynonym[GreekDioxipelun]    [dioxagr-l-dioxi]          [encoding=agr]
\definefontsynonym[GreekGandhari]      [gandhar]                  [encoding=agr]
\definefontsynonym[GreekGandhariit]    [gandhai]                  [encoding=agr]
\definefontsynonym[GreekGaramondPrem]    [garagr-KERN-GaramondPremrPro]                     [encoding=agr]
\definefontsynonym[GreekGaramondPremit] [garagr-KERN-GaramondPremrPro-It]                     [encoding=agr]
\definefontsynonym[GreekGaramondPrembo] [garagr-KERN-GaramondPremrPro-Bd]                     [encoding=agr]
\definefontsynonym[GreekGaramondPremboit] [garagr-KERN-GaramondPremrPro-BdIt]                     [encoding=agr]
\definefontsynonym[GreekGentiumit][GreekGentiumItalic]            [encoding=agr]
\definefontsynonym[GreekGentiumAltit]  [GreekGentiumAltItalic]     [encoding=agr]
\definefontsynonym[GreekGentiumAltlun] [Gentium]                   [encoding=agr]
\definefontsynonym[GreekGentiumAltlunit][GreekGentiumAltItaliclun] [encoding=agr]
\definefontsynonym[GreekGentiumitlun]  [GreekGentiumItaliclun]          [encoding=agr]
\definefontsynonym[GreekKerkis]        [Kerkis]                    [encoding=agr]
\definefontsynonym[GreekKerkisit]      [Kerkis-Italic]             [encoding=agr]
\definefontsynonym[GreekKerkisbo]      [Kerkis-Bold]               [encoding=agr]
\definefontsynonym[GreekKerkisboit]    [Kerkis-BoldItalic]        [encoding=agr]
\definefontsynonym[GreekKorinthia][koragr-Korinthia]              [encoding=agr]
\definefontsynonym[GreekKorinthialun]  [koragr-l-Korinthia]            [encoding=agr]
\definefontsynonym[GreekLfb]      [greeklfb]                      [encoding=agr]
\definefontsynonym[GreekMinion]   [minagr-MinionPro-Regular]      [encoding=agr]
\definefontsynonym[GreekMinionit] [minagr-MinionPro-It]           [encoding=agr]
\definefontsynonym[GreekMinionbo] [minagr-MinionPro-Bold]         [encoding=agr]
\definefontsynonym[GreekMinionlun]     [minagr-l-MinionPro-It]         [encoding=agr]
\definefontsynonym[GreekMinionbolun]   [minagr-l-MinionPro-Bold]       [encoding=agr]
\definefontsynonym[GreekMinionitlun]   [minagr-l-MinionPro-It]       [encoding=agr]
\definefontsynonym[GreekPalatino] [palagr-PalatinoLinotype-Roman] [encoding=agr]
\definefontsynonym[GreekPalatinoit] [palagr-PalatinoLinotype-Italic][encoding=agr]
\definefontsynonym[GreekPalatinobo][palagr-PalatinoLinotype-Bold]  [encoding=agr]
\definefontsynonym[GreekPalatinoboit][palagr-PalatinoLinotype-BoldItalic] [encoding=agr]
\definefontsynonym[GreekSang]     [Greeksangtf]                   [encoding=agr]
\definefontsynonym[GreekSerif]    [freeagr-FreeSerif]             [encoding=agr]
\definefontsynonym[GreekSerifit]  [freeagrit-FreeSerifItalic]     [encoding=agr]
\definefontsynonym[GreekSerifbo]  [freeagrit-FreeSerifBold]       [encoding=agr]
\definefontsynonym[GreekSerifboit][freeagrit-FreeSerifBoldItalic] [encoding=agr]
\definefontsynonym[GreekTimes]    [timagr-Times-Roman]            [encoding=agr]
\definefontsynonym[GreekTimesbo]  [timagr-Times-Bold]             [encoding=agr]
\definefontsynonym[GreekTimesit]  [timagr-Times-Italic]           [encoding=agr]
\definefontsynonym[GreekTimesboit][timagr-Times-BoldItalic]       [encoding=agr]
\definefontsynonym[Kadmos]        [kadmo]                         [encoding=agr]
\definefontsynonym[Kadmoslun]     [kadmoc]                        [encoding=agr]
\definefontsynonym[KadmosNew]     [kadmnew]                       [encoding=agr]
\definefontsynonym[GFSOlga]       [olgagr-GFSOlga]                [encoding=agr]
\definefontsynonym[Oxonia]        [oxonia]                        [encoding=agr]
\definefontsynonym[Oxonialun]     [oxoniac]                       [encoding=agr]
\definefontsynonym[Teubner]       [Teubnerc]                      [encoding=agr]
\definefontsynonym[Vusillus]      [vusagr-vusilli]                [encoding=agr]

%D The next lines define a Metric font. This is just a quick and dirty hack to
%D get some metric symbols; we may some day write proper code for it. For the
%D time being, no frills are needed here since this will always be used for a
%D few characters only.

\definefontsynonym[MFont][Anaxiphorminx]
\definefont[metre][MFont sa 1.2]

\define\Mf{\groupedcommand{\metre}{}}

\define\aeolbase{\getglyph{Anaxiphorminx}{\char227}\getglyph{Anaxiphorminx}{\char227}}

\define\acephal{\getglyph{Anaxiphorminx}{\char142}}

%D use values to define Greek font
\expanded{\definefont[GreekFont][\currentmoduleparameter{font} sa \currentmoduleparameter{scale}]}
\expanded{\definefont[AltGreekFont][\currentmoduleparameter{altfont} sa \currentmoduleparameter{altscale}]}

%D The following code was suggested by Hans to take care of problems with the
%D catcode changes within table environments: 

\long\def\rescanwithsetup#1#2%
   {{\directsetup{#1}\scantokens{#2\ignorespaces}}} 

%D We wrap everything that is needed for obtaining Greek output into a setup
%D buffer: change the catcodes of accents, switch to the language ancientgreek
%D so we get proper hyphenation, and switch to the proper bodyfont:
   
\startsetups[enablegreek]%
   \catcode`~=\other% 
   \catcode`|=\other%
   \catcode`'=\other% 
   \language[ancientgreek]%
   \GreekFont 
\stopsetups 
   
\startsetups[enablealtgreek]%
   \catcode`~=\other% 
   \catcode`|=\other%
   \catcode`'=\other% 
   \language[ancientgreek]%
   \AltGreekFont
\stopsetups 

%D Finally, we define a startstop environment and a command to enable these
%D setups:

\definestartstop[greek][commands=\directsetup{enablegreek}]

\definestartstop[altgreek][commands=\directsetup{enablealtgreek}]

\def\localgreek{\rescanwithsetup{enablegreek}}

\def\localaltgreek{\rescanwithsetup{enablealtgreek}}

\protect
\stopmodule
\endinput
