% Use t-ancientgreek module for typesetting ancient Koine Greek
\usemodule[ancientgreek][font=Aristarcoj,scale=1.1]
%\usemodule[ancientgreek][font=KadmosNew,scale=1]
%\usemodule[ancientgreek][font=GreekGentiumAlt,scale=1]

% Set up custom paper size
\definepapersize[TradePaper][width=6in,height=9in]
\setuppapersize[TradePaper][TradePaper]

% Set up page layout
\setuplayout
[
    topspace=.3in,
    %bottomspace=.25in,
    bottomspace=0in,
    bottom=.25in,
    bottomdistance=.1in,
    cutspace=0in,
    backspace=.5in,
    header=.2in,
    headerdistance=.1in,
    footer=0in,
    rightmargin=0in,
    leftmargin=0in,
    height=8.15in,
    width=4.75in
]

% Use 12pt font by default
\setupbodyfont[Serif,11pt]

% Set up line-break tolerance
\setuptolerance[horizontal,space,verytolerant]
\raggedbottom

% Set up indentation parameters
\setupindenting[big,yes]
%\setupindenting[medium,yes]
\indenting[always]

% Set up inter-paragraph spacing
\setupwhitespace[medium]

% Set up a counter that will act as our footnote label
\newcounter\fnumlabel

% Set up special command to turn off default footnote numbers next to footnote text
\def\deffnumsoff#1{\tfxx}

% Set up footnotes in paragraph form (n=0) with proper font size, etc., and no default footnote numbers.
% Footnote numbers will be part of actual footnote text.
\setupfootnotes[n=0,bodyfont=9pt,way=bypage,before=\crlf\hairline,textcommand=\vii\high,style=\it\vii,rule=off,numbercommand=\deffnumsoff,split=tolerant]

% Left-justify footnotes
\setupfootnotedefinition[distance=0pt]

% Set up custom macro to replace default \footnote macro. This macro will include the footnote number
% as part of the footnote text and then increment the footnote label counter for the next footnote.
\def\fnote#1#2{\footnote[\fnumlabel]{\note[\fnumlabel]\localgreek{#1}, \ix{\it{#2}}}\increment\fnumlabel}

% Set up footnotes so that there is hyphenation
%\setupnote[footnote][align={normal,hyphenated}]
\setupnote[footnote][align={nothyphenated,stretch,verytolerant}]

% Set up macros to handle drop-cap chapter numbers
%\def\DropChapOne{\DroppedCaps{}{Serif}{4\baselineskip}{0pt}{2\baselineskip}{3}}
\def\DropChapOne{\DroppedCaps{}{Serif}{2.4\baselineskip}{5pt}{1\baselineskip}{2}}
\def\DropChap{\DroppedCaps{}{Serif}{2.4\baselineskip}{5pt}{1\baselineskip}{2}}

% Set up marker for verses
\definemarking[verse][verses]

%
% Text formatting macros:
%

% Very large dropped number for first chapter number of book
\def\bookbeg#1#2{\DropChapOne{#1}\marking[verse]{#1:#2}}

% Large dropped number for subsequent chapter numbers
\def\chapnum#1#2{\par\DropChap{#1}\marking[verse]{#1:#2}}

% Smaller, bold number followed by a non-breaking space for verse numbers
\def\versenum#1#2{{\tfx\bf #2}~\marking[verse]{#1:#2}}

% Macro for all Greek text. Note that we turn off hyphenation in this text.
\def\lg#1{\localgreek{#1}}
\def\lag#1{\localaltgreek{#1}}

% Book-style alternating pages
\setuppagenumbering[alternative=doublesided,location=,way=bytext,partnumber=no]
\setupbottomtexts[pagenumber]
\setupbottom[style=\tf,state=high]

% Clear out header texts, then set them up again
\setupheadertexts[]
\setupheadertexts[\setups{text a}][][][\setups{text b}]

% Set up header text for odd pages
\startsetups[text a]
  \hfill
  \getmarking[chapter]
  \hfill
  \llap{\getmarking[verse][first]--\getmarking[verse][last]}
\stopsetups

% Set up header text for even pages
\startsetups[text b]
  \rlap{\getmarking[verse][first]--\getmarking[verse][last]}
  \hfill
  \getmarking[chapter]
  \hfill
\stopsetups

% Hairline under every header
%\setupheader[text][after=\hairline]
\setupbackgrounds[header][text][frame=off,bottomframe=on]

% Special command to turn off chapter title numbers
\def\nochapnum#1{\crlf\crlf\crlf}

% Set up beginning-of-chapter pages so that they don't have headers
\setuphead[chapter][numbercommand=\nochapnum,distance=0pt,header=high,footer=empty,textstyle=\tfd,alternative=middle]

% Make sure footnotes stay with page they are referenced on
\brokenpenalty \zerocount

% No hyphenation please
\nohyphens

\starttext
\part[GospelsAndActs]{Gospels and Acts of the Apostles}
\chapter[Matthew]{\lg{ΚΑΤΑ ΜΑΤΘΑΙΟΝ}}
\input 01_MT.xcoded.utf8
\stoptext
