\startenvironment heb-sty

\mainlanguage[hebrew]

% Font setup

\definefontfeature
   [hebrew]
   [mode=node,language=dflt,script=hebr,
    init=yes,medi=yes,fina=yes,isol=yes,
    liga=yes,dlig=yes,rlig=yes,clig=yes,
    mark=yes,mkmk=yes,kern=yes,curs=yes]

\starttypescript [serif] [hebrew]
 \definefontsynonym [Ezra SIL] [name:SILEOT] [features=hebrew]
\stoptypescript

\starttypescript [serif] [hebrew] [name]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]           [Ezra SIL] [features=hebrew]
 \definefontsynonym [SerifItalic]     [Ezra SIL] [features=hebrew]
 \definefontsynonym [SerifBold]       [Ezra SIL] [features=hebrew]
 \definefontsynonym [SerifBoldItalic] [Ezra SIL] [features=hebrew]
\stoptypescript

\starttypescript [Hebrew]
  \definetypeface [Hebrew] [rm] [serif] [hebrew] [default] 
\stoptypescript 

\def\HebrewGlobalDir {\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
\def\HebrewParDir    {\textdir TRT\pardir TRT}
\def\HebrewTextDir   {\textdir TRT}
\def\LatinParDir     {\textdir TLT\pardir TLT}
\def\LatinTextDir    {\textdir TLT}
\def\LatinGlobalDir  {\pagedir TLT\bodydir TLT\pardir TLT\textdir TLT}

\define\sethebrew
  {\HebrewGlobalDir%
   \usetypescript[Hebrew]%
   \setupbodyfont[Hebrew,20pt]}

\definestartstop
  [hebrewpar]
  [commands=\Hebrew\HebrewParDir]

\define[1]\RT
  {{\Hebrew\HebrewTextDir#1}}

\define\setlatin
  {\LatinGlobalDir%
   \usetypescript[lm]%
   \setupbodyfont[lm,20pt]}

\definestartstop
  [latinpar]
  [commands=\Hebrew\LatinParDir]

\define[1]\LT
  {{\LatinTextDir#1}}

\setcharactermirroring[1]

\stopenvironment

